diff options
author | Michael J. Sullivan <sully@msully.net> | 2019-09-28 14:03:58 -0400 |
---|---|---|
committer | Steven Myint <git@stevenmyint.com> | 2019-09-28 11:03:58 -0700 |
commit | 5ed30a6b9e4b9c1bb4042e5c5b3b506e52133da4 (patch) | |
tree | 07b943978b04f4d856d5605711eaaa77f3d4f906 | |
parent | 1bc5292d03f861e7a8d8c0f32cbb1f1bbfeea9ca (diff) | |
download | pyflakes-5ed30a6b9e4b9c1bb4042e5c5b3b506e52133da4.tar.gz |
Support typing_extensions.overload in addition to typing.overload (#466)
They are synonyms and typing_extensions.overloads works on 3.5.1.
-rw-r--r-- | pyflakes/checker.py | 4 | ||||
-rw-r--r-- | pyflakes/test/test_type_annotations.py | 17 |
2 files changed, 20 insertions, 1 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py index 8196fa4..44c6b25 100644 --- a/pyflakes/checker.py +++ b/pyflakes/checker.py @@ -622,7 +622,9 @@ def is_typing_overload(value, scope_stack): if name in scope: return ( isinstance(scope[name], ImportationFrom) and - scope[name].fullName == 'typing.overload' + scope[name].fullName in ( + 'typing.overload', 'typing_extensions.overload', + ) ) return False diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py index bebdef7..676a4a5 100644 --- a/pyflakes/test/test_type_annotations.py +++ b/pyflakes/test/test_type_annotations.py @@ -39,6 +39,23 @@ class TestTypeAnnotations(TestCase): return s """) + def test_typingExtensionsOverload(self): + """Allow intentional redefinitions via @typing_extensions.overload""" + self.flakes(""" + from typing_extensions import overload + + @overload + def f(s): # type: (None) -> None + pass + + @overload + def f(s): # type: (int) -> int + pass + + def f(s): + return s + """) + def test_overload_with_multiple_decorators(self): self.flakes(""" from typing import overload |