Skip to content

Overloads with default arguments do not work properly #5486

Closed
@padix-key

Description

@padix-key

I have the follwoing stub file (test.pyi):

from typing import overload

@overload
def func(
    param: None = ...
) -> int: ...

@overload
def func(
    param: int = ...
) -> str: ...

When I run mypy test.pyi, mypy shows the following error:
test.pyi:4: error: Overloaded function signatures 1 and 2 overlap with incompatible return types
The parameter param clearly has two different types. Hence, the functions should not overlap to my understanding.

mypy 0.620 has been used.

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