Commit d8f44e6
committed
Respect the magic trailing comma in starred type parameter lists
A magic trailing comma exploded a PEP 695 type parameter list of plain
type vars, but was silently ignored once the list contained a
*TypeVarTuple or **ParamSpec, collapsing the params back onto one line.
is_split_before_delimiter/is_split_after_delimiter skip a star that
is_vararg() recognises, so it is not mistaken for a MATH_OPERATORS
delimiter. is_vararg() checks the star's parent against
VARARGS_PARENTS, which listed the argument and lambda nodes but not the
PEP 695 typevartuple and paramspec ones. The stars in a type parameter
list were therefore scored as multiplication and power operators, and
that delimiter beat the comma when the line was split.
Add both nodes to VARARGS_PARENTS. This affects def, async def, class
and type aliases alike.
Closes #52431 parent 51abf53 commit d8f44e6
2 files changed
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
65 | 94 | | |
66 | 95 | | |
67 | 96 | | |
| |||
0 commit comments