Skip to content

Commit

Permalink
Merge branch 'pylint-dev:main' into per_directory_configs
Browse files Browse the repository at this point in the history
  • Loading branch information
0nf committed Jan 28, 2024
2 parents 3bd9d4a + 77caa0f commit 6b5f217
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typing import TYPE_CHECKING, Any, NamedTuple

import astroid
import astroid.exceptions
from astroid import bases, extract_node, nodes, util
from astroid.nodes import _base_nodes
from astroid.typing import InferenceResult
Expand Down Expand Up @@ -2521,7 +2522,7 @@ class D(Tp):
and name in frame_locals
)

# pylint: disable = too-many-branches
# pylint: disable-next=too-many-branches,too-many-statements
def _loopvar_name(self, node: astroid.Name) -> None:
# filter variables according to node's scope
astmts = [s for s in node.lookup(node.name)[1] if hasattr(s, "assign_type")]
Expand Down Expand Up @@ -2557,8 +2558,12 @@ def _loopvar_name(self, node: astroid.Name) -> None:
else:
_astmts = astmts[:1]
for i, stmt in enumerate(astmts[1:]):
if astmts[i].statement().parent_of(stmt) and not utils.in_for_else_branch(
astmts[i].statement(), stmt
try:
astmt_statement = astmts[i].statement()
except astroid.exceptions.ParentMissingError:
continue
if astmt_statement.parent_of(stmt) and not utils.in_for_else_branch(
astmt_statement, stmt
):
continue
_astmts.append(stmt)
Expand Down

0 comments on commit 6b5f217

Please sign in to comment.