File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1919from typing import TYPE_CHECKING , Any , NamedTuple
2020
2121import astroid
22+ import astroid .exceptions
2223from astroid import bases , extract_node , nodes , util
2324from astroid .nodes import _base_nodes
2425from astroid .typing import InferenceResult
@@ -2521,7 +2522,7 @@ class D(Tp):
25212522 and name in frame_locals
25222523 )
25232524
2524- # pylint: disable = too-many-branches
2525+ # pylint: disable-next= too-many-branches,too-many-statements
25252526 def _loopvar_name (self , node : astroid .Name ) -> None :
25262527 # filter variables according to node's scope
25272528 astmts = [s for s in node .lookup (node .name )[1 ] if hasattr (s , "assign_type" )]
@@ -2557,8 +2558,12 @@ def _loopvar_name(self, node: astroid.Name) -> None:
25572558 else :
25582559 _astmts = astmts [:1 ]
25592560 for i , stmt in enumerate (astmts [1 :]):
2560- if astmts [i ].statement ().parent_of (stmt ) and not utils .in_for_else_branch (
2561- astmts [i ].statement (), stmt
2561+ try :
2562+ astmt_statement = astmts [i ].statement ()
2563+ except astroid .exceptions .ParentMissingError :
2564+ continue
2565+ if astmt_statement .parent_of (stmt ) and not utils .in_for_else_branch (
2566+ astmt_statement , stmt
25622567 ):
25632568 continue
25642569 _astmts .append (stmt )
You can’t perform that action at this time.
0 commit comments