Skip to content
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

new check: suggest to iterate over dict.values() instead if items() if #2206

Closed
spaceone opened this issue Jan 26, 2023 · 4 comments
Closed
Labels
rule Implementing or modifying a lint rule

Comments

@spaceone
Copy link
Contributor

B007 unused-loop-control-variable revealed and fixed code like:

-               for k, v in self.validation_errors.items():
+               for _k, v in self.validation_errors.items():
                        num += v.number_of_errors()

a new checker could make it even better:

-               for k, v in self.validation_errors.items():
+               for v in self.validation_errors.values():
                        num += v.number_of_errors()
@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Jan 26, 2023
@andersk
Copy link
Contributor

andersk commented Jan 26, 2023

Some classes such as xml.etree.elementtree.Element support items but not values.

@JonathanPlasse
Copy link
Contributor

JonathanPlasse commented Jan 27, 2023

It would be an aggressive rule.

@dhruvmanila
Copy link
Member

This is being implemented as part of perflint (#4789)

@charliermarsh
Copy link
Member

I believe we now support this via PERF102.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

5 participants