-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[ruff
] Implement unnecessary-nested-literal
(RUF041
)
#14323
[ruff
] Implement unnecessary-nested-literal
(RUF041
)
#14323
Conversation
ae4a677
to
ebbd9f1
Compare
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF041 | 2 | 2 | 0 | 0 | 0 |
E501 | 1 | 1 | 0 | 0 | 0 |
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.
@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
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.
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 <[email protected]>
…eral.rs Co-authored-by: Alex Waygood <[email protected]>
b6b3837
to
b30d865
Compare
Summary
Implementing
unnecessary-nested-literal
.This rule could help simplify other rules' fixes by handling the flattening of
Literal
s here.See also https://github.com/astral-sh/ruff/pull/14270/files#r1837810594 (unions in a follow-up PR)
Test Plan
cargo test
The 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).