Skip to content

Union subtyping doesn't work with covariant type constructors Tuple and Callable #7187

Open
@ilevkivskyi

Description

@ilevkivskyi

Both calls in this code fail, but I think they should be allowed:

from typing import Callable, Union, Tuple

def f(x: Union[Callable[..., int], Callable[..., str]]) -> None: ...
x: Callable[..., Union[int, str]]
f(x)

def g(y: Union[Tuple[int], Tuple[str]]) -> None: ...
y: Tuple[Union[int, str]]
g(y)

Moreover, I would say types in each pair are actually equivalent.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions