-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[pylint
] Improve repeated-equality-comparison
fix to use a set
when all elements are hashable (PLR1714
)
#16685
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
Conversation
CodSpeed Performance ReportMerging #16685 will degrade performances by 4.61%Comparing Summary
Benchmarks breakdown
|
31df500
to
c9457ea
Compare
@@ -28,7 +28,7 @@ use crate::Locator; | |||
/// If the items are hashable, use a `set` for efficiency; otherwise, use a | |||
/// `tuple`. | |||
/// | |||
/// In [preview], this rule will try to determine if the values are hashable | |||
/// This rule will try to determine if the values are hashable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the part below this "and continue to suggest the use of a set
" was also part of the preview behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, yeah. I should have removed the continue
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PLR1714 | 62 | 31 | 31 | 0 | 0 |
Linter (preview)
✅ ecosystem check detected no linter changes.
…when all elements are hashable (`PLR1714`)
8043a60
to
a2521a4
Compare
a2521a4
to
b13b4d6
Compare
…when all elements are hashable (`PLR1714`) (#16685) ## Summary This PR promotes the fix improvements for `PLR1714` that were introduced in #14372 to stable. The improvement is that the fix now proposes to use a set if all elements are hashable: ``` foo == "bar" or foo == "baz" or foo == "qux" ``` Gets fixed to ```py foo in {"bar", "baz", "qux"} ``` where it previously always got fixed to a tuple. The new fix was first released in ruff 0.8.0 (Nov last year). This is not a breaking change. The change was preview gated only to get some extra test coverage. There are no open issues or PRs related to this changed fix behavior.
…when all elements are hashable (`PLR1714`) (#16685) ## Summary This PR promotes the fix improvements for `PLR1714` that were introduced in #14372 to stable. The improvement is that the fix now proposes to use a set if all elements are hashable: ``` foo == "bar" or foo == "baz" or foo == "qux" ``` Gets fixed to ```py foo in {"bar", "baz", "qux"} ``` where it previously always got fixed to a tuple. The new fix was first released in ruff 0.8.0 (Nov last year). This is not a breaking change. The change was preview gated only to get some extra test coverage. There are no open issues or PRs related to this changed fix behavior.
* main: (53 commits) [syntax-errors] Tuple unpacking in `for` statement iterator clause before Python 3.9 (#16558) Ruff v0.10 Release (#16708) Add new `noqa` specification to the docs (#16703) describe requires-python fallback in docs (#16704) [red-knot] handle cycles in MRO/bases resolution (#16693) [red-knot] Auto generate statement nodes (#16645) [`pylint`] Better inference for `str.strip` (`PLE310`) (#16671) [`pylint`] Improve `repeated-equality-comparison` fix to use a `set` when all elements are hashable (`PLR1714`) (#16685) [`pylint`/`pep8-naming`] Check `__new__` argument name in `bad-staticmethod-argument` and not `invalid-first-argument-name-for-class-method` (`PLW0211`/`N804`) (#16676) [`flake8-pyi`] Stabilize fix for `unused-private-type-var` (`PYI018`) (#16682) [`flake8-bandit`] Deprecate `suspicious-xmle-tree-usage` (`S320`) (#16680) [`flake8-simplify`] Avoid double negation in fixes (`SIM103`) (#16684) [`pyupgrade`]: Improve diagnostic range for `redundant-open-mode` (`UP015`) (#16672) Consider all `TYPE_CHECKING` symbols for type-checking blocks (#16669) [`pep8-naming`]: Ignore methods decorated with `@typing.override` (`invalid-argument-name`) (#16667) Stabilize FURB169 preview behavior (#16666) [`pylint`] Detect invalid default value type for `os.environ.get` (`PLW1508`) (#16674) [`flake8-pytest-style`] Allow for loops with empty bodies (`PT012`, `PT031`) (#16678) [`pyupgrade`]: Deprecate `non-pep604-isinstance` (`UP038`) (#16681) [`flake8-type-checking`] Stabilize `runtime-cast-value` (`TC006`) (#16637) ...
Summary
This PR promotes the fix improvements for
PLR1714
that were introduced in #14372 to stable.The improvement is that the fix now proposes to use a set if all elements are hashable:
Gets fixed to
where it previously always got fixed to a tuple.
The new fix was first released in ruff 0.8.0 (Nov last year). This is not a breaking change. The change was preview gated only to get some extra test coverage.
There are no open issues or PRs related to this changed fix behavior.