mypy icon indicating copy to clipboard operation
mypy copied to clipboard

no error when method in metaclass is overridden by an incompatible method in its instance

Open DetachHead opened this issue 1 year ago • 0 comments

class Foo(type):
    def foo(cls) -> None: ...


class Bar(Foo):
    def asdf(cls) -> None:
        cls.foo()


class Baz(metaclass=Bar):
    # no error.
    # at runtime it raises TypeError: Baz.foo() missing 2 required positional arguments: 'self' and 'asdf'
    def foo(self, asdf: int) -> None: ...


Baz.asdf()

playground

DetachHead avatar Oct 16 '24 04:10 DetachHead