Skip to content

F821 false positive in else when except block locals matches try block locals. #5249

@jaraco

Description

@jaraco

Sometime between 0.0.265 and 0.0.274, ruff started failing on this case:

try:
    v = 3
except ImportError as v:
    print(v)
else:
    print(v)

with

e.py:6:11: F821 Undefined name `v`

This issue was encountered in pypa/setuptools#3961.

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