Repository navigation
Commit 4fcf2d6
Check starred args with variadic items against fixed formals as a whole
A starred argument whose type is a variable-length iterable of variadic
items (e.g. tuple[tuple[*Ts], ...], the type of *composed when annotated
*composed: tuple[*Ts]) previously had each of its items checked against a
single fixed formal, silently accepting calls that should be rejected
because the unpacked item count cannot match a fixed-arity signature.
In check_argument_types, when such an ARG_STAR actual maps to a non-star
formal, check the iterable as a whole against the formal instead of
expanding it item-by-item. This catches #22567: passing
*composed (tuple[tuple[*Ts], ...]) to func(composed: tuple[*Ts]) now
reports an incompatible-argument error instead of succeeding.
Add a regression test case (testTypeVarTupleUnpackedStarArgIsCheckedIssue22567)
in check-typevar-tuple.test.1 parent 0570905 commit 4fcf2d6
2 files changed
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2953 | 2953 | | |
2954 | 2954 | | |
2955 | 2955 | | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
2956 | 2980 | | |
2957 | 2981 | | |
2958 | 2982 | | |
| |||
6898 | 6922 | | |
6899 | 6923 | | |
6900 | 6924 | | |
| 6925 | + | |
| 6926 | + | |
| 6927 | + | |
| 6928 | + | |
| 6929 | + | |
| 6930 | + | |
| 6931 | + | |
| 6932 | + | |
| 6933 | + | |
| 6934 | + | |
| 6935 | + | |
| 6936 | + | |
| 6937 | + | |
| 6938 | + | |
| 6939 | + | |
| 6940 | + | |
| 6941 | + | |
| 6942 | + | |
| 6943 | + | |
| 6944 | + | |
| 6945 | + | |
| 6946 | + | |
| 6947 | + | |
| 6948 | + | |
| 6949 | + | |
| 6950 | + | |
| 6951 | + | |
| 6952 | + | |
6901 | 6953 | | |
6902 | 6954 | | |
6903 | 6955 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3324 | 3324 | | |
3325 | 3325 | | |
3326 | 3326 | | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
0 commit comments