mirror of
https://github.com/astral-sh/ruff.git
synced 2026-10-28 10:45:37 +08:00
## 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>
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.