Skip to content

Signatures of overloaded methods are incompatible with supertypes, even if they really are #3262

Closed
@refi64

Description

@refi64

e.g.

from typing import overload

class A:
    @overload
    def f(self, x: str) -> str: ...
    @overload
    def f(self, y: int) -> int: ...

class B(A):
    @overload
    def f(self, x: str) -> str: ...
    @overload
    def f(self, y: int) -> int: ...
    @overload
    def f(self, z: bytes) -> bytes: ...

IMO in this case, it should still be compatible, since B supports A's full API, just with another extra function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions