Skip to content

Commit e0c728d

Browse files
committed
Fix some errors
1 parent 385776d commit e0c728d

File tree

1 file changed

+55
-42
lines changed

1 file changed

+55
-42
lines changed

gnupg.pyi

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,38 @@
22
This type stub file was generated by pyright.
33
"""
44

5-
from typing import Any
5+
import logging
6+
import re
7+
from typing import Any, Callable
68

79
__version__: str = ...
810
__author__: str = ...
911
__date__: str = ...
1012

1113
from typing import Protocol
1214

13-
class ReadableFile(Protocol):
15+
string_types: type[str] = str
16+
text_type: type[str] = str
17+
path_types: tuple[type[str]] = (str,)
18+
19+
log_everything: bool = ...
20+
logger: logging.Logger = ...
21+
fsencoding: str = ...
22+
23+
UNSAFE: re.Pattern[Any] = ...
24+
25+
def shell_quote(s: str) -> str: ...
26+
def no_quote(s: str) -> str: ...
27+
28+
class _ReadableFile(Protocol):
1429
def read(self, size: int) -> bytes: ...
15-
30+
1631
class StatusHandler:
1732
"""
1833
The base class for handling status messages from `gpg`.
1934
"""
2035

21-
on_data_failure = ...
36+
on_data_failure: Exception | None = ...
2237
def __init__(self, gpg: GPG) -> None:
2338
"""
2439
Initialize an instance.
@@ -54,24 +69,24 @@ class Verify(StatusHandler):
5469
TRUST_LEVELS: dict[str, int] = ...
5570
GPG_SYSTEM_ERROR_CODES: dict[int, str] = ...
5671
GPG_ERROR_CODES: dict[int, str] = ...
57-
returncode = ...
72+
returncode: int | None = ...
5873
def __init__(self, gpg: GPG) -> None: ...
5974
def __nonzero__(self) -> bool: ...
6075

61-
__bool__ = ...
76+
__bool__: Any = ...
6277
def handle_status(self, key: str, value: str) -> None: ...
6378

6479
class ImportResult(StatusHandler):
6580
"""
6681
This class handles status messages during key import.
6782
"""
6883

69-
counts = ...
70-
returncode = ...
84+
counts: list[str] = ...
85+
returncode: int | None = ...
7186
def __init__(self, gpg: GPG) -> None: ...
7287
def __nonzero__(self) -> bool: ...
7388

74-
__bool__ = ...
89+
__bool__: Any = ...
7590
ok_reason: dict[str, str] = ...
7691
problem_reason: dict[str, str] = ...
7792
def handle_status(self, key: str, value: str) -> None: ...
@@ -81,25 +96,25 @@ class ImportResult(StatusHandler):
8196
"""
8297
...
8398

84-
ESCAPE_PATTERN = ...
85-
BASIC_ESCAPES = ...
99+
ESCAPE_PATTERN: re.Pattern[Any] = ...
100+
BASIC_ESCAPES: dict[str, str] = ...
86101

87102
class SendResult(StatusHandler):
88103
"""
89104
This class handles status messages during key sending.
90105
"""
91106

92-
returncode = ...
107+
returncode: int | None = ...
93108
def handle_status(self, key: str, value: str) -> None: ...
94109

95110
class SearchKeys(StatusHandler, list[dict[Any, Any]]):
96111
"""
97112
This class handles status messages during key search.
98113
"""
99114

100-
UID_INDEX = ...
101-
FIELDS = ...
102-
returncode = ...
115+
UID_INDEX: int = ...
116+
FIELDS: list[str] = ...
117+
returncode: int | None = ...
103118
def __init__(self, gpg: GPG) -> None: ...
104119
def get_fields(self, args: Any) -> dict[str, Any]:
105120
"""
@@ -139,15 +154,15 @@ class ListKeys(SearchKeys):
139154
rvk = revocation key
140155
"""
141156

142-
UID_INDEX = ...
143-
FIELDS = ...
157+
UID_INDEX: int = ...
158+
FIELDS: list[str] = ...
144159
def __init__(self, gpg: GPG) -> None: ...
145160
def key(self, args: Any) -> None:
146161
"""
147162
Internal method used to update the instance from a `gpg` status message.
148163
"""
149164
...
150-
sec = ...
165+
sec: Any = ...
151166
def fpr(self, args: Any) -> None:
152167
"""
153168
Internal method used to update the instance from a `gpg` status message.
@@ -191,8 +206,6 @@ class ScanKeys(ListKeys):
191206

192207
class TextHandler: ...
193208

