Skip to content

Unexpected type 'unicode' for os.path.join() with (Any, str) args #5232

Closed
@JukkaL

Description

@JukkaL

The revealed type for the os.path.join call in the program below is unicode, even though I'd expect either Any or str, as the arguments have types Any and str:

import os
def f(): pass
reveal_type(os.path.join(f(), 'x'))  # builtins.unicode

Here's a self-contained example:

# a.pyi
from typing import overload
@overload
def join(__p1: bytes, *p: bytes) -> bytes: ...
@overload
def join(__p1: unicode, *p: unicode) -> unicode: ...
# program.py
from a import join
def f(): pass
reveal_type(join(f(), 'x'))  # builtins.unicode

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions