diff --git a/stdlib/ntpath.pyi b/stdlib/ntpath.pyi index f1fa137c6..1a58b52de 100644 --- a/stdlib/ntpath.pyi +++ b/stdlib/ntpath.pyi @@ -42,6 +42,9 @@ from posixpath import ( splitext as splitext, supports_unicode_filenames as supports_unicode_filenames, ) + +if sys.version_info >= (3, 12): + from posixpath import isjunction as isjunction, splitroot as splitroot from typing import AnyStr, overload from typing_extensions import LiteralString @@ -85,6 +88,8 @@ __all__ = [ "samestat", "commonpath", ] +if sys.version_info >= (3, 12): + __all__ += ["isjunction", "splitroot"] altsep: LiteralString diff --git a/stdlib/posixpath.pyi b/stdlib/posixpath.pyi index 1945190be..45a8ad7ec 100644 --- a/stdlib/posixpath.pyi +++ b/stdlib/posixpath.pyi @@ -58,6 +58,8 @@ __all__ = [ "relpath", "commonpath", ] +if sys.version_info >= (3, 12): + __all__ += ["isjunction", "splitroot"] supports_unicode_filenames: bool # aliases (also in os) @@ -150,3 +152,10 @@ def isabs(s: StrOrBytesPath) -> bool: ... def islink(path: FileDescriptorOrPath) -> bool: ... def ismount(path: FileDescriptorOrPath) -> bool: ... def lexists(path: FileDescriptorOrPath) -> bool: ... + +if sys.version_info >= (3, 12): + def isjunction(path: StrOrBytesPath) -> bool: ... + @overload + def splitroot(p: AnyOrLiteralStr) -> tuple[AnyOrLiteralStr, AnyOrLiteralStr, AnyOrLiteralStr]: ... + @overload + def splitroot(p: PathLike[AnyStr]) -> tuple[AnyStr, AnyStr, AnyStr]: ... diff --git a/tests/stubtest_allowlists/py312.txt b/tests/stubtest_allowlists/py312.txt index 0a7bec9d1..8e585797d 100644 --- a/tests/stubtest_allowlists/py312.txt +++ b/tests/stubtest_allowlists/py312.txt @@ -33,21 +33,12 @@ importlib.resources.files importlib.util.module_for_loader importlib.util.set_loader importlib.util.set_package -ntpath.__all__ -ntpath.isjunction -ntpath.splitroot os.DirEntry.is_junction -os.path.__all__ -os.path.isjunction -os.path.splitroot pathlib.Path.__init__ pathlib.PurePath.__init__ pathlib.PurePath.is_relative_to pathlib.PurePath.relative_to poplib.POP3_SSL.__init__ -posixpath.__all__ -posixpath.isjunction -posixpath.splitroot smtplib.SMTP.starttls smtplib.SMTP_SSL.__init__ typing.ParamSpec.__mro_entries__