Files
ruff/crates/ty_python_semantic
Charlie MarshandDhruv Manilawala ec92fb2b9c [ty] Preserve keyword safety for unpacked callables (#27517)
## Summary

Follow-up to #27516.

Previously, callable assignability could overlook keyword arguments that
reach explicit source parameters through a target's `**kwargs`:

```python
from typing import Protocol

class Callback(Protocol):
    def __call__(self, *args: *tuple[*tuple[int, ...], int], **kwargs: str) -> None: ...

def source(*args: object, flag: int = 0, **kwargs: str) -> None: ...

callback: Callback = source  # error: [invalid-assignment]
```

The target accepts `callback(1, flag="wrong")`, but `source` requires
`flag` to be an integer.

We now validate target keyword-variadic values against explicit source
parameters, reject names that collide with source parameters already
occupied positionally, and prevent positional target arguments from
satisfying required source keyword-only parameters. Existing protected
names and uninhabited keyword annotations remain valid.

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2026-08-19 11:33:56 +05:30
..
2026-08-13 09:39:16 -04:00
2026-08-13 09:39:16 -04:00

ty_python_semantic

This crate is an internal component of Ruff. The Rust API exposed here is unstable and will have frequent breaking changes.

This version (0.0.9) is a component of Ruff 0.16.3. The source can be found here.

See Ruff's crate versioning policy for details on versioning.