Files
typeshed/stdlib/ntpath.pyi
Alex Waygood 33a62ae42d Add more defaults to the stdlib (#9606)
Continuing work towards #8988.

The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are:

- Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine)
- Defaults in non-py311 branches
- Defaults for float parameters
- Defaults for overloads
2023-01-29 01:51:23 +00:00

115 lines
2.6 KiB
Python

import sys
from _typeshed import BytesPath, StrPath
from genericpath import (
commonprefix as commonprefix,
exists as exists,
getatime as getatime,
getctime as getctime,
getmtime as getmtime,
getsize as getsize,
isdir as isdir,
isfile as isfile,
samefile as samefile,
sameopenfile as sameopenfile,
samestat as samestat,
)
from os import PathLike
# Re-export common definitions from posixpath to reduce duplication
from posixpath import (
abspath as abspath,
basename as basename,
commonpath as commonpath,
curdir as curdir,
defpath as defpath,
devnull as devnull,
dirname as dirname,
expanduser as expanduser,
expandvars as expandvars,
extsep as extsep,
isabs as isabs,
islink as islink,
ismount as ismount,
lexists as lexists,
normcase as normcase,
normpath as normpath,
pardir as pardir,
pathsep as pathsep,
relpath as relpath,
sep as sep,
split as split,
splitdrive as splitdrive,
splitext as splitext,
supports_unicode_filenames as supports_unicode_filenames,
)
from typing import AnyStr, overload
from typing_extensions import LiteralString
__all__ = [
"normcase",
"isabs",
"join",
"splitdrive",
"split",
"splitext",
"basename",
"dirname",
"commonprefix",
"getsize",
"getmtime",
"getatime",
"getctime",
"islink",
"exists",
"lexists",
"isdir",
"isfile",
"ismount",
"expanduser",
"expandvars",
"normpath",
"abspath",
"curdir",
"pardir",
"sep",
"pathsep",
"defpath",
"altsep",
"extsep",
"devnull",
"realpath",
"supports_unicode_filenames",
"relpath",
"samefile",
"sameopenfile",
"samestat",
"commonpath",
]
altsep: LiteralString
# 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: LiteralString, *paths: LiteralString) -> LiteralString: ...
@overload
def join(__path: StrPath, *paths: StrPath) -> str: ...
@overload
def join(__path: BytesPath, *paths: BytesPath) -> bytes: ...
if sys.platform == "win32":
if sys.version_info >= (3, 10):
@overload
def realpath(path: PathLike[AnyStr], *, strict: bool = False) -> AnyStr: ...
@overload
def realpath(path: AnyStr, *, strict: bool = False) -> AnyStr: ...
else:
@overload
def realpath(path: PathLike[AnyStr]) -> AnyStr: ...
@overload
def realpath(path: AnyStr) -> AnyStr: ...
else:
realpath = abspath