Skip to content

Commit

Permalink
Continue looking for undefined variables in type checking guards. Close
Browse files Browse the repository at this point in the history
  • Loading branch information
PCManticore committed Sep 25, 2019
1 parent b74d248 commit c9e5494
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pylint/checkers/variables.py
Expand Up @@ -1357,7 +1357,8 @@ def _is_variable_violation(
defined_in_or_else = any(
target.name == name for target in definition.targets
)
break
if defined_in_or_else:
break

if not used_in_branch and not defined_in_or_else:
maybee0601 = True
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/u/undefined_variable.py
Expand Up @@ -270,9 +270,12 @@ def func_should_fail(_dt: datetime): # [used-before-assignment]

if TYPE_CHECKING:
from collections import Counter
from collections import OrderedDict
else:
Counter = object
OrderedDict = object


def tick(counter: Counter, name: str) -> None:
def tick(counter: Counter, name: str, dictionary: OrderedDict) -> None:
counter[name] += 1
return dictionary

0 comments on commit c9e5494

Please sign in to comment.