Skip to content

Commit 5ed30a6

Browse files
msullivanmyint
authored andcommitted
Support typing_extensions.overload in addition to typing.overload (#466)
They are synonyms and typing_extensions.overloads works on 3.5.1.
1 parent 1bc5292 commit 5ed30a6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

pyflakes/checker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,9 @@ def name_is_typing_overload(name): # type: (str) -> bool
622622
if name in scope:
623623
return (
624624
isinstance(scope[name], ImportationFrom) and
625-
scope[name].fullName == 'typing.overload'
625+
scope[name].fullName in (
626+
'typing.overload', 'typing_extensions.overload',
627+
)
626628
)
627629

628630
return False

pyflakes/test/test_type_annotations.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ def g(s):
3939
return s
4040
""")
4141

42+
def test_typingExtensionsOverload(self):
43+
"""Allow intentional redefinitions via @typing_extensions.overload"""
44+
self.flakes("""
45+
from typing_extensions import overload
46+
47+
@overload
48+
def f(s): # type: (None) -> None
49+
pass
50+
51+
@overload
52+
def f(s): # type: (int) -> int
53+
pass
54+
55+
def f(s):
56+
return s
57+
""")
58+
4259
def test_overload_with_multiple_decorators(self):
4360
self.flakes("""
4461
from typing import overload

0 commit comments

Comments
 (0)