mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
[ruff
] Implement mutable-fromkeys-value
(RUF024
) (#9597)
## Summary Implement rule `mutable-fromkeys-value` (`RUF023`). Autofixes ```python dict.fromkeys(foo, []) ``` to ```python {key: [] for key in foo} ``` The fix is marked as unsafe as it changes runtime behaviour. It also uses `key` as the comprehension variable, which may not always be desired. Closes #4613. ## Test Plan `cargo test`
This commit is contained in:
parent
a1f3cda190
commit
1e4b421a00
8 changed files with 295 additions and 0 deletions
|
@ -926,6 +926,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
|||
(Ruff, "020") => (RuleGroup::Preview, rules::ruff::rules::NeverUnion),
|
||||
(Ruff, "021") => (RuleGroup::Preview, rules::ruff::rules::ParenthesizeChainedOperators),
|
||||
(Ruff, "022") => (RuleGroup::Preview, rules::ruff::rules::UnsortedDunderAll),
|
||||
(Ruff, "024") => (RuleGroup::Preview, rules::ruff::rules::MutableFromkeysValue),
|
||||
(Ruff, "100") => (RuleGroup::Stable, rules::ruff::rules::UnusedNOQA),
|
||||
(Ruff, "200") => (RuleGroup::Stable, rules::ruff::rules::InvalidPyprojectToml),
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue