summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2020-10-03 07:45:00 -0700
committerGitHub <noreply@github.com>2020-10-03 07:45:00 -0700
commitdbb8fc4152c7d8dc4f7d666df4171860679f4b47 (patch)
tree91d581d19a0440c11c0057cfcb14d9256027dc0c
parent6a5f38b5ab12260fde8a0463acd433bc2d34dbcf (diff)
downloadpyflakes-dbb8fc4152c7d8dc4f7d666df4171860679f4b47.tar.gz
simplify typing.Literal check (#587)
-rw-r--r--pyflakes/checker.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index a6439d6..d6d057e 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -862,7 +862,6 @@ class Checker(object):
offset = None
traceTree = False
_in_annotation = AnnotationState.NONE
- _in_typing_literal = False
_in_deferred = False
builtIns = set(builtin_vars).union(_MAGIC_GLOBALS)
@@ -1505,11 +1504,8 @@ class Checker(object):
def SUBSCRIPT(self, node):
if _is_name_or_attr(node.value, 'Literal'):
- orig, self._in_typing_literal = self._in_typing_literal, True
- try:
+ with self._enter_annotation(AnnotationState.NONE):
self.handleChildren(node)
- finally:
- self._in_typing_literal = orig
elif _is_name_or_attr(node.value, 'Annotated'):
self.handleNode(node.value, node)
@@ -1794,7 +1790,7 @@ class Checker(object):
self.handleChildren(node)
def STR(self, node):
- if self._in_annotation and not self._in_typing_literal:
+ if self._in_annotation:
fn = functools.partial(
self.handleStringAnnotation,
node.s,