mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:23 +00:00
[flake8-simplify
] Implement SIM911
(#9460)
## Summary Closes #9319, implements the [`SIM911` rule from `flake8-simplify`](https://github.com/MartinThoma/flake8-simplify/pull/183). #### Note I wasn't sure whether or not to include ```rs if checker.settings.preview.is_disabled() { return; } ``` at the beginning of the function with violation logic if the rule's already declared as part of `RuleGroup::Preview`. I've seen both variants, so I'd appreciate some feedback on that :)
This commit is contained in:
parent
f192c72596
commit
eb4ed2471b
6 changed files with 160 additions and 0 deletions
23
crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM911.py
vendored
Normal file
23
crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM911.py
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
def foo(d: dict[str, str]) -> None:
|
||||
for k, v in zip(d.keys(), d.values()): # SIM911
|
||||
...
|
||||
|
||||
for k, v in zip(d.keys(), d.values(), strict=True): # SIM911
|
||||
...
|
||||
|
||||
for k, v in zip(d.keys(), d.values(), struct=True): # OK
|
||||
...
|
||||
|
||||
|
||||
d1 = d2 = {}
|
||||
|
||||
for k, v in zip(d1.keys(), d2.values()): # OK
|
||||
...
|
||||
|
||||
for k, v in zip(d1.items(), d2.values()): # OK
|
||||
...
|
||||
|
||||
for k, v in zip(d2.keys(), d2.values()): # SIM911
|
||||
...
|
||||
|
||||
items = zip(x.keys(), x.values()) # OK
|
Loading…
Add table
Add a link
Reference in a new issue