File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 19
19
from typing import TYPE_CHECKING , Any , NamedTuple
20
20
21
21
import astroid
22
+ import astroid .exceptions
22
23
from astroid import bases , extract_node , nodes , util
23
24
from astroid .nodes import _base_nodes
24
25
from astroid .typing import InferenceResult
@@ -2521,7 +2522,7 @@ class D(Tp):
2521
2522
and name in frame_locals
2522
2523
)
2523
2524
2524
- # pylint: disable = too-many-branches
2525
+ # pylint: disable-next= too-many-branches,too-many-statements
2525
2526
def _loopvar_name (self , node : astroid .Name ) -> None :
2526
2527
# filter variables according to node's scope
2527
2528
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:
2557
2558
else :
2558
2559
_astmts = astmts [:1 ]
2559
2560
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
2562
2567
):
2563
2568
continue
2564
2569
_astmts .append (stmt )
You can’t perform that action at this time.
0 commit comments