8000 Allow * in TypeVarTuple default · python/cpython@c13420b · GitHub
[go: up one dir, main page]

Skip to content

Commit c13420b

Browse files
committed
Allow * in TypeVarTuple default
1 parent 900cd40 commit c13420b

File tree

3 files changed

+516
-467
lines changed

3 files changed

+516
-467
lines changed

Grammar/python.gram

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,13 @@ type_param_seq[asdl_type_param_seq*]: a[asdl_type_param_seq*]=','.type_param+ ['
645645

646646
type_param[type_param_ty] (memo):
647647
| a=NAME b=[type_param_bound] c=[type_param_default] { _PyAST_TypeVar(a->v.Name.id, b, c, EXTRA) }
648-
| '*' a=NAME [type_param_default] colon=':' e=expression {
648+
| '*' a=NAME colon=':' e=expression {
649649
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
650650
? "cannot use constraints with TypeVarTuple"
651651
: "cannot use bound with TypeVarTuple")
652652
}
653-
| '*' a=NAME b=[type_param_default] { _PyAST_TypeVarTuple(a->v.Name.id, b, EXTRA) }
654-
| '**' a=NAME [type_param_default] colon=':' e=expression {
653+
| '*' a=NAME b=[type_param_starred_default] { _PyAST_TypeVarTuple(a->v.Name.id, b, EXTRA) }
654+
| '**' a=NAME colon=':' e=expression {
655655
RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
656656
? "cannot use constraints with ParamSpec"
657657
: "cannot use bound with ParamSpec")
@@ -661,6 +661,8 @@ type_param[type_param_ty] (memo):
661661
type_param_bound[expr_ty]: ':' e=expression { e }
662662
type_param_default[expr_ty]: '=' e=expression {
663663
CHECK_VERSION(expr_ty, 13, "Type parameter defaults are", e) }
664+
type_param_starred_default[expr_ty]: '=' e=starred_expression {
665+
CHECK_VERSION(expr_ty, 13, "Type parameter defaults are", e) }
664666

665667
# EXPRESSIONS
666668
# -----------

0 commit comments

Comments
 (0)
0