summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorShantanu <hauntsaninja@users.noreply.github.com>2020-05-03 22:08:14 -0700
committerGitHub <noreply@github.com>2020-05-03 22:08:14 -0700
commit603d3546264149f323edb7952b60075fb6bc4dc2 (patch)
treea0ef9ad7c3453ac9cb48f3ed3cfa2268d565d438 /Lib
parentc95e691c904bb5ebd91825efa81b93cb9e354a85 (diff)
downloadcpython-git-603d3546264149f323edb7952b60075fb6bc4dc2.tar.gz
bpo-40493: fix function type comment parsing (GH-19894)
The grammar for func_type_input rejected things like `(*t1) ->t2`. This fixes that. Automerge-Triggered-By: @gvanrossum
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_type_comments.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_type_comments.py b/Lib/test/test_type_comments.py
index 6027b3b56f..71d1430dbc 100644
--- a/Lib/test/test_type_comments.py
+++ b/Lib/test/test_type_comments.py
@@ -399,6 +399,14 @@ class TypeCommentTests(unittest.TestCase):
self.assertEqual(tree.argtypes[2].id, "Any")
self.assertEqual(tree.returns.id, "float")
+ tree = parse_func_type_input("(*int) -> None")
+ self.assertEqual(tree.argtypes[0].id, "int")
+ tree = parse_func_type_input("(**int) -> None")
+ self.assertEqual(tree.argtypes[0].id, "int")
+ tree = parse_func_type_input("(*int, **str) -> None")
+ self.assertEqual(tree.argtypes[0].id, "int")
+ self.assertEqual(tree.argtypes[1].id, "str")
+
with self.assertRaises(SyntaxError):
tree = parse_func_type_input("(int, *str, *Any) -> float")