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

[ruff] Don't emit used-dummy-variable on function parameters (RUF052) #14818

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

AlexWaygood
Copy link
Member

Summary

Fixes #14796.
Fixes #14790.
Fixes #14799.

There isn't nearly as much community consensus around the idea that using a leading underscore for a function parameter indicates the binding is meant to be "unused"; many people use this to indicate "private" parameters. Even if we decide that we don't believe that private parameters should be recognised as a concept by Ruff, I think emitting this lint on function parameters would still need to be behind a configuration flag (or maybe even a separate rule altogether), as it's just a lot more controversial than the other changes this rule makes IMO.

I agree with @zanieb's comment in #14796 (comment) that the logical conclusion of this argument is that we should probably look into whether we should change the behaviour for ARG001. Unfortunately we'll only be able to do that in the next minor release, however, as it would be an increase in the scope of ARG001. I can open an issue for that after this PR is merged, so that we don't forget.

Test Plan

cargo test -p ruff_linter --lib

@AlexWaygood AlexWaygood added bug Something isn't working preview Related to preview mode features labels Dec 6, 2024
@AlexWaygood AlexWaygood changed the title [ruff] Dont emit RUF052 on function parameters [ruff] Dont emit used-dummy-variable on function parameters (RUF052) Dec 6, 2024
Copy link
Contributor

github-actions bot commented Dec 6, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+1 -256 violations, +0 -0 fixes in 15 projects; 40 projects unchanged)

DisnakeDev/disnake (+0 -5 violations, +0 -0 fixes)

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

- disnake/ext/commands/converter.py:1189:33: RUF052 [*] Local dummy variable `_GenericAlias` is accessed
- disnake/ext/commands/help.py:211:37: RUF052 [*] Local dummy variable `_original` is accessed
- disnake/ext/commands/help.py:217:38: RUF052 [*] Local dummy variable `_original` is accessed
- disnake/utils.py:691:35: RUF052 [*] Local dummy variable `_IS_ASCII` is accessed
- scripts/codemods/base.py:31:25: RUF052 [*] Local dummy variable `_orig` is accessed

RasaHQ/rasa (+0 -28 violations, +0 -0 fixes)

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

- rasa/core/training/interactive.py:524:19: RUF052 [*] Local dummy variable `_table` is accessed
- rasa/core/training/interactive.py:527:20: RUF052 [*] Local dummy variable `_table` is accessed
- rasa/shared/importers/multi_project.py:80:31: RUF052 [*] Local dummy variable `_dict` is accessed
- rasa/shared/nlu/training_data/training_data.py:598:13: RUF052 [*] Local dummy variable `_examples` is accessed
- rasa/shared/nlu/training_data/training_data.py:598:39: RUF052 [*] Local dummy variable `_running_count` is accessed
- rasa/shared/nlu/training_data/training_data.py:598:60: RUF052 [*] Local dummy variable `_running_train_count` is accessed
- rasa/telemetry.py:601:29: RUF052 [*] Local dummy variable `_unused_hint` is accessed
- rasa/telemetry.py:910:9: RUF052 [*] Local dummy variable `_model_directory` is accessed
- rasa/utils/tensorflow/crf.py:118:18: RUF052 [*] Local dummy variable `_state` is accessed
- rasa/utils/tensorflow/crf.py:118:38: RUF052 [*] Local dummy variable `_inputs` is accessed
... 18 additional changes omitted for project

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

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

- airflow/api_fastapi/common/parameters.py:284:5: RUF052 [*] Local dummy variable `_type` is accessed
- airflow/configuration.py:887:9: RUF052 [*] Local dummy variable `_extra_stacklevel` is accessed
- airflow/decorators/setup_teardown.py:42:19: RUF052 [*] Local dummy variable `_func` is accessed
- airflow/sentry.py:167:25: RUF052 [*] Local dummy variable `_self` is accessed
- airflow/settings.py:383:28: RUF052 [*] Local dummy variable `_engine` is accessed
- airflow/utils/hashlib_wrapper.py:27:9: RUF052 [*] Local dummy variable `__string` is accessed
- airflow/utils/retries.py:59:26: RUF052 [*] Local dummy variable `_func` is accessed
- dev/breeze/src/airflow_breeze/commands/sbom_commands.py:391:5: RUF052 [*] Local dummy variable `_dir_exists_warn_and_should_skip` is accessed
- dev/breeze/src/airflow_breeze/utils/run_utils.py:103:25: RUF052 [*] Local dummy variable `_index` is accessed
- dev/breeze/src/airflow_breeze/utils/run_utils.py:103:38: RUF052 [*] Local dummy variable `_arg` is accessed
- dev/breeze/src/airflow_breeze/utils/run_utils.py:120:38: RUF052 [*] Local dummy variable `_argument` is accessed
- dev/example_dags/update_example_dags_paths.py:93:18: RUF052 [*] Local dummy variable `_file` is accessed
- docs/exts/operators_and_hooks_ref.py:257:34: RUF052 [*] Local dummy variable `_file_path` is accessed
- docs/exts/operators_and_hooks_ref.py:257:59: RUF052 [*] Local dummy variable `_class_name` is accessed
... 63 additional changes omitted for project

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

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

- superset/common/query_object_factory.py:47:9: RUF052 [*] Local dummy variable `_datasource_dao` is accessed
- superset/views/utils.py:426:31: RUF052 [*] Local dummy variable `_self` is accessed
- tests/example_data/data_loading/pandas/pands_data_loading_conf.py:57:29: RUF052 [*] Local dummy variable `_dict` is accessed

