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

[pylint] - use sets when possible for PLR1714 autofix (repeated-equality-comparison) #14372

Merged
merged 4 commits into from
Nov 18, 2024

Conversation

diceroll123
Copy link
Contributor

@diceroll123 diceroll123 commented Nov 15, 2024

Summary

Uses a set if we can determine that it should be used.

Test Plan

cargo test

Copy link
Contributor

github-actions bot commented Nov 16, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

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

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

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

- airflow/assets/__init__.py:128:8: PLR1714 Consider merging multiple comparisons: `value in ("self", "context")`. Use a `set` if the elements are hashable.
+ airflow/assets/__init__.py:128:8: PLR1714 Consider merging multiple comparisons: `value in {"self", "context"}`.
- airflow/www/decorators.py:55:27: PLR1714 Consider merging multiple comparisons: `k in ("val", "value")`. Use a `set` if the elements are hashable.
+ airflow/www/decorators.py:55:27: PLR1714 Consider merging multiple comparisons: `k in {"val", "value"}`.
- airflow/www/views.py:4340:21: PLR1714 Consider merging multiple comparisons: `parsed_url.scheme in ("http", "https")`. Use a `set` if the elements are hashable.
+ airflow/www/views.py:4340:21: PLR1714 Consider merging multiple comparisons: `parsed_url.scheme in {"http", "https"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2956:8: PLR1714 Consider merging multiple comparisons: `package_format in ("sdist", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2956:8: PLR1714 Consider merging multiple comparisons: `package_format in {"sdist", "both"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2958:8: PLR1714 Consider merging multiple comparisons: `package_format in ("wheel", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2958:8: PLR1714 Consider merging multiple comparisons: `package_format in {"wheel", "both"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2974:8: PLR1714 Consider merging multiple comparisons: `package_format in ("sdist", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2974:8: PLR1714 Consider merging multiple comparisons: `package_format in {"sdist", "both"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2976:8: PLR1714 Consider merging multiple comparisons: `package_format in ("wheel", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:2976:8: PLR1714 Consider merging multiple comparisons: `package_format in {"wheel", "both"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:588:12: PLR1714 Consider merging multiple comparisons: `package_format in ("sdist", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:588:12: PLR1714 Consider merging multiple comparisons: `package_format in {"sdist", "both"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:590:12: PLR1714 Consider merging multiple comparisons: `package_format in ("wheel", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:590:12: PLR1714 Consider merging multiple comparisons: `package_format in {"wheel", "both"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:604:12: PLR1714 Consider merging multiple comparisons: `package_format in ("sdist", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:604:12: PLR1714 Consider merging multiple comparisons: `package_format in {"sdist", "both"}`.
- dev/breeze/src/airflow_breeze/commands/release_management_commands.py:606:12: PLR1714 Consider merging multiple comparisons: `package_format in ("wheel", "both")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/commands/release_management_commands.py:606:12: PLR1714 Consider merging multiple comparisons: `package_format in {"wheel", "both"}`.
- dev/breeze/src/airflow_breeze/utils/host_info_utils.py:39:8: PLR1714 Consider merging multiple comparisons: `os in ("linux", "darwin")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/utils/host_info_utils.py:39:8: PLR1714 Consider merging multiple comparisons: `os in {"linux", "darwin"}`.
- dev/breeze/src/airflow_breeze/utils/host_info_utils.py:49:8: PLR1714 Consider merging multiple comparisons: `os in ("linux", "darwin")`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/utils/host_info_utils.py:49:8: PLR1714 Consider merging multiple comparisons: `os in {"linux", "darwin"}`.
- dev/breeze/src/airflow_breeze/utils/packages.py:691:12: PLR1714 Consider merging multiple comparisons: `ex.returncode in (128, 2)`. Use a `set` if the elements are hashable.
+ dev/breeze/src/airflow_breeze/utils/packages.py:691:12: PLR1714 Consider merging multiple comparisons: `ex.returncode in {128, 2}`.
- helm_tests/airflow_aux/test_basic_helm_chart.py:81:12: PLR1714 Consider merging multiple comparisons: `version in ("2.3.2", "default")`. Use a `set` if the elements are hashable.
+ helm_tests/airflow_aux/test_basic_helm_chart.py:81:12: PLR1714 Consider merging multiple comparisons: `version in {"2.3.2", "default"}`.
- providers/src/airflow/providers/fab/auth_manager/security_manager/override.py:2258:12: PLR1714 Consider merging multiple comparisons: `provider in ("github", "githublocal")`. Use a `set` if the elements are hashable.
+ providers/src/airflow/providers/fab/auth_manager/security_manager/override.py:2258:12: PLR1714 Consider merging multiple comparisons: `provider in {"github", "githublocal"}`.
... 8 additional changes omitted for project

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

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

- superset/migrations/versions/2023-03-17_13-24_b5ea9d343307_bar_chart_stack_options.py:82:16: PLR1714 Consider merging multiple comparisons: `stack in ("Stack", "Stream")`. Use a `set` if the elements are hashable.
+ superset/migrations/versions/2023-03-17_13-24_b5ea9d343307_bar_chart_stack_options.py:82:16: PLR1714 Consider merging multiple comparisons: `stack in {"Stack", "Stream"}`.
- superset/migrations/versions/2024-05-10_18-02_f84fde59123a_update_charts_with_old_time_comparison.py:198:13: PLR1714 Consider merging multiple comparisons: `Slice.viz_type in ("pop_kpi", "table")`. Use a `set` if the elements are hashable.
+ superset/migrations/versions/2024-05-10_18-02_f84fde59123a_update_charts_with_old_time_comparison.py:198:13: PLR1714 Consider merging multiple comparisons: `Slice.viz_type in {"pop_kpi", "table"}`.
- superset/utils/core.py:312:13: PLR1714 Consider merging multiple comparisons: `standalone_param not in ("false", "0")`. Use a `set` if the elements are hashable.
+ superset/utils/core.py:312:13: PLR1714 Consider merging multiple comparisons: `standalone_param not in {"false", "0"}`.
- tests/integration_tests/databases/commands_tests.py:1184:12: PLR1714 Consider merging multiple comparisons: `database.backend in ("postgresql", "mysql")`. Use a `set` if the elements are hashable.
+ tests/integration_tests/databases/commands_tests.py:1184:12: PLR1714 Consider merging multiple comparisons: `database.backend in {"postgresql", "mysql"}`.

aws/aws-sam-cli (+1 -1 violations, +0 -0 fixes)

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

- tests/integration/publish/publish_app_integ_base.py:60:16: PLR1714 Consider merging multiple comparisons: `f.suffix in (".yaml", ".json")`. Use a `set` if the elements are hashable.
+ tests/integration/publish/publish_app_integ_base.py:60:16: PLR1714 Consider merging multiple comparisons: `f.suffix in {".yaml", ".json"}`.

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

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

- src/bokeh/core/has_props.py:280:24: PLR1714 Consider merging multiple comparisons: `head in ("bokeh", "__main__")`. Use a `set` if the elements are hashable.
+ src/bokeh/core/has_props.py:280:24: PLR1714 Consider merging multiple comparisons: `head in {"bokeh", "__main__"}`.
- src/bokeh/server/tornado.py:622:12: PLR1714 Consider merging multiple comparisons: `mode in ("server", "server-dev")`. Use a `set` if the elements are hashable.
+ src/bokeh/server/tornado.py:622:12: PLR1714 Consider merging multiple comparisons: `mode in {"server", "server-dev"}`.
- tests/unit/bokeh/embed/test_server__embed.py:215:16: PLR1714 Consider merging multiple comparisons: `r in ("&foo=10&bar=baz", "&bar=baz&foo=10")`. Use a `set` if the elements are hashable.
+ tests/unit/bokeh/embed/test_server__embed.py:215:16: PLR1714 Consider merging multiple comparisons: `r in {"&foo=10&bar=baz", "&bar=baz&foo=10"}`.
- tests/unit/bokeh/embed/test_server__embed.py:222:16: PLR1714 Consider merging multiple comparisons: `r in ("&foo=10&bar=baz", "&bar=baz&foo=10")`. Use a `set` if the elements are hashable.
+ tests/unit/bokeh/embed/test_server__embed.py:222:16: PLR1714 Consider merging multiple comparisons: `r in {"&foo=10&bar=baz", "&bar=baz&foo=10"}`.

latchbio/latch (+2 -2 violations, +0 -0 fixes)

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

- src/latch_cli/services/stop_pod.py:22:8: PLR1714 Consider merging multiple comparisons: `res.status_code in (403, 404)`. Use a `set` if the elements are hashable.
+ src/latch_cli/services/stop_pod.py:22:8: PLR1714 Consider merging multiple comparisons: `res.status_code in {403, 404}`.
- src/latch_cli/snakemake/single_task_snakemake.py:362:8: PLR1714 Consider merging multiple comparisons: `parsed.scheme not in ("", "docker")`. Use a `set` if the elements are hashable.
+ src/latch_cli/snakemake/single_task_snakemake.py:362:8: PLR1714 Consider merging multiple comparisons: `parsed.scheme not in {"", "docker"}`.

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLR1714 62 31 31 0 0

@MichaReiser
Copy link
Member

Could we make this a preview only change? And could you update the test plan if you already went through the ecosystem changes?

@diceroll123
Copy link
Contributor Author

Could we make this a preview only change? And could you update the test plan if you already went through the ecosystem changes?

Preview check added!

As for the ecosystem changes, seems fine with what's there, I'm all ears if not!

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule fixes Related to suggested fixes for violations preview Related to preview mode features and removed rule Implementing or modifying a lint rule labels Nov 18, 2024
@MichaReiser MichaReiser merged commit 5776535 into astral-sh:main Nov 18, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations preview Related to preview mode features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants