Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default for PT001 and PT023 #12838

Merged
merged 3 commits into from
Aug 13, 2024
Merged

Conversation

MichaReiser
Copy link
Member

Summary

This PR promotes the changed defaults for PT001 and PT023 to not require parentheses for fixtures and marker decorators without arguments to stable.

The default were changed in preview mode back in June (#12106).

See #8796

Test Plan

Updated snapshot tests

@MichaReiser MichaReiser added breaking Breaking API change configuration Related to settings and configuration labels Aug 12, 2024
@MichaReiser MichaReiser added this to the v0.6 milestone Aug 12, 2024
@@ -930,9 +925,7 @@ pub(crate) fn fixture(
check_fixture_decorator(checker, name, decorator);
}

if checker.enabled(Rule::PytestDeprecatedYieldFixture)
&& checker.settings.flake8_pytest_style.fixture_parentheses
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was a bug. It's unclear to me why this rule would depend on enabling that setting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's odd. I tried digging through blame but the best I can conclude without spending too much time on it is that it's been this way for a long time xD

Copy link
Contributor

github-actions bot commented Aug 12, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+355 -957 violations, +2006 -0 fixes in 10 projects; 44 projects unchanged)

PlasmaPy/PlasmaPy (+93 -0 violations, +0 -0 fixes)

+ tests/analysis/test_nullpoint.py:241:1: PT023 [*] Use `@pytest.mark.slow` over `@pytest.mark.slow()`
+ tests/analysis/test_nullpoint.py:258:1: PT023 [*] Use `@pytest.mark.slow` over `@pytest.mark.slow()`
+ tests/analysis/test_nullpoint.py:292:1: PT023 [*] Use `@pytest.mark.slow` over `@pytest.mark.slow()`
+ tests/analysis/test_nullpoint.py:311:1: PT023 [*] Use `@pytest.mark.slow` over `@pytest.mark.slow()`
+ tests/analysis/test_nullpoint.py:345:1: PT023 [*] Use `@pytest.mark.slow` over `@pytest.mark.slow()`
+ tests/analysis/test_nullpoint.py:363:1: PT023 [*] Use `@pytest.mark.slow` over `@pytest.mark.slow()`
... 55 additional changes omitted for rule PT023
+ tests/diagnostics/charged_particle_radiography/test_detector_stacks.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ tests/diagnostics/charged_particle_radiography/test_detector_stacks.py:31:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ tests/diagnostics/test_langmuir.py:144:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ tests/diagnostics/test_langmuir.py:152:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
... 83 additional changes omitted for project

