Skip to content

SIM113 only reported once per scope #24206

@jporcher

Description

@jporcher

Summary

i = 0
for val in [1,2,3]:
    print(f"{i}: {val}")
    i += 1

i = 0
for val in [1,2,3]:
    print(f"{i}: {val}")
    i += 1

Only the first i += 1 is reported with SIM113. And if you fix it:

for i,val in enumerate([1,2,3]):
    print(f"{i}: {val}")

i = 0
for val in [1,2,3]:
    print(f"{i}: {val}")
    i += 1

i += 1 is still not reported as an error. Now if you change the variable name:

for i,val in enumerate([1,2,3]):
    print(f"{i}: {val}")

j = 0
for val in [1,2,3]:
    print(f"{j}: {val}")
    j += 1

Now j += 1 is reported with SIM113.

Version

No response

Metadata

Metadata

Assignees

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