mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-118090: Improve error message for empty type param brackets (GH-118091)
This commit is contained in:
parent
04859228aa
commit
b60d4c0d53
4 changed files with 1430 additions and 1214 deletions
|
@ -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):
|
||||
...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue