summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyflakes/checker.py2
-rw-r--r--pyflakes/test/test_type_annotations.py20
2 files changed, 21 insertions, 1 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 0e636c1..83f92aa 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -1480,7 +1480,7 @@ class Checker(object):
self.pushScope()
- self.handleChildren(node, omit='decorator_list')
+ self.handleChildren(node, omit=['decorator_list', 'returns'])
def checkUnusedAssignments():
"""
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 03f70bb..9c34dcf 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -342,3 +342,23 @@ class TestTypeAnnotations(TestCase):
x = 1
# type: F
""")
+
+ @skipIf(version_info < (3,), 'new in Python 3')
+ def test_return_annotation_is_class_scope_variable(self):
+ self.flakes("""
+ from typing import TypeVar
+ class Test:
+ Y = TypeVar('Y')
+
+ def t(self, x: Y) -> Y:
+ return x
+ """)
+
+ @skipIf(version_info < (3,), 'new in Python 3')
+ def test_return_annotation_is_function_body_variable(self):
+ self.flakes("""
+ class Test:
+ def t(self) -> Y:
+ Y = 2
+ return Y
+ """, m.UndefinedName)