Skip to content

"Union[str, Path]" is incompatible with "Union[str, bytes, int, _PathLike[Any]]" #4222

Closed
@sametmax

Description

@sametmax

I have some code doing:

def extract(path: Union[str, Path]) -> Generator:
    with open(path) as f:

Mypy complains:

 Argument 1 to "open" has incompatible type "Union[str, Path]"; expected "Union[str, bytes, int, _PathLike[Any]]"

But it seems to me that Union[str, Path] is an subset of Union[str, bytes, int, _PathLike[Any]], or am I mistaken ?

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