summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2024-05-07 12:01:06 (GMT)
committerGitHub <noreply@github.com>2024-05-07 12:01:06 (GMT)
commitb60d4c0d53b6aafbf4a6e560b4cb6f1d5c7240c8 (patch)
tree54765a43707335c5c8d3656098e3a4acbfe0bb3f /Lib/test
parent04859228aa11756558807bcf99ccff78e4e8c56d (diff)
downloadcpython-b60d4c0d53b6aafbf4a6e560b4cb6f1d5c7240c8.zip
cpython-b60d4c0d53b6aafbf4a6e560b4cb6f1d5c7240c8.tar.gz
cpython-b60d4c0d53b6aafbf4a6e560b4cb6f1d5c7240c8.tar.bz2
gh-118090: Improve error message for empty type param brackets (GH-118091)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_syntax.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index de783f7..b978838 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -1213,6 +1213,22 @@ Missing parens after function definition
Traceback (most recent call last):
SyntaxError: expected '('
+ >>> def f -> int:
+ Traceback (most recent call last):
+ SyntaxError: expected '('
+
+ >>> async def f -> int: # type: int
+ Traceback (most recent call last):
+ SyntaxError: expected '('
+
+ >>> async def f[T]:
+ Traceback (most recent call last):
+ SyntaxError: expected '('
+
+ >>> def f[T] -> str:
+ Traceback (most recent call last):
+ SyntaxError: expected '('
+
Parenthesized arguments in function definitions
>>> def f(x, (y, z), w):
@@ -2027,6 +2043,31 @@ Invalid bytes literals:
Invalid expressions in type scopes:
+ >>> type A[] = int
+ Traceback (most recent call last):
+ ...
+ SyntaxError: Type parameter list cannot be empty
+
+ >>> class A[]: ...
+ Traceback (most recent call last):
+ ...
+ SyntaxError: Type parameter list cannot be empty
+
+ >>> def some[](): ...
+ Traceback (most recent call last):
+ ...
+ SyntaxError: Type parameter list cannot be empty
+
+ >>> def some[]()
+ Traceback (most recent call last):
+ ...
+ SyntaxError: Type parameter list cannot be empty
+
+ >>> async def some[]: # type: int
+ Traceback (most recent call last):
+ ...
+ SyntaxError: Type parameter list cannot be empty
+
>>> type A[T: (x:=3)] = int
Traceback (most recent call last):
...