massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / pathlib.pyi
1 import sys
2 from _typeshed import (
3     OpenBinaryMode,
4     OpenBinaryModeReading,
5     OpenBinaryModeUpdating,
6     OpenBinaryModeWriting,
7     OpenTextMode,
8     Self,
9     StrPath,
10 )
11 from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
12 from os import PathLike, stat_result
13 from types import TracebackType
14 from typing import IO, Any, BinaryIO, Generator, Sequence, Tuple, Type, TypeVar, overload
15 from typing_extensions import Literal
16
17 if sys.version_info >= (3, 9):
18     from types import GenericAlias
19
20 _P = TypeVar("_P", bound=PurePath)
21
22 class PurePath(PathLike[str]):
23     parts: Tuple[str, ...]
24     drive: str
25     root: str
26     anchor: str
27     name: str
28     suffix: str
29     suffixes: list[str]
30     stem: str
31     def __new__(cls: Type[_P], *args: StrPath) -> _P: ...
32     def __hash__(self) -> int: ...
33     def __lt__(self, other: PurePath) -> bool: ...
34     def __le__(self, other: PurePath) -> bool: ...
35     def __gt__(self, other: PurePath) -> bool: ...
36     def __ge__(self, other: PurePath) -> bool: ...
37     def __truediv__(self: _P, key: StrPath) -> _P: ...
38     def __rtruediv__(self: _P, key: StrPath) -> _P: ...
39     def __bytes__(self) -> bytes: ...
40     def as_posix(self) -> str: ...
41     def as_uri(self) -> str: ...
42     def is_absolute(self) -> bool: ...
43     def is_reserved(self) -> bool: ...
44     if sys.version_info >= (3, 9):
45         def is_relative_to(self, *other: StrPath) -> bool: ...
46     def match(self, path_pattern: str) -> bool: ...
47     def relative_to(self: _P, *other: StrPath) -> _P: ...
48     def with_name(self: _P, name: str) -> _P: ...
49     if sys.version_info >= (3, 9):
50         def with_stem(self: _P, stem: str) -> _P: ...
51     def with_suffix(self: _P, suffix: str) -> _P: ...
52     def joinpath(self: _P, *other: StrPath) -> _P: ...
53     @property
54     def parents(self: _P) -> Sequence[_P]: ...
55     @property
56     def parent(self: _P) -> _P: ...
57     if sys.version_info >= (3, 9):
58         def __class_getitem__(cls, type: Any) -> GenericAlias: ...
59
60 class PurePosixPath(PurePath): ...
61 class PureWindowsPath(PurePath): ...
62
63 class Path(PurePath):
64     def __new__(cls: Type[_P], *args: StrPath, **kwargs: Any) -> _P: ...
65     def __enter__(self: Self) -> Self: ...
66     def __exit__(
67         self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
68     ) -> bool | None: ...
69     @classmethod
70     def cwd(cls: Type[_P]) -> _P: ...
71     if sys.version_info >= (3, 10):
72         def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ...
73         def chmod(self, mode: int, *, follow_symlinks: bool = ...) -> None: ...
74     else:
75         def stat(self) -> stat_result: ...
76         def chmod(self, mode: int) -> None: ...
77     def exists(self) -> bool: ...
78     def glob(self: _P, pattern: str) -> Generator[_P, None, None]: ...
79     def group(self) -> str: ...
80     def is_dir(self) -> bool: ...
81     def is_file(self) -> bool: ...
82     if sys.version_info >= (3, 7):
83         def is_mount(self) -> bool: ...
84     def is_symlink(self) -> bool: ...
85     def is_socket(self) -> bool: ...
86     def is_fifo(self) -> bool: ...
87     def is_block_device(self) -> bool: ...
88     def is_char_device(self) -> bool: ...
89     def iterdir(self: _P) -> Generator[_P, None, None]: ...
90     def lchmod(self, mode: int) -> None: ...
91     def lstat(self) -> stat_result: ...
92     def mkdir(self, mode: int = ..., parents: bool = ..., exist_ok: bool = ...) -> None: ...
93     # Adapted from builtins.open
94     # Text mode: always returns a TextIOWrapper
95     # The Traversable .open in stdlib/importlib/abc.pyi should be kept in sync with this.
96     @overload
97     def open(
98         self,
99         mode: OpenTextMode = ...,
100         buffering: int = ...,
101         encoding: str | None = ...,
102         errors: str | None = ...,
103         newline: str | None = ...,
104     ) -> TextIOWrapper: ...
105     # Unbuffered binary mode: returns a FileIO
106     @overload
107     def open(
108         self, mode: OpenBinaryMode, buffering: Literal[0], encoding: None = ..., errors: None = ..., newline: None = ...
109     ) -> FileIO: ...
110     # Buffering is on: return BufferedRandom, BufferedReader, or BufferedWriter
111     @overload
112     def open(
113         self,
114         mode: OpenBinaryModeUpdating,
115         buffering: Literal[-1, 1] = ...,
116         encoding: None = ...,
117         errors: None = ...,
118         newline: None = ...,
119     ) -> BufferedRandom: ...
120     @overload
121     def open(
122         self,
123         mode: OpenBinaryModeWriting,
124         buffering: Literal[-1, 1] = ...,
125         encoding: None = ...,
126         errors: None = ...,
127         newline: None = ...,
128     ) -> BufferedWriter: ...
129     @overload
130     def open(
131         self,
132         mode: OpenBinaryModeReading,
133         buffering: Literal[-1, 1] = ...,
134         encoding: None = ...,
135         errors: None = ...,
136         newline: None = ...,
137     ) -> BufferedReader: ...
138     # Buffering cannot be determined: fall back to BinaryIO
139     @overload
140     def open(
141         self, mode: OpenBinaryMode, buffering: int, encoding: None = ..., errors: None = ..., newline: None = ...
142     ) -> BinaryIO: ...
143     # Fallback if mode is not specified
144     @overload
145     def open(
146         self, mode: str, buffering: int = ..., encoding: str | None = ..., errors: str | None = ..., newline: str | None = ...
147     ) -> IO[Any]: ...
148     def owner(self) -> str: ...
149     if sys.version_info >= (3, 9):
150         def readlink(self: _P) -> _P: ...
151     if sys.version_info >= (3, 8):
152         def rename(self: _P, target: str | PurePath) -> _P: ...
153         def replace(self: _P, target: str | PurePath) -> _P: ...
154     else:
155         def rename(self, target: str | PurePath) -> None: ...
156         def replace(self, target: str | PurePath) -> None: ...
157     def resolve(self: _P, strict: bool = ...) -> _P: ...
158     def rglob(self: _P, pattern: str) -> Generator[_P, None, None]: ...
159     def rmdir(self) -> None: ...
160     def symlink_to(self, target: str | Path, target_is_directory: bool = ...) -> None: ...
161     if sys.version_info >= (3, 10):
162         def hardlink_to(self, target: str | Path) -> None: ...
163     def touch(self, mode: int = ..., exist_ok: bool = ...) -> None: ...
164     if sys.version_info >= (3, 8):
165         def unlink(self, missing_ok: bool = ...) -> None: ...
166     else:
167         def unlink(self) -> None: ...
168     @classmethod
169     def home(cls: Type[_P]) -> _P: ...
170     def absolute(self: _P) -> _P: ...
171     def expanduser(self: _P) -> _P: ...
172     def read_bytes(self) -> bytes: ...
173     def read_text(self, encoding: str | None = ..., errors: str | None = ...) -> str: ...
174     def samefile(self, other_path: str | bytes | int | Path) -> bool: ...
175     def write_bytes(self, data: bytes) -> int: ...
176     if sys.version_info >= (3, 10):
177         def write_text(
178             self, data: str, encoding: str | None = ..., errors: str | None = ..., newline: str | None = ...
179         ) -> int: ...
180     else:
181         def write_text(self, data: str, encoding: str | None = ..., errors: str | None = ...) -> int: ...
182     if sys.version_info >= (3, 8):
183         def link_to(self, target: StrPath | bytes) -> None: ...
184
185 class PosixPath(Path, PurePosixPath): ...
186 class WindowsPath(Path, PureWindowsPath): ...