ruff
d0cf01cf - [ty] Preserve wrapped signatures in nominal descriptor checks (#28466)

Commit
2 days ago
[ty] Preserve wrapped signatures in nominal descriptor checks (#28466) ## Summary We now check the wrapped callable when assigning a precise method wrapper to an annotated `staticmethod` or `classmethod`. Previously, the nominal fallback discarded the wrapped signature, allowing a function returning `str` where the descriptor promised `int`: ```python def stringify(value: int) -> str: return str(value) def consume(method: staticmethod[[int], int]) -> int: return method(1) + 1 consume(staticmethod(stringify)) # Now rejected. ``` Compare the wrapped callable with the nominal descriptor's specialized `__func__` contract, preserving overload-specific return types. Use the same relation when inferring generic descriptor parameters. Follow-up to #28207. Addresses [this review comment](https://github.com/astral-sh/ruff/pull/28207#discussion_r3965484630).
Author
Parents
Loading