diff --git a/stdlib/2/os/path.pyi b/stdlib/2/os/path.pyi index 56973e423be4..8f82bf24674a 100644 --- a/stdlib/2/os/path.pyi +++ b/stdlib/2/os/path.pyi @@ -55,7 +55,20 @@ def isdir(path: _PathType) -> bool: ... def islink(path: _PathType) -> bool: ... def ismount(path: _PathType) -> bool: ... -def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... +# Make sure signatures are disjunct, and allow combinations of bytes and unicode. +# (Since Python 2 allows that, too) +# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in +# a type error. +@overload +def join(__p1: bytes, *p: bytes) -> bytes: ... +@overload +def join(__p1: Text, *p: _PathType) -> Text: ... +@overload +def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ... +@overload +def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ... +@overload +def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ... def normcase(path: AnyStr) -> AnyStr: ... def normpath(path: AnyStr) -> AnyStr: ... @@ -63,7 +76,7 @@ if sys.platform == 'win32': def realpath(path: AnyStr) -> AnyStr: ... else: def realpath(filename: AnyStr) -> AnyStr: ... -def relpath(path: AnyStr, start: AnyStr = ...) -> AnyStr: ... +def relpath(path: AnyStr, start: _PathType = ...) -> AnyStr: ... def samefile(path1: _PathType, path2: _PathType) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ...