mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
Generalize PIE807 to handle dict literals (#8608)
## Summary PIE807 will rewrite `lambda: []` to `list` -- AFAICT though, the same rationale also applies to dicts, so I've modified the code to also rewrite `lambda: {}` to `dict`. Two things I'm not sure about: * Should this go to a new rule? This no longer actually matches the behavior of flake8-pie, and while I think thematically it makes sense to be part of the same rule, we could make it a standalone rule (but if so, where should I put it and what error code should I use)? * If we want a single rule, are there backwards compatibility concerns with the rule name change (from `reimplemented_list_builtin` to `reimplemented_container_builtin`? ## Test Plan Added snapshot tests of the functionality.
This commit is contained in:
parent
d574fcd1ac
commit
6f23bdb78f
9 changed files with 304 additions and 111 deletions
|
@ -773,7 +773,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
|||
(Flake8Pie, "796") => (RuleGroup::Stable, rules::flake8_pie::rules::NonUniqueEnums),
|
||||
(Flake8Pie, "800") => (RuleGroup::Stable, rules::flake8_pie::rules::UnnecessarySpread),
|
||||
(Flake8Pie, "804") => (RuleGroup::Stable, rules::flake8_pie::rules::UnnecessaryDictKwargs),
|
||||
(Flake8Pie, "807") => (RuleGroup::Stable, rules::flake8_pie::rules::ReimplementedListBuiltin),
|
||||
(Flake8Pie, "807") => (RuleGroup::Stable, rules::flake8_pie::rules::ReimplementedContainerBuiltin),
|
||||
(Flake8Pie, "808") => (RuleGroup::Stable, rules::flake8_pie::rules::UnnecessaryRangeStart),
|
||||
(Flake8Pie, "810") => (RuleGroup::Stable, rules::flake8_pie::rules::MultipleStartsEndsWith),
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue