@@ -10,7 +10,12 @@ from typing import (
10
10
)
11
11
12
12
_T = TypeVar ('_T' )
13
- _PathType = Union [bytes , Text ]
13
+
14
+ if sys .version_info >= (3 , 6 ):
15
+ from builtins import _PathLike
16
+ _PathType = Union [bytes , Text , _PathLike ]
17
+ else :
18
+ _PathType = Union [bytes , Text ]
14
19
15
20
# ----- os.path variables -----
16
21
supports_unicode_filenames = False
@@ -55,20 +60,23 @@ def isdir(path: _PathType) -> bool: ...
55
60
def islink (path : _PathType ) -> bool : ...
56
61
def ismount (path : _PathType ) -> bool : ...
57
62
58
- # Make sure signatures are disjunct, and allow combinations of bytes and unicode.
59
- # (Since Python 2 allows that, too)
60
- # Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in
61
- # a type error.
62
- @overload
63
- def join (__p1 : bytes , * p : bytes ) -> bytes : ...
64
- @overload
65
- def join (__p1 : Text , * p : _PathType ) -> Text : ...
66
- @overload
67
- def join (__p1 : bytes , __p2 : Text , * p : _PathType ) -> Text : ...
68
- @overload
69
- def join (__p1 : bytes , __p2 : bytes , __p3 : Text , * p : _PathType ) -> Text : ...
70
- @overload
71
- def join (__p1 : bytes , __p2 : bytes , __p3 : bytes , __p4 : Text , * p : _PathType ) -> Text : ...
63
+ if sys .version_info < (3 , 0 ):
64
+ # Make sure signatures are disjunct, and allow combinations of bytes and unicode.
65
+ # (Since Python 2 allows that, too)
66
+ # Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in
67
+ # a type error.
68
+ @overload
69
+ def join (__p1 : bytes , * p : bytes ) -> bytes : ...
70
+ @overload
71
+ def join (__p1 : Text , * p : _PathType ) -> Text : ...
72
+ @overload
73
+ def join (__p1 : bytes , __p2 : Text , * p : _PathType ) -> Text : ...
74
+ @overload
75
+ def join (__p1 : bytes , __p2 : bytes , __p3 : Text , * p : _PathType ) -> Text : ...
76
+ @overload
77
+ def join (__p1 : bytes , __p2 : bytes , __p3 : bytes , __p4 : Text , * p : _PathType ) -> Text : ...
78
+ else :
79
+ def join (path : AnyStr , * paths : AnyStr ) -> AnyStr : ...
72
80
73
81
def normcase (path : AnyStr ) -> AnyStr : ...
74
82
def normpath (path : AnyStr ) -> AnyStr : ...
0 commit comments