bokeh/bokeh (+0 -2 violations, +0 -0 fixes)

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

- src/bokeh/core/has_props.py:521:28: RUF052 [*] Local dummy variable `_with_props` is accessed
- src/bokeh/embed/standalone.py:302:15: RUF052 [*] Local dummy variable `_always_new` is accessed

ibis-project/ibis (+0 -24 violations, +0 -0 fixes)

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

- ibis/backends/datafusion/__init__.py:699:31: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:732:33: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:739:33: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:746:33: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:753:40: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:760:38: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:767:37: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:774:37: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/datafusion/__init__.py:781:47: RUF052 [*] Local dummy variable `_conn` is accessed
- ibis/backends/duckdb/__init__.py:1753:51: RUF052 [*] Local dummy variable `_conn` is accessed
... 14 additional changes omitted for project

lnbits/lnbits (+0 -1 violations, +0 -0 fixes)

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

- tests/wallets/helpers.py:80:36: RUF052 [*] Local dummy variable `_test_data` is accessed

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

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

- rotkehlchen/serialization/schemas.py:151:15: RUF052 [*] Local dummy variable `_kwargs` is accessed
- rotkehlchen/serialization/schemas.py:213:15: RUF052 [*] Local dummy variable `_kwargs` is accessed

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

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

- skbuild/platform_specifics/abstract.py:215:45: RUF052 [*] Local dummy variable `_generator` is accessed

scikit-build/scikit-build-core (+0 -6 violations, +0 -0 fixes)

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

- src/scikit_build_core/settings/sources.py:138:21: RUF052 [*] Local dummy variable `__target` is accessed
- src/scikit_build_core/settings/sources.py:155:5: RUF052 [*] Local dummy variable `__target` is accessed
- src/scikit_build_core/settings/sources.py:70:17: RUF052 [*] Local dummy variable `__dict` is accessed
- src/scikit_build_core/settings/sources.py:80:21: RUF052 [*] Local dummy variable `__dict` is accessed
- src/scikit_build_core/settings/sources.py:86:17: RUF052 [*] Local dummy variable `__opt` is accessed
- tests/test_dynamic_metadata.py:58:5: RUF052 [*] Local dummy variable `_field` is accessed

zulip/zulip (+0 -2 violations, +0 -0 fixes)

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

- zerver/actions/users.py:478:32: RUF052 [*] Local dummy variable `_cascade` is accessed
- zerver/lib/validator.py:232:5: RUF052 [*] Local dummy variable `_allow_only_listed_keys` is accessed

indico/indico (+0 -37 violations, +0 -0 fixes)

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

- indico/core/emails.py:93:42: RUF052 [*] Local dummy variable `_from_task` is accessed
- indico/core/marshmallow.py:54:52: RUF052 [*] Local dummy variable `_mro` is accessed
- indico/core/permissions.py:139:42: RUF052 [*] Local dummy variable `_type` is accessed
- indico/core/permissions.py:62:26: RUF052 [*] Local dummy variable `_type` is accessed
- indico/modules/categories/operations.py:57:49: RUF052 [*] Local dummy variable `_extra_log_fields` is accessed
- indico/modules/categories/operations.py:66:51: RUF052 [*] Local dummy variable `_extra_log_fields` is accessed
- indico/modules/events/contributions/controllers/compat.py:17:25: RUF052 [*] Local dummy variable `_endpoint` is accessed
- indico/modules/events/export.py:431:34: RUF052 [*] Local dummy variable `_re` is accessed
- indico/modules/events/models/events.py:860:35: RUF052 [*] Local dummy variable `_for_sending` is accessed
- indico/modules/events/operations.py:144:52: RUF052 [*] Local dummy variable `_extra_log_fields` is accessed
... 27 additional changes omitted for project

pytest-dev/pytest (+0 -40 violations, +0 -0 fixes)

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

- src/_pytest/_code/code.py:443:9: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/cacheprovider.py:101:50: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/cacheprovider.py:109:33: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/cacheprovider.py:70:50: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/cacheprovider.py:77:44: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/cacheprovider.py:89:42: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/capture.py:907:9: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/config/argparsing.py:354:9: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/config/argparsing.py:46:9: RUF052 [*] Local dummy variable `_ispytest` is accessed
- src/_pytest/fixtures.py:1220:29: RUF052 [*] Local dummy variable `_ispytest` is accessed
... 30 additional changes omitted for project

pdm-project/pdm (+0 -4 violations, +0 -0 fixes)

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

- src/pdm/models/backends.py:78:26: RUF052 [*] Local dummy variable `__format_spec` is accessed
- src/pdm/models/backends.py:92:26: RUF052 [*] Local dummy variable `__format_spec` is accessed
- src/pdm/project/core.py:609:96: RUF052 [*] Local dummy variable `_kwds` is accessed
- src/pdm/pytest.py:214:27: RUF052 [*] Local dummy variable `__key` is accessed

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

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
RUF052 255 0 255 0 0
DOC501 2 1 1 0 0

@AlexWaygood AlexWaygood changed the title [ruff] Dont emit used-dummy-variable on function parameters (RUF052) [ruff] Don't emit used-dummy-variable on function parameters (RUF052) Dec 6, 2024
@AlexWaygood AlexWaygood merged commit 4fdd4dd into main Dec 6, 2024
21 checks passed
@AlexWaygood AlexWaygood deleted the alex/ruf052-parameters branch December 6, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preview Related to preview mode features
Projects
None yet
2 participants