Skip to content

Allow overriding of instance methods with staticmethods or classmethods? #4504

Description

@sharkdp

As a follow up to #4341, this ticket tracks the open question about whether or not to allow the following override (and similar cases with classmethod, or in reverse):

class Base:
    def f(self, x: int) -> None:
        ...

class Sub(Base):
    # ty: invalid-method-override
    @staticmethod
    def f(x: int) -> None:
        ...

See #4341 (comment) for an explanation of why this is not sound (and why we might want to allow it anyway).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintaineroverridesIssues related to validating subclass overrides (Liskov checks, etc)

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions