ruff
eb625e43 - [ty] Check overrides of receiver attribute declarations (#28557)

Commit
42 days ago
[ty] Check overrides of receiver attribute declarations (#28557) ## Summary We now check receiver attribute declarations against inherited attribute contracts: ```python class Base: value: int class Child(Base): def __init__(self) -> None: self.value: str = "" # invalid-attribute-override ``` This covers attributes declared in methods on either side of an override, including generic specializations and inherited slots. The opt-in mutable-override rule also rejects narrowing a receiver declaration's type. Plain assignments continue to initialize or update an inherited attribute without introducing a new declaration. We compare each class's own declarations so that inherited lookup cannot hide an incompatible receiver annotation. Names absent from the bases are skipped before inferring method bodies. Part of https://github.com/astral-sh/ty/issues/2158.
Author
Parents
Loading