ruff
bc28178d - [ty] Respect suppression of attribute override diagnostics (#29327)

Commit
40 days ago
[ty] Respect suppression of attribute override diagnostics (#29327) ## Summary We now allow a single ignore to suppress an incompatible attribute or property override: ```python from collections.abc import Callable class Base: # Callers can pass an int to this callable. f: Callable[[int], int] class Child(Base): # This override is incompatible: the bound method accepts no arguments. # Before: ignoring invalid-attribute-override exposed invalid-method-override, # so suppressing the same conflict required a second ignore. # After: this ignore suppresses the conflict, with no further diagnostic. def f(self) -> int: # ty: ignore[invalid-attribute-override] return 0 ``` Previously, the attribute checker only told its caller whether it emitted a diagnostic. Suppressing that diagnostic therefore caused the caller to continue into the method checker, which reported the same conflict under a different rule. We now return the applicable rule even when its diagnostic is suppressed or disabled, so the method checker does not revisit that conflict. Disabling an attribute or property override rule also avoids this fallback. We still check other base classes for violations of enabled rules. Closes https://github.com/astral-sh/ty/issues/4710.
Author
Parents
Loading