ty
ty copied to clipboard
Extend `invalid-method-override` diagnostics to cover methods being overridden by non-methods
We have a basic implementation of the Liskov Substitution Principle in place for method overrides. But we do not currently emit diagnostics for methods invalidly overridden by non-methods. We need to implement this.
This should include methods being overridden by definitions in the class body:
class A:
def f(self) -> None: ...
class B(A):
f = None
It should include methods overridden by declarations in the class body:
class A:
def f(self) -> None: ...
class B(A):
f: int
and it should include methods overridden by implicit instance attributes:
class A:
def f(self): ...
class B(A):
def __init__(self) -> None:
self.f = 42
We may want to fix https://github.com/astral-sh/ty/issues/1345 before fixing this issue.