Skip to content

Commit 65b60bd

Browse files
committed
Revert "Another solution."
This reverts commit a6f0dd2.
1 parent be50c14 commit 65b60bd

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

pyflakes/checker.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ def __init__(self, name, source):
325325
self.name = name
326326
self.source = source
327327
self.used = False
328+
self.during_type_checking = False
328329

329330
def __str__(self):
330331
return self.name
@@ -612,17 +613,6 @@ def _add_to_names(container):
612613

613614
class Scope(dict):
614615
importStarred = False # set to True when import * is found
615-
# Special key for checking whether a binding is defined only for type checking.
616-
TYPE_CHECKING_ONLY = object()
617-
618-
def __init__(self):
619-
super(Scope, self).__init__(self)
620-
self[self.TYPE_CHECKING_ONLY] = collections.defaultdict(bool)
621-
622-
def items(self):
623-
for key, val in super(Scope, self).items():
624-
if key != self.TYPE_CHECKING_ONLY:
625-
yield key, val
626616

627617
def __repr__(self):
628618
scope_cls = self.__class__.__name__
@@ -1129,6 +1119,8 @@ def addBinding(self, node, value):
11291119
break
11301120
existing = scope.get(value.name)
11311121

1122+
value.during_type_checking = self._in_type_checking
1123+
11321124
if (existing and not isinstance(existing, Builtin) and
11331125
not self.differentForks(node, existing.source)):
11341126

@@ -1230,8 +1222,7 @@ def handleNodeLoad(self, node):
12301222
scope[n.fullName].used = (self.scope, node)
12311223
except KeyError:
12321224
pass
1233-
if (self.scope[Scope.TYPE_CHECKING_ONLY][name]
1234-
and not self._in_annotation):
1225+
if n.during_type_checking and not self._in_annotation:
12351226
# Only defined during type-checking; this does not count. Real code
12361227
# (not an annotation) using this binding will not work.
12371228
continue

0 commit comments

Comments
 (0)