KEMBAR78
"Overloaded ... incompatible return types" error when one overloaded argument is a Tuple · Issue #4237 · python/mypy · GitHub
Skip to content

"Overloaded ... incompatible return types" error when one overloaded argument is a Tuple #4237

@joshstaiger

Description

@joshstaiger

Running mypy (0.550) on the following code:

from typing import overload, Tuple, Any

class A: ...
class B: ...
class C: ...
class D: ...

@overload
def f(x: A) -> B: ...

@overload
def f(x: Tuple[C]) -> D: ...

def f(x: Any) -> Any:...

reports:

error: Overloaded function signatures 1 and 2 overlap with incompatible return types

I've tried a couple different types for the second overload and so far the error only seems to occur with Tuple[...] arguments. For instance, I don't see the issue if I substitute def f(x:List[C]) -> D: ... as the 2nd overload.

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