Skip to content

[flake8-simplify] SIM911 false positive when methods have args #18778

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

SIM911 has a false positive if you give the methods args, since they are removed when it is transformed into .items(), which changes the behavior of the code to no longer raise a TypeError. If there is a situation in where the code thinks the variable is a dict, but it's actually the dict class, that could actually show up in non-constructed code. I was unable to find such a situation though. playground

PS ~\Desktop\New_folder>Get-Content issue.py
d = {}
for country, stars in zip(d.keys(*x), d.values("hello")):...
PS ~\Desktop\New_folder>uvx ruff check issue.py --isolated --select SIM --fix --diff
--- issue.py
+++ issue.py
@@ -1,2 +1,2 @@
 d = {}
-for country, stars in zip(d.keys(*x), d.values("hello")):...
+for country, stars in d.items():...

Would fix 1 error.

Version

ruff 0.12.0 (87f0feb 2025-06-17) + playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions