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

Skip to content

Make os.path.join() first parameter pos-only #6812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions stdlib/ntpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ altsep: str
if sys.version_info < (3, 7) and sys.platform == "win32":
def splitunc(p: AnyStr) -> tuple[AnyStr, AnyStr]: ... # deprecated

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

if sys.platform == "win32":
if sys.version_info >= (3, 10):
Expand Down
8 changes: 6 additions & 2 deletions stdlib/posixpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ def normpath(path: AnyStr) -> AnyStr: ...
def commonpath(paths: Sequence[StrPath]) -> str: ...
@overload
def commonpath(paths: Sequence[BytesPath]) -> bytes: ...

# First parameter is not actually pos-only,
# but must be defined as pos-only in the stub or cross-platform code doesn't type-check,
# as the parameter name is different in ntpath.join()
@overload
def join(a: StrPath, *paths: StrPath) -> str: ...
def join(__a: StrPath, *paths: StrPath) -> str: ...
@overload
def join(a: BytesPath, *paths: BytesPath) -> bytes: ...
def join(__a: BytesPath, *paths: BytesPath) -> bytes: ...

if sys.version_info >= (3, 10):
@overload
Expand Down
4 changes: 4 additions & 0 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ contextlib.AbstractContextManager.__exit__
io.IncrementalNewlineDecoder.setstate
typing.SupportsRound.__round__
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences
# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
posixpath.join
ntpath.join
os.path.join

# These enums derive from (str, Enum). See comment in py3_common.txt
pstats.SortKey.__new__
Expand Down
0