apache/airflow (+0 -316 violations, +1220 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

- airflow/__init__.py:108:5: RET506 Unnecessary `elif` after `raise` statement
+ airflow/__init__.py:108:5: RET506 [*] Unnecessary `elif` after `raise` statement
- airflow/api/auth/backend/kerberos_auth.py:128:9: RET505 Unnecessary `elif` after `return` statement
+ airflow/api/auth/backend/kerberos_auth.py:128:9: RET505 [*] Unnecessary `elif` after `return` statement
- airflow/api/auth/backend/kerberos_auth.py:165:13: RET505 Unnecessary `elif` after `return` statement
+ airflow/api/auth/backend/kerberos_auth.py:165:13: RET505 [*] Unnecessary `elif` after `return` statement
- airflow/api_connexion/endpoints/config_endpoint.py:119:5: RET505 Unnecessary `elif` after `return` statement
+ airflow/api_connexion/endpoints/config_endpoint.py:119:5: RET505 [*] Unnecessary `elif` after `return` statement
... 923 additional changes omitted for rule RET505
- airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:47:9: RET506 Unnecessary `else` after `raise` statement
+ airflow/api_connexion/endpoints/forward_to_fab_endpoint.py:47:9: RET506 [*] Unnecessary `else` after `raise` statement
- airflow/cli/commands/dag_command.py:281:5: RET506 Unnecessary `elif` after `raise` statement
+ airflow/cli/commands/dag_command.py:281:5: RET506 [*] Unnecessary `elif` after `raise` statement
... 255 additional changes omitted for rule RET506
- airflow/dag_processing/manager.py:586:21: RET508 Unnecessary `elif` after `break` statement
+ airflow/dag_processing/manager.py:586:21: RET508 [*] Unnecessary `elif` after `break` statement
- airflow/jobs/scheduler_job_runner.py:585:21: RET507 Unnecessary `else` after `continue` statement
+ airflow/jobs/scheduler_job_runner.py:585:21: RET507 [*] Unnecessary `else` after `continue` statement
- airflow/models/xcom_arg.py:655:13: RET508 Unnecessary `elif` after `break` statement
+ airflow/models/xcom_arg.py:655:13: RET508 [*] Unnecessary `elif` after `break` statement
- airflow/providers/amazon/aws/hooks/sagemaker.py:1207:21: RET508 Unnecessary `else` after `break` statement
+ airflow/providers/amazon/aws/hooks/sagemaker.py:1207:21: RET508 [*] Unnecessary `else` after `break` statement
... 5 additional changes omitted for rule RET508
- airflow/providers/amazon/aws/secrets/secrets_manager.py:233:13: RET507 Unnecessary `elif` after `continue` statement
+ airflow/providers/amazon/aws/secrets/secrets_manager.py:233:13: RET507 [*] Unnecessary `elif` after `continue` statement
- airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py:627:13: RET507 Unnecessary `elif` after `continue` statement
... 1513 additional changes omitted for project

apache/superset (+71 -129 violations, +24 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

- RELEASING/verify_release.py:52:5: RET505 Unnecessary `else` after `return` statement
+ RELEASING/verify_release.py:52:5: RET505 [*] Unnecessary `else` after `return` statement
- RELEASING/verify_release.py:93:9: RET505 Unnecessary `elif` after `return` statement
+ RELEASING/verify_release.py:93:9: RET505 [*] Unnecessary `elif` after `return` statement
- scripts/build_docker.py:67:5: RET505 Unnecessary `elif` after `return` statement
+ scripts/build_docker.py:67:5: RET505 [*] Unnecessary `elif` after `return` statement
... 11 additional changes omitted for rule RET505
- superset/migrations/versions/2018-07-05_15-19_3dda56f1c4c6_migrate_num_period_compare_and_period_.py:92:5: RET506 Unnecessary `elif` after `raise` statement
+ superset/migrations/versions/2018-07-05_15-19_3dda56f1c4c6_migrate_num_period_compare_and_period_.py:92:5: RET506 [*] Unnecessary `elif` after `raise` statement
- superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py:334:13: RET507 Unnecessary `elif` after `continue` statement
+ superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py:334:13: RET507 [*] Unnecessary `elif` after `continue` statement
... 214 additional changes omitted for project

bokeh/bokeh (+3 -142 violations, +306 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

- examples/server/app/clustering/main.py:88:5: RET505 Unnecessary `elif` after `return` statement
+ examples/server/app/clustering/main.py:88:5: RET505 [*] Unnecessary `elif` after `return` statement
- release/checks.py:105:9: RET505 Unnecessary `else` after `return` statement
+ release/checks.py:105:9: RET505 [*] Unnecessary `else` after `return` statement
- release/checks.py:119:9: RET505 Unnecessary `else` after `return` statement
+ release/checks.py:119:9: RET505 [*] Unnecessary `else` after `return` statement
... 239 additional changes omitted for rule RET505
- src/bokeh/application/application.py:169:9: RET506 Unnecessary `elif` after `raise` statement
+ src/bokeh/application/application.py:169:9: RET506 [*] Unnecessary `elif` after `raise` statement
- src/bokeh/application/handlers/directory.py:154:9: RET506 Unnecessary `elif` after `raise` statement
+ src/bokeh/application/handlers/directory.py:154:9: RET506 [*] Unnecessary `elif` after `raise` statement
... 441 additional changes omitted for project

freedomofpress/securedrop (+53 -0 violations, +0 -0 fixes)

+ admin/tests/test_integration.py:534:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ molecule/testinfra/app-code/test_securedrop_app_code.py:55:1: PT023 [*] Use `@pytest.mark.skip_in_prod` over `@pytest.mark.skip_in_prod()`
+ molecule/testinfra/app-code/test_securedrop_app_code.py:69:1: PT023 [*] Use `@pytest.mark.skip_in_prod` over `@pytest.mark.skip_in_prod()`
+ molecule/testinfra/app/test_app_network.py:12:1: PT023 [*] Use `@pytest.mark.skip_in_prod` over `@pytest.mark.skip_in_prod()`
+ molecule/testinfra/app/test_appenv.py:18:1: PT023 [*] Use `@pytest.mark.skip_in_prod` over `@pytest.mark.skip_in_prod()`
+ molecule/testinfra/app/test_appenv.py:90:1: PT023 [*] Use `@pytest.mark.skip_in_prod` over `@pytest.mark.skip_in_prod()`
+ molecule/testinfra/app/test_ossec_agent.py:42:1: PT023 [*] Use `@pytest.mark.xfail` over `@pytest.mark.xfail()`
... 23 additional changes omitted for rule PT023
+ securedrop/tests/conftest.py:102:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ securedrop/tests/conftest.py:122:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ securedrop/tests/conftest.py:151:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
... 43 additional changes omitted for project

pypa/cibuildwheel (+6 -0 violations, +0 -0 fixes)

+ test/conftest.py:40:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ test/conftest.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ unit_test/conftest.py:22:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ unit_test/main_tests/conftest.py:63:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ unit_test/main_tests/conftest.py:84:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ unit_test/option_prepare_test.py:32:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`

rotki/rotki (+0 -370 violations, +0 -0 fixes)

- rotkehlchen/tests/api/blockchain/test_substrate.py:102:1: PT023 [*] Use `@pytest.mark.vcr()` over `@pytest.mark.vcr`
- rotkehlchen/tests/api/blockchain/test_substrate.py:51:1: PT023 [*] Use `@pytest.mark.vcr()` over `@pytest.mark.vcr`
- rotkehlchen/tests/api/test_caching.py:116:1: PT023 [*] Use `@pytest.mark.vcr()` over `@pytest.mark.vcr`
- rotkehlchen/tests/api/test_current_assets_price.py:311:1: PT023 [*] Use `@pytest.mark.vcr()` over `@pytest.mark.vcr`
- rotkehlchen/tests/api/test_current_assets_price.py:345:1: PT023 [*] Use `@pytest.mark.vcr()` over `@pytest.mark.vcr`
- rotkehlchen/tests/api/test_history_events_export.py:83:1: PT023 [*] Use `@pytest.mark.vcr()` over `@pytest.mark.vcr`
... 337 additional changes omitted for rule PT023
- rotkehlchen/tests/conftest.py:107:5: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
- rotkehlchen/tests/fixtures/accounting.py:73:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
- rotkehlchen/tests/fixtures/accounting.py:85:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
- rotkehlchen/tests/fixtures/db.py:125:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture`
... 360 additional changes omitted for project

scikit-build/scikit-build (+20 -0 violations, +0 -0 fixes)

+ tests/conftest.py:150:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ tests/conftest.py:157:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()`
+ tests/test_distribution.py:12:1: PT023 [*] Use `@pytest.mark.isolated` over `@pytest.mark.isolated()`
+ tests/test_distribution.py:29:1: PT023 [*] Use `@pytest.mark.isolated` over `@pytest.mark.isolated()`
+ tests/test_hello_cpp.py:174:1: PT023 [*] Use `@pytest.mark.deprecated` over `@pytest.mark.deprecated()`
+ tests/test_hello_fortran.py:22:1: PT023 [*] Use `@pytest.mark.fortran` over `@pytest.mark.fortran()`
+ tests/test_hello_fortran.py:30:1: PT023 [*] Use `@pytest.mark.fortran` over `@pytest.mark.fortran()`
+ tests/test_hello_fortran.py:61:1: PT023 [*] Use `@pytest.mark.fortran` over `@pytest.mark.fortran()`
... 13 additional changes omitted for rule PT023
... 12 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (8 rules affected)

code total + violation - violation + fix - fix
RET505 1582 0 0 1582 0
PT023 661 196 465 0 0
RET506 372 0 0 372 0
PT004 355 0 355 0 0
PT001 295 159 136 0 0
RET507 36 0 0 36 0
RET508 16 0 0 16 0
PT005 1 0 1 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+38 -356 violations, +0 -0 fixes in 5 projects; 49 projects unchanged)

apache/airflow (+0 -316 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- helm_tests/airflow_aux/test_pod_template_file.py:48:9: PT004 Fixture `setup_test_cases` does not return anything, add leading underscore
- kubernetes_tests/conftest.py:27:5: PT004 Fixture `initialize_providers_manager` does not return anything, add leading underscore
- kubernetes_tests/test_base.py:58:9: PT004 Fixture `base_tests_setup` does not return anything, add leading underscore
- kubernetes_tests/test_kubernetes_pod_operator.py:89:5: PT004 Fixture `mock_get_connection` does not return anything, add leading underscore
- kubernetes_tests/test_kubernetes_pod_operator.py:98:9: PT004 Fixture `setup_tests` does not return anything, add leading underscore
- tests/always/test_pandas.py:31:9: PT004 Fixture `setup_test_cases` does not return anything, add leading underscore
- tests/always/test_pandas.py:48:9: PT004 Fixture `setup_test_cases` does not return anything, add leading underscore
- tests/always/test_providers_manager.py:57:9: PT004 Fixture `inject_fixtures` does not return anything, add leading underscore
- tests/api_connexion/conftest.py:64:5: PT004 Fixture `set_auto_role_public` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_config_endpoint.py:238:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_config_endpoint.py:70:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_connection_endpoint.py:61:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dag_endpoint.py:122:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dag_parsing.py:67:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dag_run_endpoint.py:132:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dag_source_endpoint.py:74:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dag_stats_endpoint.py:62:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dag_warning_endpoint.py:67:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dataset_endpoint.py:655:9: PT004 Fixture `time_freezer` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dataset_endpoint.py:835:9: PT004 Fixture `time_freezer` does not return anything, add leading underscore
- tests/api_connexion/endpoints/test_dataset_endpoint.py:84:9: PT004 Fixture `setup_attrs` does not return anything, add leading underscore
... 295 additional changes omitted for rule PT004
- tests/providers/ssh/operators/test_ssh.py:68:9: PT005 Fixture `_patch_exec_ssh_client` returns a value, remove leading underscore
... 294 additional changes omitted for project

apache/superset (+0 -40 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- tests/integration_tests/celery_tests.py:71:5: PT004 Fixture `setup_sqllab` does not return anything, add leading underscore
- tests/integration_tests/charts/api_tests.py:1274:9: PT004 Fixture `load_energy_charts` does not return anything, add leading underscore
- tests/integration_tests/charts/api_tests.py:89:9: PT004 Fixture `clear_data_cache` does not return anything, add leading underscore
- tests/integration_tests/charts/data/api_tests.py:93:5: PT004 Fixture `skip_by_backend` does not return anything, add leading underscore
- tests/integration_tests/conftest.py:120:5: PT004 Fixture `setup_sample_data` does not return anything, add leading underscore
- tests/integration_tests/core_tests.py:79:5: PT004 Fixture `cleanup` does not return anything, add leading underscore
- tests/integration_tests/dashboards/filter_state/api_tests.py:57:5: PT004 Fixture `cache` does not return anything, add leading underscore
- tests/integration_tests/explore/api_tests.py:66:5: PT004 Fixture `cache` does not return anything, add leading underscore
- tests/integration_tests/explore/form_data/api_tests.py:68:5: PT004 Fixture `cache` does not return anything, add leading underscore
- tests/integration_tests/fixtures/birth_names_dashboard.py:37:5: PT004 Fixture `load_birth_names_data` does not return anything, add leading underscore
... 30 additional changes omitted for project

freedomofpress/securedrop (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ molecule/testinfra/ossec/test_journalist_mail.py:14:45: RUF100 [*] Unused `noqa` directive (non-enabled: `PT004`)

pandas-dev/pandas (+34 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ doc/source/user_guide/style.ipynb:cell 113:31:89: E501 Line too long (90 > 88)
+ doc/source/user_guide/style.ipynb:cell 113:33:89: E501 Line too long (98 > 88)
+ doc/source/user_guide/style.ipynb:cell 123:5:56: E741 Ambiguous variable name: `l`
+ doc/source/user_guide/style.ipynb:cell 125:2:13: C408 Unnecessary `dict` call (rewrite as a literal)
+ doc/source/user_guide/style.ipynb:cell 125:4:13: C408 Unnecessary `dict` call (rewrite as a literal)
+ doc/source/user_guide/style.ipynb:cell 125:6:13: C408 Unnecessary `dict` call (rewrite as a literal)
+ doc/source/user_guide/style.ipynb:cell 125:8:13: C408 Unnecessary `dict` call (rewrite as a literal)
+ doc/source/user_guide/style.ipynb:cell 126:1:1: NPY002 Replace legacy `np.random.seed` call with `np.random.Generator`
+ doc/source/user_guide/style.ipynb:cell 126:2:1: PLW0127 Self-assignment of variable `cmap`
+ doc/source/user_guide/style.ipynb:cell 126:2:8: PLW0128 Redeclared variable `cmap` in assignment
... 24 additional changes omitted for project

rotki/rotki (+3 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ rotkehlchen/tests/fixtures/globaldb.py:200:52: RUF100 [*] Unused `noqa` directive (non-enabled: `PT004`)
+ rotkehlchen/tests/fixtures/oracles.py:20:118: RUF100 [*] Unused `noqa` directive (non-enabled: `PT004`)
+ rotkehlchen/tests/fixtures/thegraph.py:12:67: RUF100 [*] Unused `noqa` directive (non-enabled: `PT004`)

Changes by rule (10 rules affected)

code total + violation - violation + fix - fix
PT004 355 0 355 0 0
E501 18 18 0 0 0
NPY002 8 8 0 0 0
RUF100 4 4 0 0 0
C408 4 4 0 0 0
E741 1 1 0 0 0
PLW0127 1 1 0 0 0
PLW0128 1 1 0 0 0
F811 1 1 0 0 0
PT005 1 0 1 0 0

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The big reduction in ecosystem hits is evidence that this is the way to go!

@@ -930,9 +925,7 @@ pub(crate) fn fixture(
check_fixture_decorator(checker, name, decorator);
}

if checker.enabled(Rule::PytestDeprecatedYieldFixture)
&& checker.settings.flake8_pytest_style.fixture_parentheses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's odd. I tried digging through blame but the best I can conclude without spending too much time on it is that it's been this way for a long time xD

@MichaReiser MichaReiser merged commit 502df89 into ruff-0.6 Aug 13, 2024
20 checks passed
@MichaReiser MichaReiser deleted the change-default-for-pt001-pt023 branch August 13, 2024 15:54
@MichaReiser MichaReiser mentioned this pull request Aug 13, 2024
AlexWaygood added a commit that referenced this pull request Aug 14, 2024
MichaReiser added a commit that referenced this pull request Aug 14, 2024
MichaReiser added a commit that referenced this pull request Aug 14, 2024
@FinchPowers
Copy link
Contributor

FinchPowers commented Aug 21, 2024

The documentation string was updated, but not the examples.

Capture d’écran, le 2024-08-20 à 20 42 16

Fix in: #13019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking API change configuration Related to settings and configuration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants