Skip to content

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

@DetachHead

Description

@DetachHead
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions