8000 Make `os.path.join()` first parameter pos-only (#6812) · python/typeshed@582f1e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 582f1e9

Browse files
authored
Make os.path.join() first parameter pos-only (#6812)
1 parent 73302d3 commit 582f1e9

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

stdlib/ntpath.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ altsep: str
4848
if sys.version_info < (3, 7) and sys.platform == "win32":
4949
def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated
5050

51-
# Similar to posixpath, but have slightly different argument names
51+
# First parameter is not actually pos-only,
52+
# but must be defined as pos-only in the stub or cross-platform code doesn't type-check,
53+
# as the parameter name is different in posixpath.join()
5254
@overload
53-
def join(path: StrPath, *paths: StrPath) -> str: ...
55+
def join(__path: StrPath, *paths: StrPath) -> str: ...
5456
@overload
55-
def join(path: BytesPath, *paths: BytesPath) -> bytes: ...
57+
def join(__path: BytesPath, *paths: BytesPath) -> bytes: ...
5658

5759
if sys.platform == "win32":
5860
if sys.version_info >= (3, 10):

stdlib/posixpath.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ def normpath(path: AnyStr) -> AnyStr: ...
6060
def commonpath(paths: Sequence[StrPath]) -> str: ...
6161
@overload
6262
def commonpath(paths: Sequence[BytesPath]) -> bytes: ...
63+
64+
# First parameter is not actually pos-only,
65+
# but must be defined as pos-only in the stub or cross-platform code doesn't type-check,
66+
# as the parameter name is different in ntpath.join()
6367
@overload
64-
def join(a: StrPath, *paths: StrPath) -> str: ...
68+
def join(__a: StrPath, *paths: StrPath) -> str: ...
6569
@overload
66-
def join(a: BytesPath, *paths: BytesPath) -> bytes: ...
70+
def join(__a: BytesPath, *paths: BytesPath) -> bytes: ...
6771

6872
if sys.version_info >= (3, 10):
6973
@overload

tests/stubtest_allowlists/py310.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ contextlib.AbstractContextManager.__exit__
115115
io.IncrementalNewlineDecoder.setstate
116116
typing.SupportsRound.__round__
117117
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences
118+
# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
119+
posixpath.join
120+
ntpath.join
121+
os.path.join
118122

119123
# These enums derive from (str, Enum). See comment in py3_common.txt
120124
pstats.SortKey.__new__

0 commit comments

Comments
 (0)
0