File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
tests/functional/u/undefined Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ Release date: TBA
5858
5959 Closes #3614
6060
61+ * Fix crash with ``AssignAttr`` in ``if TYPE_CHECKING`` blocks.
62+
63+ Closes #5111
64+
6165
6266What's New in Pylint 2.11.1?
6367============================
Original file line number Diff line number Diff line change @@ -1536,7 +1536,9 @@ def _is_variable_violation(
15361536 for definition in defstmt_parent .orelse :
15371537 if isinstance (definition , nodes .Assign ):
15381538 defined_in_or_else = any (
1539- target .name == name for target in definition .targets
1539+ target .name == name
1540+ for target in definition .targets
1541+ if isinstance (target , nodes .AssignName )
15401542 )
15411543 if defined_in_or_else :
15421544 break
Original file line number Diff line number Diff line change @@ -328,3 +328,13 @@ def decorated3(x):
328328@decorator (x * x * y for x in range (3 )) # [undefined-variable]
329329def decorated4 (x ):
330330 print (x )
331+
332+
333+ # https://github.com/PyCQA/pylint/issues/5111
334+ # AssignAttr in orelse block of 'TYPE_CHECKING' shouldn't crash
335+ # Name being assigned must be imported in orelse block
336+ if TYPE_CHECKING :
337+ pass
338+ else :
339+ from types import GenericAlias
340+ object ().__class_getitem__ = classmethod (GenericAlias )
You can’t perform that action at this time.
0 commit comments