Skip to content

Commit ff16eee

Browse files
committed
Merge pull request #443 from spkersten/ospath436
Replaced overload with AnyStr or Union type in os/path module
2 parents 3ed4e07 + fc4b893 commit ff16eee

File tree

1 file changed

+32
-100
lines changed

1 file changed

+32
-100
lines changed

stubs/3.2/os/path.py

Lines changed: 32 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -18,112 +18,44 @@
1818
devnull = ''
1919

2020
# ----- os.path function stubs -----
21-
@overload
22-
def abspath(path: str) -> str: pass
23-
@overload
24-
def abspath(path: bytes) -> bytes: pass
25-
@overload
26-
def basename(path: str) -> str: pass
27-
@overload
28-
def basename(path: bytes) -> bytes: pass
21+
def abspath(path: AnyStr) -> AnyStr: pass
22+
def basename(path: AnyStr) -> AnyStr: pass
23+
2924
# NOTE: Empty List[bytes] results in '' (str) => fall back to Any return type.
3025
def commonprefix(list: List[AnyStr]) -> Any: pass
31-
@overload
32-
def dirname(path: str) -> str: pass
33-
@overload
34-
def dirname(path: bytes) -> bytes: pass
35-
@overload
36-
def exists(path: str) -> bool: pass
37-
@overload
38-
def exists(path: bytes) -> bool: pass
39-
@overload
40-
def lexists(path: str) -> bool: pass
41-
@overload
42-
def lexists(path: bytes) -> bool: pass
43-
@overload
44-
def expanduser(path: str) -> str: pass
45-
@overload
46-
def expanduser(path: bytes) -> bytes: pass
47-
@overload
48-
def expandvars(path: str) -> str: pass
49-
@overload
50-
def expandvars(path: bytes) -> bytes: pass
26+
def dirname(path: AnyStr) -> AnyStr: pass
27+
def exists(path: AnyStr) -> bool: pass
28+
def lexists(path: AnyStr) -> bool: pass
29+
def expanduser(path: AnyStr) -> AnyStr: pass
30+
def expandvars(path: AnyStr) -> AnyStr: pass
31+
5132

5233
# These return float if os.stat_float_times() == True
53-
@overload
54-
def getatime(path: str) -> Any: pass
55-
@overload
56-
def getatime(path: bytes) -> Any: pass
57-
@overload
58-
def getmtime(path: str) -> Any: pass
59-
@overload
60-
def getmtime(path: bytes) -> Any: pass
61-
@overload
62-
def getctime(path: str) -> Any: pass
63-
@overload
64-
def getctime(path: bytes) -> Any: pass
34+
def getatime(path: AnyStr) -> Any: pass
35+
def getmtime(path: AnyStr) -> Any: pass
36+
def getctime(path: AnyStr) -> Any: pass
37+
38+
def getsize(path: AnyStr) -> int: pass
39+
def isabs(path: AnyStr) -> bool: pass
40+
def isfile(path: AnyStr) -> bool: pass
41+
def isdir(path: AnyStr) -> bool: pass
42+
def islink(path: AnyStr) -> bool: pass
43+
def ismount(path: AnyStr) -> bool: pass
44+
45+
def join(path: AnyStr, *paths: AnyStr) -> AnyStr: pass
6546

66-
@overload
67-
def getsize(path: str) -> int: pass
68-
@overload
69-
def getsize(path: bytes) -> int: pass
70-
@overload
71-
def isabs(path: str) -> bool: pass
72-
@overload
73-
def isabs(path: bytes) -> bool: pass
74-
@overload
75-
def isfile(path: str) -> bool: pass
76-
@overload
77-
def isfile(path: bytes) -> bool: pass
78-
@overload
79-
def isdir(path: str) -> bool: pass
80-
@overload
81-
def isdir(path: bytes) -> bool: pass
82-
@overload
83-
def islink(path: str) -> bool: pass
84-
@overload
85-
def islink(path: bytes) -> bool: pass
86-
@overload
87-
def ismount(path: str) -> bool: pass
88-
@overload
89-
def ismount(path: bytes) -> bool: pass
90-
@overload
91-
def join(path: str, *paths: str) -> str: pass
92-
@overload
93-
def join(path: bytes, *paths: bytes) -> bytes: pass
94-
@overload
95-
def normcase(path: str) -> str: pass
96-
@overload
97-
def normcase(path: bytes) -> bytes: pass
98-
@overload
99-
def normpath(path: str) -> str: pass
100-
@overload
101-
def normpath(path: bytes) -> bytes: pass
102-
@overload
103-
def realpath(path: str) -> str: pass
104-
@overload
105-
def realpath(path: bytes) -> bytes: pass
106-
@overload
107-
def relpath(path: str, start: str = None) -> str: pass
108-
@overload
109-
def relpath(path: bytes, start: bytes = None) -> bytes: pass
110-
@overload
111-
def samefile(path1: str, path2: str) -> bool: pass
112-
@overload
113-
def samefile(path1: bytes, path2: bytes) -> bool: pass
47+
def normcase(path: AnyStr) -> AnyStr: pass
48+
def normpath(path: AnyStr) -> AnyStr: pass
49+
def realpath(path: AnyStr) -> AnyStr: pass
50+
def relpath(path: AnyStr, start: AnyStr = None) -> AnyStr: pass
51+
52+
def samefile(path1: AnyStr, path2: AnyStr) -> bool: pass
11453
def sameopenfile(fp1: int, fp2: int) -> bool: pass
11554
#def samestat(stat1: stat_result,
11655
# stat2: stat_result) -> bool: pass # Unix only
117-
@overload
118-
def split(path: str) -> Tuple[str, str]: pass
119-
@overload
120-
def split(path: bytes) -> Tuple[bytes, bytes]: pass
121-
@overload
122-
def splitdrive(path: str) -> Tuple[str, str]: pass
123-
@overload
124-
def splitdrive(path: bytes) -> Tuple[bytes, bytes]: pass
125-
@overload
126-
def splitext(path: str) -> Tuple[str, str]: pass
127-
@overload
128-
def splitext(path: bytes) -> Tuple[bytes, bytes]: pass
56+
57+
def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: pass
58+
def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: pass
59+
def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: pass
60+
12961
#def splitunc(path: str) -> Tuple[str, str]: pass # Windows only, deprecated

0 commit comments

Comments
 (0)