summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-01-20 17:10:19 -0800
committerIan Stapleton Cordasco <graffatcolmingov@gmail.com>2019-01-21 08:02:47 -0600
commit357a2e3cf3461b414ba5a70485a62c411d557c3f (patch)
treefffc9d5eeb7e32233488cec31228bfeae91f83ec
parent7272b1048ee319cc058bf83d4b78563573583ce9 (diff)
downloadpyflakes-357a2e3cf3461b414ba5a70485a62c411d557c3f.tar.gz
Allow star args in type comments
-rw-r--r--pyflakes/checker.py5
-rw-r--r--pyflakes/test/test_type_annotations.py8
2 files changed, 12 insertions, 1 deletions
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 7b68b21..480ee00 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -1037,7 +1037,10 @@ class Checker(object):
comment = comment.split(':', 1)[1].strip()
func_match = TYPE_FUNC_RE.match(comment)
if func_match:
- parts = (func_match.group(1), func_match.group(2).strip())
+ parts = (
+ func_match.group(1).replace('*', ''),
+ func_match.group(2).strip(),
+ )
else:
parts = (comment,)
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 1ed676b..40397e8 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -231,6 +231,14 @@ class TestTypeAnnotations(TestCase):
return a + b
""")
+ def test_typeCommentsStarArgs(self):
+ self.flakes("""
+ from mod import A, B, C, D
+ def f(a, *b, **c):
+ # type: (A, *B, **C) -> D
+ return a + b
+ """)
+
def test_typeCommentsFullSignatureWithDocstring(self):
self.flakes('''
from mod import A, B, C, D