gh-118090: Improve error message for empty type param brackets (GH-118091)

This commit is contained in:
Nikita Sobolev 2024-05-07 15:01:06 +03:00 committed by GitHub
parent 04859228aa
commit b60d4c0d53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1430 additions and 1214 deletions

View file

@ -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):
...