194-
_INVALID_KEY_REASONS = ...
195-
196209
class Crypt(Verify, TextHandler):
197210
"""
198211
This class handles status messages during encryption and decryption.
@@ -201,19 +214,19 @@ class Crypt(Verify, TextHandler):
201214
def __init__(self, gpg: GPG) -> None: ...
202215
def __nonzero__(self) -> bool: ...
203216

204-
__bool__ = ...
217+
__bool__: Any = ...
205218
def handle_status(self, key: str, value: str) -> None: ...
206219

207220
class GenKey(StatusHandler):
208221
"""
209222
This class handles status messages during key generation.
210223
"""
211224

212-
returncode = ...
225+
returncode: int | None = ...
213226
def __init__(self, gpg: GPG) -> None: ...
214227
def __nonzero__(self) -> bool: ...
215228

216-
__bool__ = ...
229+
__bool__: Any = ...
217230
def __str__(self) -> str: ...
218231
def handle_status(self, key: str, value: str) -> None: ...
219232

@@ -222,11 +235,11 @@ class AddSubkey(StatusHandler):
222235
This class handles status messages during subkey addition.
223236
"""
224237

225-
returncode = ...
238+
returncode: int | None = ...
226239
def __init__(self, gpg: GPG) -> None: ...
227240
def __nonzero__(self) -> bool: ...
228241

229-
__bool__ = ...
242+
__bool__: Any = ...
230243
def __str__(self) -> str: ...
231244
def handle_status(self, key: str, value: str) -> None: ...
232245

@@ -242,15 +255,15 @@ class DeleteResult(StatusHandler):
242255
This class handles status messages during key deletion.
243256
"""
244257

245-
returncode = ...
258+
returncode: int | None = ...
246259
def __init__(self, gpg: GPG) -> None: ...
247260
def __str__(self) -> str: ...
248261

249-
problem_reason = ...
262+
problem_reason: dict[str, str] = ...
250263
def handle_status(self, key: str, value: str) -> None: ...
251264
def __nonzero__(self) -> bool: ...
252265

253-
__bool__ = ...
266+
__bool__: Any = ...
254267

255268
class TrustResult(DeleteResult):
256269
"""
@@ -264,11 +277,11 @@ class Sign(StatusHandler, TextHandler):
264277
This class handles status messages during signing.
265278
"""
266279

267-
returncode = ...
280+
returncode: int | None = ...
268281
def __init__(self, gpg: GPG) -> None: ...
269282
def __nonzero__(self) -> bool: ...
270283

271-
__bool__ = ...
284+
__bool__: Any = ...
272285
def handle_status(self, key: str, value: str) -> None: ...
273286

274287
class AutoLocateKey(StatusHandler):
@@ -294,19 +307,19 @@ class AutoLocateKey(StatusHandler):
294307
def sub(self, args: Any) -> None: ...
295308
def fpr(self, args: Any) -> None: ...
296309

297-
VERSION_RE = ...
298-
HEX_DIGITS_RE = ...
299-
PUBLIC_KEY_RE = ...
310+
VERSION_RE: re.Pattern[Any] = ...
311+
HEX_DIGITS_RE: re.Pattern[Any] = ...
312+
PUBLIC_KEY_RE: re.Pattern[Any] = ...
300313

301314
class GPG:
302315
"""
303316
This class provides a high-level programmatic interface for `gpg`.
304317
"""
305318

306-
error_map = ...
307-
decode_errors = ...
308-
buffer_size = ...
309-
result_map = ...
319+
error_map: None = ...
320+
decode_errors: str = ...
321+
buffer_size: int = ...
322+
result_map: dict[str, Any] = ...
310323
def __init__(
311324
self,
312325
gpgbinary: str = ...,
@@ -412,7 +425,7 @@ class GPG:
412425

413426
def sign_file(
414427
self,
415-
fileobj_or_path: str | ReadableFile,
428+
fileobj_or_path: str | _ReadableFile,
416429
keyid: str | None = ...,
417430
passphrase: str | None = ...,
418431
clearsign: bool = ...,
@@ -464,7 +477,7 @@ class GPG:
464477

465478
def verify_file(
466479
self,
467-
fileobj_or_path: str | ReadableFile,
480+
fileobj_or_path: str | _ReadableFile,
468481
data_filename: str | None = ...,
469482
close_file: bool = ...,
470483
extra_args: list[str] | None = ...,
@@ -743,7 +756,7 @@ class GPG:
743756

744757
def encrypt_file(
745758
self,
746-
fileobj_or_path: str | ReadableFile,
759+
fileobj_or_path: str | _ReadableFile,
747760
recipients: str | list[str],
748761
sign: str | None = ...,
749762
always_trust: bool = ...,
@@ -828,7 +841,7 @@ class GPG:
828841

829842
def decrypt_file(
830843
self,
831-
fileobj_or_path: str | ReadableFile,
844+
fileobj_or_path: str | _ReadableFile,
832845
always_trust: bool = ...,
833846
passphrase: str | None = ...,
834847
output: str | None = ...,
@@ -864,7 +877,7 @@ class GPG:
864877
...
865878

866879
def get_recipients_file(
867-
self, fileobj_or_path: str | ReadableFile, extra_args: list[str] | None = ...
880+
self, fileobj_or_path: str | _ReadableFile, extra_args: list[str] | None = ...
868881
) -> list[str]:
869882
"""
870883
Get the list of recipients for an encrypted message in a file or file-like object.

0 commit comments

Comments
 (0)