You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "xchwan (via GitHub)" <gi...@apache.org> on 2025/09/15 04:28:38 UTC
[PR] Enable pt011 rule 0 [airflow]
xchwan opened a new pull request, #55659:
URL: https://github.com/apache/airflow/pull/55659
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Enable Even More PyDocStyle Checks #40567
@ferruzzi enable PT011 to pytest. There are 102 files changes is need.
So, I separate to many PR, which contains about 5 file changes for easy review.
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #55659:
URL: https://github.com/apache/airflow/pull/55659#discussion_r2348537716
##########
dev/stats/explore_pr_candidates.ipynb:
##########
Review Comment:
Why was this file changed? It seems unrelated to the PR? 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on PR #55659:
URL: https://github.com/apache/airflow/pull/55659#issuecomment-3293643783
Can you add a one-liner tot he PR description with what the rule is, so we can make sure the changes are scoped correctly?
https://docs.astral.sh/ruff/rules/pytest-raises-too-broad/
PT011: all instances of `pytest.raises` should include a `match` term to make sure they are catching the right error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #55659:
URL: https://github.com/apache/airflow/pull/55659#discussion_r2349958888
##########
task-sdk/tests/task_sdk/definitions/test_asset_decorators.py:
##########
@@ -115,7 +115,7 @@ def root_func():
def asset_func():
pass
- with pytest.raises(ValueError) as err:
+ with pytest.raises(ValueError, match="nested function not supported") as err:
root_func()
assert err.value.args[0] == "nested function not supported"
Review Comment:
May be wrong, but I think err.value.args[0] is the error message. If that is the case this (and elsewhere) can be cleaned up as well.
##########
task-sdk/tests/task_sdk/definitions/test_asset.py:
##########
@@ -386,10 +386,8 @@ def normalizer(uri):
_mock_get_uri_normalizer_raising_error,
)
def test_sanitize_uri_raises_exception():
- with pytest.raises(ValueError) as e_info:
+ with pytest.raises(ValueError, match="Incorrect URI format"):
_sanitize_uri("postgres://localhost:5432/database.schema.table")
- assert isinstance(e_info.value, ValueError)
- assert str(e_info.value) == "Incorrect URI format"
Review Comment:
I like that this one lets us consolidate multiple tests into one line.
##########
dev/stats/explore_pr_candidates.ipynb:
##########
Review Comment:
I agree with Ash, the two ipynb files don't seem to be relevant
##########
task-sdk/tests/task_sdk/definitions/decorators/test_task_group.py:
##########
@@ -174,14 +175,10 @@ def tg(a, b):
tg.partial(a=1).expand(b=t()["values"])
- with pytest.raises(ValueError) as ctx:
+ expected_msg = "cannot map over XCom with custom key 'values' from <Task(_PythonDecoratedOperator): t>"
+ with pytest.raises(ValueError, match=re.escape(expected_msg)):
Review Comment:
Nitpick (here and below), feel free to close or ignore this, but I'm pretty sure you can define the match string as a raw-string like this and save the import, but I haven't tested this.
```suggestion
expected_msg = r"cannot map over XCom with custom key 'values' from <Task(_PythonDecoratedOperator): t>"
with pytest.raises(ValueError, match=expected_msg):
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #55659:
URL: https://github.com/apache/airflow/pull/55659#discussion_r2349238458
##########
dev/stats/explore_pr_candidates.ipynb:
##########
Review Comment:
This files are changed went I comment out PT011 rule and ruff check runs other need change. I just run ```ruff check --fix``` to fix it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #55659:
URL: https://github.com/apache/airflow/pull/55659#discussion_r2349238458
##########
dev/stats/explore_pr_candidates.ipynb:
##########
Review Comment:
This files are changed went I comment out PT011 rule and ruff check get other need change part. I just run ```ruff check --fix``` to fix it. I can rollback If there are any concern.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "xchwan (via GitHub)" <gi...@apache.org>.
xchwan commented on code in PR #55659:
URL: https://github.com/apache/airflow/pull/55659#discussion_r2349238458
##########
dev/stats/explore_pr_candidates.ipynb:
##########
Review Comment:
This files are changed went I comment out PT011 rule and ruff check get other need change part. I just run ```ruff check --fix``` to fix it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 merged PR #55659:
URL: https://github.com/apache/airflow/pull/55659
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enable pt011 rule 0 [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #55659:
URL: https://github.com/apache/airflow/pull/55659#discussion_r2356972712
##########
task-sdk/tests/task_sdk/definitions/test_asset_decorators.py:
##########
@@ -115,20 +115,17 @@ def root_func():
def asset_func():
pass
- with pytest.raises(ValueError) as err:
+ with pytest.raises(ValueError, match="nested function not supported"):
root_func()
- assert err.value.args[0] == "nested function not supported"
-
@pytest.mark.parametrize("func_fixer", ("self", "context"), indirect=True)
def test_with_invalid_asset_name(self, func_fixer):
@func_fixer
def example_asset_func():
pass
- with pytest.raises(ValueError) as err:
+ with pytest.raises(ValueError, match="prohibited name for asset"):
Review Comment:
```suggestion
with pytest.raises(ValueError, match="prohibited name for asset: {func_fixer.fixed_name}"):
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org