mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-31 00:24:24 +08:00
Improve pathlib stubs (#7181)
This commit is contained in:
@@ -54,7 +54,7 @@ class PurePath(PathLike[str]):
|
||||
def parents(self: Self) -> Sequence[Self]: ...
|
||||
@property
|
||||
def parent(self: Self) -> Self: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
if sys.version_info >= (3, 9) and sys.version_info < (3, 11):
|
||||
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
|
||||
|
||||
class PurePosixPath(PurePath): ...
|
||||
@@ -77,12 +77,8 @@ class Path(PurePath):
|
||||
|
||||
def exists(self) -> bool: ...
|
||||
def glob(self: Self, pattern: str) -> Generator[Self, None, None]: ...
|
||||
def group(self) -> str: ...
|
||||
def is_dir(self) -> bool: ...
|
||||
def is_file(self) -> bool: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def is_mount(self) -> bool: ...
|
||||
|
||||
def is_symlink(self) -> bool: ...
|
||||
def is_socket(self) -> bool: ...
|
||||
def is_fifo(self) -> bool: ...
|
||||
@@ -147,7 +143,14 @@ class Path(PurePath):
|
||||
def open(
|
||||
self, mode: str, buffering: int = ..., encoding: str | None = ..., errors: str | None = ..., newline: str | None = ...
|
||||
) -> IO[Any]: ...
|
||||
def owner(self) -> str: ...
|
||||
if sys.platform != "win32":
|
||||
# These methods do "exist" on Windows, but they always raise NotImplementedError,
|
||||
# so it's safer to pretend they don't exist
|
||||
def owner(self) -> str: ...
|
||||
def group(self) -> str: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def is_mount(self) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def readlink(self: Self) -> Self: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
@@ -6,6 +6,11 @@ sqlite3.Connection.load_extension
|
||||
sqlite3.dbapi2.Connection.enable_load_extension
|
||||
sqlite3.dbapi2.Connection.load_extension
|
||||
|
||||
# pathlib methods that exist on Windows, but always raise NotImplementedError,
|
||||
# so are omitted from the stub
|
||||
pathlib.WindowsPath.is_mount
|
||||
pathlib.Path.is_mount
|
||||
|
||||
# Exists at runtime, but missing from stubs
|
||||
_winapi.CreateFileMapping
|
||||
_winapi.MapViewOfFile
|
||||
|
||||
@@ -7,6 +7,11 @@ cgi.parse
|
||||
urllib.parse.parse_qs
|
||||
urllib.parse.parse_qsl
|
||||
|
||||
# pathlib methods that exist on Windows, but always raise NotImplementedError,
|
||||
# so are omitted from the stub
|
||||
pathlib.WindowsPath.group
|
||||
pathlib.WindowsPath.owner
|
||||
|
||||
hashlib.scrypt
|
||||
os.startfile
|
||||
|
||||
|
||||
@@ -8,6 +8,13 @@ cgi.parse_multipart
|
||||
urllib.parse.parse_qs
|
||||
urllib.parse.parse_qsl
|
||||
|
||||
# pathlib methods that exist on Windows, but always raise NotImplementedError,
|
||||
# so are omitted from the stub
|
||||
pathlib.WindowsPath.group
|
||||
pathlib.WindowsPath.owner
|
||||
pathlib.Path.is_mount
|
||||
pathlib.WindowsPath.is_mount
|
||||
|
||||
os.startfile
|
||||
|
||||
# Exists at runtime, but missing from stubs
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
# pathlib methods that exist on Windows, but always raise NotImplementedError,
|
||||
# so are omitted from the stub
|
||||
pathlib.WindowsPath.group
|
||||
pathlib.WindowsPath.owner
|
||||
pathlib.Path.is_mount
|
||||
pathlib.WindowsPath.is_mount
|
||||
|
||||
# Exists at runtime, but missing from stubs
|
||||
_winapi.CreateFileMapping
|
||||
_winapi.MapViewOfFile
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
# pathlib methods that exist on Windows, but always raise NotImplementedError,
|
||||
# so are omitted from the stub
|
||||
pathlib.Path.is_mount
|
||||
pathlib.WindowsPath.is_mount
|
||||
|
||||
# Exists at runtime, but missing from stubs
|
||||
_winapi.CreateFileMapping
|
||||
_winapi.MapViewOfFile
|
||||
|
||||
@@ -56,6 +56,10 @@ curses.textpad
|
||||
pty
|
||||
tty
|
||||
|
||||
# pathlib functions that rely on modules that don't exist on Windows
|
||||
pathlib.Path.owner
|
||||
pathlib.Path.group
|
||||
|
||||
# Exists at runtime, but missing from stubs
|
||||
_msi.MSIError
|
||||
asyncio.windows_utils.Popen
|
||||
|
||||
Reference in New Issue
Block a user