PERF102 is not detected in generators or comprehensions, only in for loops:
d = {}
for k, _ in d.items():
print(k)
_ = (k for k, _ in d.items())
_ = [k for k, _ in d.items()]
_ = {k for k, _ in d.items()}
_ = {k: "v" for k, _ in d.items()}
Running:
$ ruff --version
ruff 0.0.284
$ ruff x.py
x.py:3:13: PERF102 [*] When using only the keys of a dict use the `keys()` method
Found 1 error.
[*] 1 potentially fixable with the --fix option.
Expected: A line for the d.items() call in the generator and each of the list/set/dict comprehension.
PERF102is not detected in generators or comprehensions, only inforloops:Running:
Expected: A line for the
d.items()call in the generator and each of thelist/set/dictcomprehension.