mirror of
https://github.com/python/cpython.git
synced 2025-12-09 02:35:14 +00:00
gh-116126: Implement PEP 696 (#116129)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
parent
852263e108
commit
ca269e58c2
28 changed files with 1924 additions and 623 deletions
|
|
@ -647,21 +647,25 @@ type_params[asdl_type_param_seq*]: '[' t=type_param_seq ']' {
|
|||
type_param_seq[asdl_type_param_seq*]: a[asdl_type_param_seq*]=','.type_param+ [','] { a }
|
||||
|
||||
type_param[type_param_ty] (memo):
|
||||
| a=NAME b=[type_param_bound] { _PyAST_TypeVar(a->v.Name.id, b, EXTRA) }
|
||||
| a=NAME b=[type_param_bound] c=[type_param_default] { _PyAST_TypeVar(a->v.Name.id, b, c, EXTRA) }
|
||||
| '*' a=NAME colon=':' e=expression {
|
||||
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
|
||||
? "cannot use constraints with TypeVarTuple"
|
||||
: "cannot use bound with TypeVarTuple")
|
||||
}
|
||||
| '*' a=NAME { _PyAST_TypeVarTuple(a->v.Name.id, EXTRA) }
|
||||
| '*' a=NAME b=[type_param_starred_default] { _PyAST_TypeVarTuple(a->v.Name.id, b, EXTRA) }
|
||||
| '**' a=NAME colon=':' e=expression {
|
||||
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
|
||||
? "cannot use constraints with ParamSpec"
|
||||
: "cannot use bound with ParamSpec")
|
||||
}
|
||||
| '**' a=NAME { _PyAST_ParamSpec(a->v.Name.id, EXTRA) }
|
||||
| '**' a=NAME b=[type_param_default] { _PyAST_ParamSpec(a->v.Name.id, b, EXTRA) }
|
||||
|
||||
type_param_bound[expr_ty]: ':' e=expression { e }
|
||||
type_param_default[expr_ty]: '=' e=expression {
|
||||
CHECK_VERSION(expr_ty, 13, "Type parameter defaults are", e) }
|
||||
type_param_starred_default[expr_ty]: '=' e=star_expression {
|
||||
CHECK_VERSION(expr_ty, 13, "Type parameter defaults are", e) }
|
||||
|
||||
# EXPRESSIONS
|
||||
# -----------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue