Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dchirikov opened this issue Jun 9, 2020 · 2 comments
Closed

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

dchirikov opened this issue Jun 9, 2020 · 2 comments
Labels
topic-join-v-union Using join vs. using unions

Comments

@dchirikov
Copy link

dchirikov commented Jun 9, 2020

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?

@dchirikov dchirikov changed the title List item 0 has incompatible type "Callable[[Union[AnyStr, _PathLike[AnyStr]]], bool]"; expected "Callable[[_PathLike[AnyStr]], bool]" Weird behaviour of Union[] in 0.870 Jun 9, 2020
@dchirikov dchirikov changed the title Weird behaviour of Union[] in 0.870 Weird behaviour on os.path.* in 0.870 Jun 9, 2020
@JelleZijlstra
Copy link
Member

This sounds similar to #8961 and #8962.

@AlexWaygood
Copy link
Member

Can't reproduce on mypy 0.902+.

@AlexWaygood AlexWaygood added the topic-join-v-union Using join vs. using unions label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-join-v-union Using join vs. using unions
Projects
None yet
Development

No branches or pull requests

3 participants