Use typing_extensions.Self in the stdlib (#9694)

This commit is contained in:
Alex Waygood
2023-02-09 09:12:13 +00:00
committed by GitHub
parent 10086c06a1
commit 9ed39d8796
98 changed files with 627 additions and 654 deletions

View File

@@ -6,7 +6,6 @@ from _typeshed import (
OpenBinaryModeWriting,
OpenTextMode,
ReadableBuffer,
Self,
StrOrBytesPath,
StrPath,
)
@@ -15,7 +14,7 @@ from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWra
from os import PathLike, stat_result
from types import TracebackType
from typing import IO, Any, BinaryIO, overload
from typing_extensions import Literal
from typing_extensions import Literal, Self
if sys.version_info >= (3, 9):
from types import GenericAlias
@@ -39,15 +38,15 @@ class PurePath(PathLike[str]):
def suffixes(self) -> list[str]: ...
@property
def stem(self) -> str: ...
def __new__(cls: type[Self], *args: StrPath) -> Self: ...
def __new__(cls, *args: StrPath) -> Self: ...
def __eq__(self, other: object) -> bool: ...
def __fspath__(self) -> str: ...
def __lt__(self, other: PurePath) -> bool: ...
def __le__(self, other: PurePath) -> bool: ...
def __gt__(self, other: PurePath) -> bool: ...
def __ge__(self, other: PurePath) -> bool: ...
def __truediv__(self: Self, key: StrPath) -> Self: ...
def __rtruediv__(self: Self, key: StrPath) -> Self: ...
def __truediv__(self, key: StrPath) -> Self: ...
def __rtruediv__(self, key: StrPath) -> Self: ...
def __bytes__(self) -> bytes: ...
def as_posix(self) -> str: ...
def as_uri(self) -> str: ...
@@ -57,17 +56,17 @@ class PurePath(PathLike[str]):
def is_relative_to(self, *other: StrPath) -> bool: ...
def match(self, path_pattern: str) -> bool: ...
def relative_to(self: Self, *other: StrPath) -> Self: ...
def with_name(self: Self, name: str) -> Self: ...
def relative_to(self, *other: StrPath) -> Self: ...
def with_name(self, name: str) -> Self: ...
if sys.version_info >= (3, 9):
def with_stem(self: Self, stem: str) -> Self: ...
def with_stem(self, stem: str) -> Self: ...
def with_suffix(self: Self, suffix: str) -> Self: ...
def joinpath(self: Self, *other: StrPath) -> Self: ...
def with_suffix(self, suffix: str) -> Self: ...
def joinpath(self, *other: StrPath) -> Self: ...
@property
def parents(self: Self) -> Sequence[Self]: ...
def parents(self) -> Sequence[Self]: ...
@property
def parent(self: Self) -> Self: ...
def parent(self) -> Self: ...
if sys.version_info >= (3, 9) and sys.version_info < (3, 11):
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
@@ -75,11 +74,11 @@ class PurePosixPath(PurePath): ...
class PureWindowsPath(PurePath): ...
class Path(PurePath):
def __new__(cls: type[Self], *args: StrPath, **kwargs: Any) -> Self: ...
def __enter__(self: Self) -> Self: ...
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: type[Self]) -> Self: ...
def cwd(cls) -> Self: ...
if sys.version_info >= (3, 10):
def stat(self, *, follow_symlinks: bool = True) -> stat_result: ...
def chmod(self, mode: int, *, follow_symlinks: bool = True) -> None: ...
@@ -88,7 +87,7 @@ class Path(PurePath):
def chmod(self, mode: int) -> None: ...
def exists(self) -> bool: ...
def glob(self: Self, pattern: str) -> Generator[Self, None, None]: ...
def glob(self, pattern: str) -> Generator[Self, None, None]: ...
def is_dir(self) -> bool: ...
def is_file(self) -> bool: ...
def is_symlink(self) -> bool: ...
@@ -96,7 +95,7 @@ class Path(PurePath):
def is_fifo(self) -> bool: ...
def is_block_device(self) -> bool: ...
def is_char_device(self) -> bool: ...
def iterdir(self: Self) -> Generator[Self, None, None]: ...
def iterdir(self) -> Generator[Self, None, None]: ...
def lchmod(self, mode: int) -> None: ...
def lstat(self) -> stat_result: ...
def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ...
@@ -163,16 +162,16 @@ class Path(PurePath):
def is_mount(self) -> bool: ...
if sys.version_info >= (3, 9):
def readlink(self: Self) -> Self: ...
def readlink(self) -> Self: ...
if sys.version_info >= (3, 8):
def rename(self: Self, target: str | PurePath) -> Self: ...
def replace(self: Self, target: str | PurePath) -> Self: ...
def rename(self, target: str | PurePath) -> Self: ...
def replace(self, target: str | PurePath) -> Self: ...
else:
def rename(self, target: str | PurePath) -> None: ...
def replace(self, target: str | PurePath) -> None: ...
def resolve(self: Self, strict: bool = False) -> Self: ...
def rglob(self: Self, pattern: str) -> Generator[Self, None, None]: ...
def resolve(self, strict: bool = False) -> Self: ...
def rglob(self, pattern: str) -> Generator[Self, None, None]: ...
def rmdir(self) -> None: ...
def symlink_to(self, target: str | Path, target_is_directory: bool = False) -> None: ...
if sys.version_info >= (3, 10):
@@ -185,9 +184,9 @@ class Path(PurePath):
def unlink(self) -> None: ...
@classmethod
def home(cls: type[Self]) -> Self: ...
def absolute(self: Self) -> Self: ...
def expanduser(self: Self) -> Self: ...
def home(cls) -> Self: ...
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: ...
@@ -202,7 +201,7 @@ class Path(PurePath):
def link_to(self, target: StrOrBytesPath) -> None: ...
if sys.version_info >= (3, 12):
def walk(
self: Self, top_down: bool = ..., on_error: Callable[[OSError], object] | None = ..., follow_symlinks: bool = ...
self, top_down: bool = ..., on_error: Callable[[OSError], object] | None = ..., follow_symlinks: bool = ...
) -> Iterator[tuple[Self, list[str], list[str]]]: ...
class PosixPath(Path, PurePosixPath): ...