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

Allow repeated-equality-comparison for mixed operations #12369

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jul 17, 2024

Summary

This PR allows us to fix both expressions in foo == "a" or foo == "b" or ("c" != bar and "d" != bar), but limits the rule to consecutive comparisons, following #7797.

I think this logic was probably added because of #12368 -- the intent being that we'd replace the entire expression.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Jul 17, 2024
@charliermarsh
Copy link
Member Author

Actually, I may change this to only merge adjacent values, like #7797.

Base automatically changed from charlie/PLR1714 to main July 17, 2024 15:49
Copy link
Contributor

github-actions bot commented Jul 17, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+12 -0 violations, +0 -0 fixes in 7 projects; 47 projects unchanged)

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

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

+ airflow/providers/cncf/kubernetes/triggers/pod.py:313:13: PLR1714 Consider merging multiple comparisons. Use a `set` if the elements are hashable.
+ airflow/providers/teradata/operators/teradata_compute_cluster.py:122:13: PLR1714 Consider merging multiple comparisons: `self.compute_profile_name in ("None", "")`. Use a `set` if the elements are hashable.

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

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

+ superset/utils/core.py:311:13: PLR1714 Consider merging multiple comparisons: `standalone_param not in ("false", "0")`. Use a `set` if the elements are hashable.

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

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-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.
+ tests/unit/bokeh/test_layouts.py:292:12: PLR1714 Consider merging multiple comparisons: `t5 not in (save0, save1)`. Use a `set` if the elements are hashable.

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

+ pandas/core/dtypes/astype.py:128:8: PLR1714 Consider merging multiple comparisons: `object in (arr.dtype, dtype)`. Use a `set` if the elements are hashable.
+ pandas/core/nanops.py:460:13: PLR1714 Consider merging multiple comparisons: `values.dtype not in (object, bool)`. Use a `set` if the elements are hashable.

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

+ rotkehlchen/__main__.py:22:12: PLR1714 Consider merging multiple comparisons: `e.code in (0, 2)`. Use a `set` if the elements are hashable.
+ rotkehlchen/chain/evm/decoding/curve/decoder.py:542:18: PLR1714 Consider merging multiple comparisons: `event.asset in (self.native_currency, sold_asset)`. Use a `set` if the elements are hashable.
+ rotkehlchen/chain/evm/decoding/curve/decoder.py:554:18: PLR1714 Consider merging multiple comparisons. Use a `set` if the elements are hashable.

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

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

+ zerver/webhooks/opbeat/view.py:82:16: PLR1714 Consider merging multiple comparisons: `key_raw not in ("html_url", "subject")`. Use a `set` if the elements are hashable.

wntrblm/nox (+1 -0 violations, +0 -0 fixes)

+ nox/manifest.py:322:16: PLR1714 Consider merging multiple comparisons: `session in (s, s.name)`. Use a `set` if the elements are hashable.

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLR1714 12 12 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+12 -0 violations, +0 -0 fixes in 7 projects; 47 projects unchanged)

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

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

+ airflow/providers/cncf/kubernetes/triggers/pod.py:313:13: PLR1714 Consider merging multiple comparisons. Use a `set` if the elements are hashable.
+ airflow/providers/teradata/operators/teradata_compute_cluster.py:122:13: PLR1714 Consider merging multiple comparisons: `self.compute_profile_name in ("None", "")`. Use a `set` if the elements are hashable.

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

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

+ superset/utils/core.py:311:13: PLR1714 Consider merging multiple comparisons: `standalone_param not in ("false", "0")`. Use a `set` if the elements are hashable.

bokeh/bokeh (+2 -0 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.
+ tests/unit/bokeh/test_layouts.py:292:12: PLR1714 Consider merging multiple comparisons: `t5 not in (save0, save1)`. Use a `set` if the elements are hashable.

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

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

+ pandas/core/dtypes/astype.py:128:8: PLR1714 Consider merging multiple comparisons: `object in (arr.dtype, dtype)`. Use a `set` if the elements are hashable.
+ pandas/core/nanops.py:460:13: PLR1714 Consider merging multiple comparisons: `values.dtype not in (object, bool)`. Use a `set` if the elements are hashable.

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

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

+ rotkehlchen/__main__.py:22:12: PLR1714 Consider merging multiple comparisons: `e.code in (0, 2)`. Use a `set` if the elements are hashable.
+ rotkehlchen/chain/evm/decoding/curve/decoder.py:542:18: PLR1714 Consider merging multiple comparisons: `event.asset in (self.native_currency, sold_asset)`. Use a `set` if the elements are hashable.
+ rotkehlchen/chain/evm/decoding/curve/decoder.py:554:18: PLR1714 Consider merging multiple comparisons. Use a `set` if the elements are hashable.

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

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

+ zerver/webhooks/opbeat/view.py:82:16: PLR1714 Consider merging multiple comparisons: `key_raw not in ("html_url", "subject")`. Use a `set` if the elements are hashable.

wntrblm/nox (+1 -0 violations, +0 -0 fixes)

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

+ nox/manifest.py:322:16: PLR1714 Consider merging multiple comparisons: `session in (s, s.name)`. Use a `set` if the elements are hashable.

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLR1714 12 12 0 0 0

@charliermarsh charliermarsh merged commit 764d9ab into main Jul 18, 2024
20 checks passed
@charliermarsh charliermarsh deleted the charlie/mixed branch July 18, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants