mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-03-15 19:18:55 +08:00
pathlib: Python3.13 updates (#12048)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
import types
|
||||
from _typeshed import (
|
||||
OpenBinaryMode,
|
||||
OpenBinaryModeReading,
|
||||
@@ -14,7 +15,7 @@ from collections.abc import Callable, Generator, Iterator, Sequence
|
||||
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
|
||||
from os import PathLike, stat_result
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, BinaryIO, Literal, overload
|
||||
from typing import IO, Any, BinaryIO, ClassVar, Literal, overload
|
||||
from typing_extensions import Self, deprecated
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
@@ -22,7 +23,14 @@ if sys.version_info >= (3, 9):
|
||||
|
||||
__all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"]
|
||||
|
||||
if sys.version_info >= (3, 13):
|
||||
__all__ += ["UnsupportedOperation"]
|
||||
|
||||
class PurePath(PathLike[str]):
|
||||
if sys.version_info >= (3, 13):
|
||||
parser: ClassVar[types.ModuleType]
|
||||
def full_match(self, pattern: StrPath, *, case_sensitive: bool | None = None) -> bool: ...
|
||||
|
||||
@property
|
||||
def parts(self) -> tuple[str, ...]: ...
|
||||
@property
|
||||
@@ -94,8 +102,6 @@ class PureWindowsPath(PurePath): ...
|
||||
|
||||
class Path(PurePath):
|
||||
def __new__(cls, *args: StrPath, **kwargs: Any) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||
@classmethod
|
||||
def cwd(cls) -> Self: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
@@ -105,17 +111,38 @@ class Path(PurePath):
|
||||
def stat(self) -> stat_result: ...
|
||||
def chmod(self, mode: int) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
def exists(self, *, follow_symlinks: bool = True) -> bool: ...
|
||||
if sys.version_info >= (3, 13):
|
||||
@classmethod
|
||||
def from_uri(cls, uri: str) -> Path: ...
|
||||
def is_dir(self, *, follow_symlinks: bool = True) -> bool: ...
|
||||
def is_file(self, *, follow_symlinks: bool = True) -> bool: ...
|
||||
def read_text(self, encoding: str | None = None, errors: str | None = None, newline: str | None = None) -> str: ...
|
||||
else:
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||
def is_dir(self) -> bool: ...
|
||||
def is_file(self) -> bool: ...
|
||||
def read_text(self, encoding: str | None = None, errors: str | None = None) -> str: ...
|
||||
|
||||
if sys.version_info >= (3, 13):
|
||||
def glob(
|
||||
self, pattern: str, *, case_sensitive: bool | None = None, recurse_symlinks: bool = False
|
||||
) -> Generator[Self, None, None]: ...
|
||||
def rglob(
|
||||
self, pattern: str, *, case_sensitive: bool | None = None, recurse_symlinks: bool = False
|
||||
) -> Generator[Self, None, None]: ...
|
||||
elif sys.version_info >= (3, 12):
|
||||
def glob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self, None, None]: ...
|
||||
def rglob(self, pattern: str, *, case_sensitive: bool | None = None) -> Generator[Self, None, None]: ...
|
||||
else:
|
||||
def exists(self) -> bool: ...
|
||||
def glob(self, pattern: str) -> Generator[Self, None, None]: ...
|
||||
def rglob(self, pattern: str) -> Generator[Self, None, None]: ...
|
||||
|
||||
def is_dir(self) -> bool: ...
|
||||
def is_file(self) -> bool: ...
|
||||
if sys.version_info >= (3, 12):
|
||||
def exists(self, *, follow_symlinks: bool = True) -> bool: ...
|
||||
else:
|
||||
def exists(self) -> bool: ...
|
||||
|
||||
def is_symlink(self) -> bool: ...
|
||||
def is_socket(self) -> bool: ...
|
||||
def is_fifo(self) -> bool: ...
|
||||
@@ -186,8 +213,12 @@ class Path(PurePath):
|
||||
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, 13):
|
||||
def owner(self, *, follow_symlinks: bool = True) -> str: ...
|
||||
def group(self, *, follow_symlinks: bool = True) -> str: ...
|
||||
else:
|
||||
def owner(self) -> str: ...
|
||||
def group(self) -> str: ...
|
||||
|
||||
# This method does "exist" on Windows on <3.12, but always raises NotImplementedError
|
||||
# On py312+, it works properly on Windows, as with all other platforms
|
||||
@@ -212,7 +243,6 @@ class Path(PurePath):
|
||||
def absolute(self) -> Self: ...
|
||||
def expanduser(self) -> Self: ...
|
||||
def read_bytes(self) -> bytes: ...
|
||||
def read_text(self, encoding: str | None = None, errors: str | None = None) -> str: ...
|
||||
def samefile(self, other_path: StrPath) -> bool: ...
|
||||
def write_bytes(self, data: ReadableBuffer) -> int: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
@@ -234,3 +264,6 @@ class Path(PurePath):
|
||||
|
||||
class PosixPath(Path, PurePosixPath): ...
|
||||
class WindowsPath(Path, PureWindowsPath): ...
|
||||
|
||||
if sys.version_info >= (3, 13):
|
||||
class UnsupportedOperation(NotImplementedError): ...
|
||||
|
||||
Reference in New Issue
Block a user