Skip to content

Weird behaviour on os.path.* in 0.870 #8980

Closed
@dchirikov

Description

@dchirikov

Updating mypy to the latest (0.870) version I got it complaining about the following code:

import os
path = "/tmp"
for call in [os.path.exists, os.path.isdir]:
    assert(call(path))
test.py:3: error: List item 0 has incompatible type "Callable[[Union[AnyStr, _PathLike[AnyStr]]], bool]"; expected "Callable[[_PathLike[AnyStr]], bool]"
test.py:4: error: Argument 1 has incompatible type "str"; expected "_PathLike[AnyStr]"

0.770 version is happy with it.
Is this an expected behavior, or a bug?

If it is expected - what's the proper way to make the latest mypy happy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions