classes_override_3
error
@override on a method with no matching ancestor method
PEP 698 — a method decorated @override (or typing.override) must actually override a method declared in a base class. When no ancestor declares a method of that name, the decorator is a lie and the type checker should report it.
To stay free of false positives the check is deliberately conservative: it only fires when the entire ancestor chain is resolvable within the current module (no Any base and no imported base whose methods we cannot see), so a method that legitimately overrides something in an unseen base is never flagged.
class Base:
def existing(self) -> int: ...
class Child(Base):
@override
def missing(self) -> int: # E0159: nothing named `missing` in any base
return 1
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
classes_override_3 down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/classes_override_3