massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / gzip.pyi
1 import _compression
2 import sys
3 import zlib
4 from _typeshed import ReadableBuffer, StrOrBytesPath
5 from io import FileIO
6 from typing import Any, Protocol, TextIO, overload
7 from typing_extensions import Literal
8
9 _ReadBinaryMode = Literal["r", "rb"]
10 _WriteBinaryMode = Literal["a", "ab", "w", "wb", "x", "xb"]
11 _OpenTextMode = Literal["rt", "at", "wt", "xt"]
12
13 READ: Literal[1]
14 WRITE: Literal[2]
15
16 class _ReadableFileobj(Protocol):
17     def read(self, __n: int) -> bytes: ...
18     def seek(self, __n: int) -> Any: ...
19     # The following attributes and methods are optional:
20     # name: str
21     # mode: str
22     # def fileno() -> int: ...
23
24 class _WritableFileobj(Protocol):
25     def write(self, __b: bytes) -> Any: ...
26     def flush(self) -> Any: ...
27     # The following attributes and methods are optional:
28     # name: str
29     # mode: str
30     # def fileno() -> int: ...
31
32 @overload
33 def open(
34     filename: StrOrBytesPath | _ReadableFileobj,
35     mode: _ReadBinaryMode = ...,
36     compresslevel: int = ...,
37     encoding: None = ...,
38     errors: None = ...,
39     newline: None = ...,
40 ) -> GzipFile: ...
41 @overload
42 def open(
43     filename: StrOrBytesPath | _WritableFileobj,
44     mode: _WriteBinaryMode,
45     compresslevel: int = ...,
46     encoding: None = ...,
47     errors: None = ...,
48     newline: None = ...,
49 ) -> GzipFile: ...
50 @overload
51 def open(
52     filename: StrOrBytesPath,
53     mode: _OpenTextMode,
54     compresslevel: int = ...,
55     encoding: str | None = ...,
56     errors: str | None = ...,
57     newline: str | None = ...,
58 ) -> TextIO: ...
59 @overload
60 def open(
61     filename: StrOrBytesPath | _ReadableFileobj | _WritableFileobj,
62     mode: str,
63     compresslevel: int = ...,
64     encoding: str | None = ...,
65     errors: str | None = ...,
66     newline: str | None = ...,
67 ) -> GzipFile | TextIO: ...
68
69 class _PaddedFile:
70     file: _ReadableFileobj
71     def __init__(self, f: _ReadableFileobj, prepend: bytes = ...) -> None: ...
72     def read(self, size: int) -> bytes: ...
73     def prepend(self, prepend: bytes = ...) -> None: ...
74     def seek(self, off: int) -> int: ...
75     def seekable(self) -> bool: ...
76
77 if sys.version_info >= (3, 8):
78     class BadGzipFile(OSError): ...
79
80 class GzipFile(_compression.BaseStream):
81     myfileobj: FileIO | None
82     mode: Literal[1, 2]
83     name: str
84     compress: zlib._Compress
85     fileobj: _ReadableFileobj | _WritableFileobj
86     @overload
87     def __init__(
88         self,
89         filename: StrOrBytesPath | None,
90         mode: _ReadBinaryMode,
91         compresslevel: int = ...,
92         fileobj: _ReadableFileobj | None = ...,
93         mtime: float | None = ...,
94     ) -> None: ...
95     @overload
96     def __init__(
97         self,
98         *,
99         mode: _ReadBinaryMode,
100         compresslevel: int = ...,
101         fileobj: _ReadableFileobj | None = ...,
102         mtime: float | None = ...,
103     ) -> None: ...
104     @overload
105     def __init__(
106         self,
107         filename: StrOrBytesPath | None,
108         mode: _WriteBinaryMode,
109         compresslevel: int = ...,
110         fileobj: _WritableFileobj | None = ...,
111         mtime: float | None = ...,
112     ) -> None: ...
113     @overload
114     def __init__(
115         self,
116         *,
117         mode: _WriteBinaryMode,
118         compresslevel: int = ...,
119         fileobj: _WritableFileobj | None = ...,
120         mtime: float | None = ...,
121     ) -> None: ...
122     @overload
123     def __init__(
124         self,
125         filename: StrOrBytesPath | None = ...,
126         mode: str | None = ...,
127         compresslevel: int = ...,
128         fileobj: _ReadableFileobj | _WritableFileobj | None = ...,
129         mtime: float | None = ...,
130     ) -> None: ...
131     @property
132     def filename(self) -> str: ...
133     @property
134     def mtime(self) -> int | None: ...
135     crc: int
136     def write(self, data: ReadableBuffer) -> int: ...
137     def read(self, size: int | None = ...) -> bytes: ...
138     def read1(self, size: int = ...) -> bytes: ...
139     def peek(self, n: int) -> bytes: ...
140     @property
141     def closed(self) -> bool: ...
142     def close(self) -> None: ...
143     def flush(self, zlib_mode: int = ...) -> None: ...
144     def fileno(self) -> int: ...
145     def rewind(self) -> None: ...
146     def readable(self) -> bool: ...
147     def writable(self) -> bool: ...
148     def seekable(self) -> bool: ...
149     def seek(self, offset: int, whence: int = ...) -> int: ...
150     def readline(self, size: int | None = ...) -> bytes: ...
151
152 class _GzipReader(_compression.DecompressReader):
153     def __init__(self, fp: _ReadableFileobj) -> None: ...
154     def read(self, size: int = ...) -> bytes: ...
155
156 if sys.version_info >= (3, 8):
157     def compress(data: bytes, compresslevel: int = ..., *, mtime: float | None = ...) -> bytes: ...
158
159 else:
160     def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
161
162 def decompress(data: bytes) -> bytes: ...