[ruff] Implement unnecessary-nested-literal (RUF041)#14323
[ruff] Implement unnecessary-nested-literal (RUF041)#14323MichaReiser merged 5 commits intoastral-sh:mainfrom
ruff] Implement unnecessary-nested-literal (RUF041)#14323Conversation
ae4a677 to
ebbd9f1
Compare
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| RUF041 | 2 | 2 | 0 | 0 | 0 |
| E501 | 1 | 1 | 0 | 0 | 0 |
MichaReiser
left a comment
There was a problem hiding this comment.
@AlexWaygood would you mind doing a quick glance at the rule definition? I already reviewed the code
crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs
Outdated
Show resolved
Hide resolved
AlexWaygood
left a comment
There was a problem hiding this comment.
Similar to #14319 (review), I feel like I'm not sure how much this antipattern really comes up in practice. But, I can see the value if this is a pattern that could be introduced by the fix for other rules we implement!
crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs
Outdated
Show resolved
Hide resolved
|
Is there any open feedback that needs addressing? I'm otherwise happy to merge this rule. |
|
My feedback has been addressed, but it looks like there's quite a few merge conflicts here. The conversations in #14323 (comment) and #14323 (comment) are also not marked as "resolved", and I think you're better placed to judge whether they should be or not ;) |
f5c223e to
b6b3837
Compare
ruff] Implement unnecessary-nested-literal (RUF039)ruff] Implement unnecessary-nested-literal (RUF041)
…eral.rs Co-authored-by: Micha Reiser <micha@reiser.io>
…eral.rs Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
b6b3837 to
b30d865
Compare
Summary
Implementing
unnecessary-nested-literal.This rule could help simplify other rules' fixes by handling the flattening of
Literals here.See also https://github.com/astral-sh/ruff/pull/14270/files#r1837810594 (unions in a follow-up PR)
Test Plan
cargo testThe ecosystem results are correct.
Some of the nesting emits multiple violations.
I've got a fix for this, but that depends on #14280.
We can go on with merging this PR after review regardless (the violations are not wrong).