-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Unexpected type 'unicode' for os.path.join() with (Any, str) args #5232
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
Comments
I am looking at this now. |
I think the issue is that due to the way we handle promotions in mypy, Not sure what the best way to handle this is -- I'd personally prefer just removing that promotion altogether, but that's a very invasive and difficult-to-implement change. Alternatively, we could special-case this in the union math somehow, but that would make it inconsistent with the rest of mypy. E.g. this currently typechecks, for example:
|
I guess other options include:
|
My original motivation for requesting it was that this example should work @overload
def f(x: List[int]) -> List[int]: ...
@overload
def f(x: List[Any]) -> List[Any]: ...
arg: Any
f(arg) # should be List[Any], _not_ just Any Also now I think that we should really check both ways, because the logic is that replacing a precise type with def f() -> int: ...
@overload
def g(x: int) -> int: ...
@overload
def g(x: float) -> float: ...
x: int = g(f()) # this passes, but will fail if I remove the annotation from 'f' I will now prepare a PR to return last type only if it is compatible both ways with all other return types (like in the first example with |
Fixes #5232 This also makes few minor amendments to pythoneval tests.
The revealed type for the
os.path.join
call in the program below isunicode
, even though I'd expect eitherAny
orstr
, as the arguments have typesAny
andstr
:Here's a self-contained example:
Run as
mypy -2 program.py
.@Michael0x2a Do you have time to have a look at this? This is causing issues in internal Dropbox repos. If you are busy, I can try to fix this. This was apparently introduced by f61c2ba.
The text was updated successfully, but these errors were encountered: