ruff
5770a363 - [ty] Consider keyword arguments when unpacking a variadic argument (#22796)

Commit
4 days ago
[ty] Consider keyword arguments when unpacking a variadic argument (#22796) ## Summary fixes: https://github.com/astral-sh/ty/issues/1584 This PR fixes a bug where ty would unpack a variadic argument consuming all the remaining unmatched parameters. The way this fix is implemented is by collecting the parameters for which an argument is provided via keyword e.g., `func(foo=1)`. For example, ```py def foo(x: str, y: int): ... def _(args: list[str]): foo(*args, y=1) ``` In the above example, `main` would currently raise `parameter-already-assigned` because we don't know how many elements would `args` unpack into so we consider assigning the type to all the remaining parameters. But, in the above case `y` has been provided as keyword argument explicitly. Now, there are other cases like `foo(*args, 1)` or `foo(*args, *(1,))` which is not considered in this PR i.e., this PR only handles explicit keyword argument and we would still emit diagnostic for positional, variadic, and keyword-variadic. Pyright behaves in the same way i.e., it only handles keyword argument while other type checkers (mypy, pyrefly) does not handle any cases. Refer to the new mdtest cases for all the cases. ## Test Plan Add new mdtests.
Author
Parents
Loading