File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -72,9 +72,11 @@ def getAlternatives(n):
72
72
if PY35_PLUS :
73
73
FOR_TYPES = (ast .For , ast .AsyncFor )
74
74
LOOP_TYPES = (ast .While , ast .For , ast .AsyncFor )
75
+ FUNCTION_TYPES = (ast .FunctionDef , ast .AsyncFunctionDef )
75
76
else :
76
77
FOR_TYPES = (ast .For ,)
77
78
LOOP_TYPES = (ast .While , ast .For )
79
+ FUNCTION_TYPES = (ast .FunctionDef ,)
78
80
79
81
# https://github.com/python/typed_ast/blob/1.4.0/ast27/Parser/tokenizer.c#L102-L104
80
82
TYPE_COMMENT_RE = re .compile (r'^#\s*type:\s*' )
@@ -642,7 +644,7 @@ def is_typing_overload_decorator(node):
642
644
)
643
645
644
646
return (
645
- isinstance (value .source , ast . FunctionDef ) and
647
+ isinstance (value .source , FUNCTION_TYPES ) and
646
648
any (
647
649
is_typing_overload_decorator (dec )
648
650
for dec in value .source .decorator_list
Original file line number Diff line number Diff line change @@ -56,6 +56,24 @@ def f(s):
56
56
return s
57
57
""" )
58
58
59
+ @skipIf (version_info < (3 , 5 ), 'new in Python 3.5' )
60
+ def test_typingOverloadAsync (self ):
61
+ """Allow intentional redefinitions via @typing.overload (async)"""
62
+ self .flakes ("""
63
+ from typing import overload
64
+
65
+ @overload
66
+ async def f(s): # type: (None) -> None
67
+ pass
68
+
69
+ @overload
70
+ async def f(s): # type: (int) -> int
71
+ pass
72
+
73
+ async def f(s):
74
+ return s
75
+ """ )
76
+
59
77
def test_overload_with_multiple_decorators (self ):
60
78
self .flakes ("""
61
79
from typing import overload
You can’t perform that action at this time.
0 commit comments