diff options
author | Anthony Sottile <asottile@umich.edu> | 2019-01-17 09:07:11 -0800 |
---|---|---|
committer | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2019-01-17 13:38:15 -0600 |
commit | 1f58890b3ea7a8683bc21594a7dc773443102893 (patch) | |
tree | a085e47ed1c024b1c55588a0a050ee3b5feeb4b4 | |
parent | 1f4e3772155ac5102e24b65ef3970d3f1454f4d4 (diff) | |
download | pyflakes-1f58890b3ea7a8683bc21594a7dc773443102893.tar.gz |
Set the proper scope for `async def`
-rw-r--r-- | pyflakes/checker.py | 2 | ||||
-rw-r--r-- | pyflakes/test/test_type_annotations.py | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py index 4c18042..e94bc71 100644 --- a/pyflakes/checker.py +++ b/pyflakes/checker.py @@ -619,6 +619,8 @@ class Checker(object): ast.GeneratorExp: GeneratorScope, ast.DictComp: GeneratorScope, } + if PY35_PLUS: + _ast_node_scope[ast.AsyncFunctionDef] = FunctionScope, nodeDepth = 0 offset = None diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py index e828412..1ed676b 100644 --- a/pyflakes/test/test_type_annotations.py +++ b/pyflakes/test/test_type_annotations.py @@ -179,6 +179,13 @@ class TestTypeAnnotations(TestCase): a: 'a: "A"' ''', m.ForwardAnnotationSyntaxError) + @skipIf(version_info < (3, 5), 'new in Python 3.5') + def test_annotated_async_def(self): + self.flakes(''' + class c: pass + async def func(c: c) -> None: pass + ''') + @skipIf(version_info < (3, 7), 'new in Python 3.7') def test_postponed_annotations(self): self.flakes(''' |