[refurb] Also report non-name expressions (FURB169)#15905
[refurb] Also report non-name expressions (FURB169)#15905MichaReiser merged 5 commits intoastral-sh:mainfrom
refurb] Also report non-name expressions (FURB169)#15905Conversation
|
crates/ruff_linter/src/rules/refurb/rules/isinstance_type_none.rs
Outdated
Show resolved
Hide resolved
We discussed this internally and, while it's quite borderline, we think this unfortunately does need to be gated behind preview. It's similar to #15579, and it's true that #15579 increased the scope a little bit, but it felt like #15579 was mainly a bugfix (expanding the scope of the rule was sort-of incidental). The line here is a bit fuzzy, and it's true that this could also be considered a bugfix of sorts. However, Ruff arguably isn't doing anything wrong here right now (it could just be doing a bit better). To us this feels like it's a significant enough expansion of the rule that it should be a preview-only change first. |
5b02243 to
ee6a90c
Compare
Preview-gated the first change. The other two are fine, I suppose? |
yup! Thanks! |
crates/ruff_linter/src/rules/refurb/rules/type_none_comparison.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Alex Waygood <[email protected]>
0861ff2 to
9ef366c
Compare
...c/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__preview__FURB169_FURB169.py.snap
Show resolved
Hide resolved
## Summary This PR stabilizes the preview behavior introduced in #15905 The behavior change is that the rule now also recognizes `type(expr) is type(None)` comparisons where `expr` isn't a name expression. For example, the rule now detects `type(a.b) is type(None)` and suggests rewriting the comparison to `a.b is None`. The new behavior was introduced with Ruff 0.9.5 (6th of February), about a month ago. There are no open issues or PRs related to this rule (or behavior change).
## Summary This PR stabilizes the preview behavior introduced in #15905 The behavior change is that the rule now also recognizes `type(expr) is type(None)` comparisons where `expr` isn't a name expression. For example, the rule now detects `type(a.b) is type(None)` and suggests rewriting the comparison to `a.b is None`. The new behavior was introduced with Ruff 0.9.5 (6th of February), about a month ago. There are no open issues or PRs related to this rule (or behavior change).
## Summary This PR stabilizes the preview behavior introduced in #15905 The behavior change is that the rule now also recognizes `type(expr) is type(None)` comparisons where `expr` isn't a name expression. For example, the rule now detects `type(a.b) is type(None)` and suggests rewriting the comparison to `a.b is None`. The new behavior was introduced with Ruff 0.9.5 (6th of February), about a month ago. There are no open issues or PRs related to this rule (or behavior change).
Summary
Follow-up to #15779.
Prior to this change, non-name expressions are not reported at all:
This change enhances the rule so that such cases are also reported in preview. Additionally:
Test Plan
cargo nextest runandcargo insta test.