Skip to content

Overloading function issues (incompatible with supertype). #3750

Open
@cynecx

Description

@cynecx
mypy 0.530-dev-417e925b16bcd63ba594f5a85c54b2407bd8831d
KeyTy = TypeVar("KeyTy")
ValTy = TypeVar("ValTy")
TempTy = TypeVar("TempTy")

class CIDict(Dict[KeyTy, ValTy]):
    @overload
    def pop(self, key: KeyTy) -> ValTy:
        pass

    @overload
    def pop(self, key: KeyTy, default: Union[ValTy, TempTy]) \
            -> Union[ValTy, TempTy]:
        pass

    def pop(self, key: KeyTy, default: Optional[Union[ValTy, TempTy]] = None) \
            -> Union[ValTy, TempTy]:
        pass

Running mypy with:

mypy test.py --strict-optional --ignore-missing-imports --disallow-untyped-calls --python-version 3.6

Issues:

CIDict.py:31: error: Signature of "pop" incompatible with supertype "MutableMapping"
CIDict.py:40: error: Overloaded function implementation does not accept all possible arguments of signature 2

Line number differ because the code above is only a snippet.

What am I missing here?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions