ruff
94db3258 - [ty] Preserve minimum lengths of unpacked tuple unions (#29331)

Commit
15 days ago
[ty] Preserve minimum lengths of unpacked tuple unions (#29331) Reject calls where every member of an unpacked tuple union supplies too many arguments once later positional arguments are included: ```python def f(a: int) -> None: ... def g(args: tuple[int] | tuple[int, int]) -> None: f(*args, 1) # too-many-positional-arguments ``` Combining unequal tuple shapes previously discarded their minimum lengths, allowing argument matching to treat `args` as empty. `TupleSpecBuilder::union` now preserves the smaller minimum length when combining shapes, so `Type::iterate` retains that guarantee for all its consumers. This also preserves required elements when unpacking tuple unions into tuple literals or inferring a `TypeVarTuple`. Addresses the [minimum-length review comment](https://github.com/astral-sh/ruff/pull/29293#discussion_r4248949931) on #29293. ## Ecosystem report Analyzed head: [`1b5eb5424c`](https://github.com/astral-sh/ruff/commit/1b5eb5424c7fad6edf6994d73a36691f358a97e2). [Full report](https://github.com/astral-sh/ruff/pull/29331#issuecomment-6150237369). The five changes are understood and acceptable for this fix: two more precise Bokeh messages, two rewrites of existing Meson cyclic-inference warnings, and one duplicate SymPy argument error. No newly rejected calls were found. The duplicate reflects pre-existing reporting behavior for nonempty tuples and can be addressed independently.
Author
Parents
Loading