-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add python-gnupg stubs #13465
base: main
Are you sure you want to change the base?
Add python-gnupg stubs #13465
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version = "0.5.*" | ||
upstream_repository = "https://github.com/vsajip/python-gnupg" |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,257 @@ | ||||||||
import logging | ||||||||
import re | ||||||||
from typing import Any | ||||||||
|
||||||||
__version__: Final[str] | ||||||||
__author__: Final[str] | ||||||||
__date__: Final[str] | ||||||||
|
||||||||
from typing import Protocol | ||||||||
|
||||||||
string_types: Final[type[str]] | ||||||||
text_type: Final[type[str]] | ||||||||
path_types: Final[tuple[type[str]]] | ||||||||
|
||||||||
log_everything: bool | ||||||||
logger: logging.Logger | ||||||||
fsencoding: str | ||||||||
|
||||||||
UNSAFE: re.Pattern[Any] = ... | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering this is only defined on some platforms, I would just add |
||||||||
|
||||||||
def shell_quote(s: str) -> str: ... | ||||||||
def no_quote(s: str) -> str: ... | ||||||||
|
||||||||
class _ReadableFile(Protocol): | ||||||||
def read(self, size: int = ..., /) -> bytes: ... | ||||||||
def close(self) -> object: ... | ||||||||
|
||||||||
class StatusHandler: | ||||||||
|
||||||||
on_data_failure: Exception | None = ... | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class Verify(StatusHandler): | ||||||||
TRUST_EXPIRED: Final = 0 | ||||||||
TRUST_UNDEFINED: Final = 1 | ||||||||
TRUST_NEVER: Final = 2 | ||||||||
TRUST_MARGINAL: Final = 3 | ||||||||
TRUST_FULLY: Final = 4 | ||||||||
TRUST_ULTIMATE: Final = 5 | ||||||||
TRUST_LEVELS: Final[dict[str, int]] | ||||||||
GPG_SYSTEM_ERROR_CODES: Final[dict[int, str]] | ||||||||
GPG_ERROR_CODES: Final[dict[int, str]] | ||||||||
returncode: int | None = ... | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def __nonzero__(self) -> bool: ... | ||||||||
def __bool__(self) -> bool: ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class ImportResult(StatusHandler): | ||||||||
|
||||||||
counts: list[str] = ... | ||||||||
returncode: int | None = ... | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def __nonzero__(self) -> bool: ... | ||||||||
def __bool__(self) -> bool: ... | ||||||||
|
||||||||
ok_reason: Final[dict[str, str]] | ||||||||
problem_reason: Final[dict[str, str]] | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
def summary(self) -> str: ... | ||||||||
|
||||||||
ESCAPE_PATTERN: Final[re.Pattern[str]] | ||||||||
BASIC_ESCAPES: Final[dict[str, str]] | ||||||||
|
||||||||
class SendResult(StatusHandler): | ||||||||
|
||||||||
returncode: int | None = ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class SearchKeys(StatusHandler, list[dict[Any, Any]]): | ||||||||
|
||||||||
UID_INDEX: Final = 1 | ||||||||
FIELDS: Final[list[str]] | ||||||||
returncode: int | None | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def get_fields(self, args: Any) -> dict[str, Any]: ... | ||||||||
def pub(self, args: Any) -> None: ... | ||||||||
def uid(self, args: Any) -> None: ... | ||||||||
Comment on lines
+77
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of |
||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class ListKeys(SearchKeys): | ||||||||
|
||||||||
UID_INDEX: int = ... | ||||||||
FIELDS: list[str] = ... | ||||||||
Comment on lines
+84
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def key(self, args: Any) -> None: ... | ||||||||
sec: Any = ... | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
def fpr(self, args: Any) -> None: ... | ||||||||
def grp(self, args: Any) -> None: ... | ||||||||
def sub(self, args: Any) -> None: ... | ||||||||
def ssb(self, args: Any) -> None: ... | ||||||||
def sig(self, args: Any) -> None: ... | ||||||||
|
||||||||
class ScanKeys(ListKeys): | ||||||||
def sub(self, args: Any) -> None: ... | ||||||||
|
||||||||
class TextHandler: ... | ||||||||
|
||||||||
class Crypt(Verify, TextHandler): | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def __nonzero__(self) -> bool: ... | ||||||||
def __bool__(self) -> bool: ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class GenKey(StatusHandler): | ||||||||
|
||||||||
returncode: int | None = ... | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def __nonzero__(self) -> bool: ... | ||||||||
def __bool__(self) -> bool: ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class AddSubkey(StatusHandler): | ||||||||
|
||||||||
returncode: int | None = ... | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def __nonzero__(self) -> bool: ... | ||||||||
def __bool__(self) -> bool: ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class ExportResult(GenKey): | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class DeleteResult(StatusHandler): | ||||||||
|
||||||||
returncode: int | None = ... | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
|
||||||||
problem_reason: dict[str, str] = ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
def __nonzero__(self) -> bool: ... | ||||||||
def __bool__(self) -> bool: ... | ||||||||
|
||||||||
class TrustResult(DeleteResult): ... | ||||||||
|
||||||||
class Sign(StatusHandler, TextHandler): | ||||||||
|
||||||||
returncode: int | None = ... | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def __nonzero__(self) -> bool: ... | ||||||||
def __bool__(self) -> bool: ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
|
||||||||
class AutoLocateKey(StatusHandler): | ||||||||
def __init__(self, gpg: GPG) -> None: ... | ||||||||
def handle_status(self, key: str, value: str) -> None: ... | ||||||||
def pub(self, args: Any) -> None: ... | ||||||||
def uid(self, args: Any) -> None: ... | ||||||||
def sub(self, args: Any) -> None: ... | ||||||||
def fpr(self, args: Any) -> None: ... | ||||||||
|
||||||||
VERSION_RE: Final[re.Pattern[str]] | ||||||||
HEX_DIGITS_RE: Final[re.Pattern[str]] | ||||||||
PUBLIC_KEY_RE: Final[re.Pattern[str]] | ||||||||
|
||||||||
class GPG: | ||||||||
|
||||||||
error_map: None = ... | ||||||||
decode_errors: str = ... | ||||||||
buffer_size: int = ... | ||||||||
result_map: dict[str, Any] = ... | ||||||||
def __init__( | ||||||||
self, | ||||||||
gpgbinary: str = "gpg", | ||||||||
gnupghome: str | None = None, | ||||||||
verbose: bool = False, | ||||||||
use_agent: bool = False, | ||||||||
keyring: str | list[str] | None = None, | ||||||||
options: list[str] | None = None, | ||||||||
secret_keyring: str | list[str] | None = None, | ||||||||
env: dict[str, str] | None = None, | ||||||||
) -> None: ... | ||||||||
def make_args(self, args: list[str], passphrase: str) -> list[str]: ... | ||||||||
def is_valid_file(self, fileobj: Any) -> bool: ... | ||||||||
def sign(self, message: str | bytes, **kwargs: Any) -> Sign: ... | ||||||||
def set_output_without_confirmation(self, args: list[str], output: str) -> None: ... | ||||||||
def is_valid_passphrase(self, passphrase: str) -> bool: ... | ||||||||
def sign_file( | ||||||||
self, | ||||||||
fileobj_or_path: str | _ReadableFile, | ||||||||
keyid: str | None = ..., | ||||||||
passphrase: str | None = ..., | ||||||||
clearsign: bool = ..., | ||||||||
detach: bool = ..., | ||||||||
binary: bool = ..., | ||||||||
output: str | None = ..., | ||||||||
extra_args: list[str] | None = ..., | ||||||||
) -> Sign: ... | ||||||||
def verify(self, data: str | bytes, **kwargs: Any) -> Verify: ... | ||||||||
def verify_file( | ||||||||
self, | ||||||||
fileobj_or_path: str | _ReadableFile, | ||||||||
data_filename: str | None = ..., | ||||||||
close_file: bool = ..., | ||||||||
extra_args: list[str] | None = ..., | ||||||||
) -> Verify: ... | ||||||||
def verify_data(self, sig_filename: str, data: str | bytes, extra_args: list[str] | None = ...) -> Verify: ... | ||||||||
def import_keys( | ||||||||
self, key_data: str | bytes, extra_args: list[str] | None = ..., passphrase: str | None = ... | ||||||||
) -> ImportResult: ... | ||||||||
def import_keys_file(self, key_path: str, **kwargs: Any) -> ImportResult: ... | ||||||||
def recv_keys(self, keyserver: str, *keyids: str, **kwargs: Any) -> ImportResult: ... | ||||||||
def send_keys(self, keyserver: str, *keyids: str, **kwargs: Any) -> SendResult: ... | ||||||||
def delete_keys( | ||||||||
self, | ||||||||
fingerprints: str | list[str], | ||||||||
secret: bool = ..., | ||||||||
passphrase: str | None = ..., | ||||||||
expect_passphrase: bool = ..., | ||||||||
exclamation_mode: bool = ..., | ||||||||
) -> DeleteResult: ... | ||||||||
def export_keys( | ||||||||
self, | ||||||||
keyids: str | list[str], | ||||||||
secret: bool = ..., | ||||||||
armor: bool = ..., | ||||||||
minimal: bool = ..., | ||||||||
passphrase: str | None = ..., | ||||||||
expect_passphrase: bool = ..., | ||||||||
output: str | None = ..., | ||||||||
) -> ExportResult: ... | ||||||||
def list_keys(self, secret: bool = ..., keys: str | list[str] | None = ..., sigs: bool = ...) -> ListKeys: ... | ||||||||
def scan_keys(self, filename: str) -> ScanKeys: ... | ||||||||
def scan_keys_mem(self, key_data: str | bytes) -> ScanKeys: ... | ||||||||
def search_keys(self, query: str, keyserver: str = ..., extra_args: list[str] | None = ...) -> SearchKeys: ... | ||||||||
def auto_locate_key(self, email: str, mechanisms: list[str] | None = ..., **kwargs: Any) -> AutoLocateKey: ... | ||||||||
def gen_key(self, input: str) -> GenKey: ... | ||||||||
def gen_key_input(self, **kwargs: Any) -> str: ... | ||||||||
def add_subkey( | ||||||||
self, master_key: str, master_passphrase: str | None = ..., algorithm: str = ..., usage: str = ..., expire: str = ... | ||||||||
) -> AddSubkey: ... | ||||||||
def encrypt_file( | ||||||||
self, | ||||||||
fileobj_or_path: str | _ReadableFile, | ||||||||
recipients: str | list[str], | ||||||||
sign: str | None = ..., | ||||||||
always_trust: bool = ..., | ||||||||
passphrase: str | None = ..., | ||||||||
armor: bool = ..., | ||||||||
output: str | None = ..., | ||||||||
symmetric: bool = ..., | ||||||||
extra_args: list[str] | None = ..., | ||||||||
) -> Crypt: ... | ||||||||
def encrypt(self, data: str | bytes, recipients: str | list[str], **kwargs: Any) -> Crypt: ... | ||||||||
def decrypt(self, message: str | bytes, **kwargs: Any) -> Crypt: ... | ||||||||
def decrypt_file( | ||||||||
self, | ||||||||
fileobj_or_path: str | _ReadableFile, | ||||||||
always_trust: bool = ..., | ||||||||
passphrase: str | None = ..., | ||||||||
output: str | None = ..., | ||||||||
extra_args: list[str] | None = ..., | ||||||||
) -> Crypt: ... | ||||||||
def get_recipients(self, message: str | bytes, **kwargs: Any) -> list[str]: ... | ||||||||
def get_recipients_file(self, fileobj_or_path: str | _ReadableFile, extra_args: list[str] | None = ...) -> list[str]: ... | ||||||||
def trust_keys(self, fingerprints: str | list[str], trustlevel: str) -> TrustResult: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be combined with the imports above.