Taragolis opened a new pull request, #37772:
URL: https://github.com/apache/airflow/pull/37772
<!--
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.
-->
<!--
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/
-->
Enable auto-fixable or partially fixable [flake8-pytest-style (PT)
rules](https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt)
```console
Run 'ruff' for extremely fast Python
linting.............................Failed
- hook id: ruff
- exit code: 1
- files were modified by this hook
tests/cli/commands/test_dag_command.py:25:22: TID251 `unittest.TestCase` is
banned: Use pytest compatible classes
tests/cli/commands/test_dag_command.py:601:18: PT027 Use `pytest.raises`
instead of unittest-style `assertRaises`
tests/conftest.py:1115:31: PT003 `scope='function'` is implied in
`@pytest.fixture()`
tests/decorators/test_bash.py:38:21: PT003 `scope='function'` is implied in
`@pytest.fixture()`
tests/plugins/test_plugins_manager.py:168:35: PT003 `scope='function'` is
implied in `@pytest.fixture()`
tests/providers/amazon/aws/hooks/test_eks.py:102:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/amazon/aws/hooks/test_eks.py:136:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/amazon/aws/hooks/test_eks.py:178:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/amazon/aws/sensors/test_eks.py:71:21: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/amazon/aws/sensors/test_eks.py:112:21: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/amazon/aws/sensors/test_eks.py:160:21: PT003
`scope='function'` is implied in `@pytest.fixture()`
Found 58 errors (47 fixed, 11 remaining).
No fixes available (9 hidden fixes can be enabled with the `--unsafe-fixes`
option).
tests/providers/cncf/kubernetes/operators/test_pod.py:75:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/docker/operators/test_docker.py:141:35: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/docker/test_exceptions.py:49:35: PT003 `scope='function'` is
implied in `@pytest.fixture()`
tests/providers/fab/auth_manager/test_security.py:157:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/fab/auth_manager/test_security.py:192:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/fab/auth_manager/test_security.py:204:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/fab/auth_manager/test_security.py:215:17: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/microsoft/azure/hooks/test_container_instance.py:35:17:
PT003 `scope='function'` is implied in `@pytest.fixture()`
tests/providers/openlineage/extractors/test_bash.py:46:31: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/providers/openlineage/extractors/test_python.py:61:31: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/test_utils/system_tests_class.py:70:35: PT003 `scope='function'` is
implied in `@pytest.fixture()`
tests/ti_deps/deps/test_not_previously_skipped_dep.py:34:31: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/ti_deps/deps/test_runnable_exec_date_dep.py:34:31: PT003
`scope='function'` is implied in `@pytest.fixture()`
tests/utils/log/test_secrets_masker.py:451:21: PT003 `scope='function'` is
implied in `@pytest.fixture()`
tests/www/views/test_views_trigger_dag.py:40:17: PT003 `scope='function'` is
implied in `@pytest.fixture()`
Found 147 errors (132 fixed, 15 remaining).
No fixes available (15 hidden fixes can be enabled with the `--unsafe-fixes`
option).
```
The only one which are not enabled is
[`PT022`](https://docs.astral.sh/ruff/rules/pytest-useless-yield-fixture/)
In some easy cases it produce expected result
```diff
diff --git a/tests/cli/commands/test_info_command.py
b/tests/cli/commands/test_info_command.py
index 7203371484..44287bb0ec 100644
--- a/tests/cli/commands/test_info_command.py
+++ b/tests/cli/commands/test_info_command.py
@@ -174,7 +174,7 @@ class TestAirflowInfo:
@pytest.fixture
def setup_parser():
- yield cli_parser.get_parser()
+ return cli_parser.get_parser()
```
In another it produces semantically correct replacement but personally I've
found it ugly. So better to fix it manually by the separate PR and disable
autofix for this rule
```diff
diff --git a/tests/conftest.py b/tests/conftest.py
index 1847e1e909..e41d03411b 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -131,7 +131,7 @@ def reset_db():
from airflow.utils import db
db.resetdb()
- yield
+ return
```
<!-- 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
[newsfragments](https://github.com/apache/airflow/tree/main/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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]