mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Enable pyi-stubs for several modules and packages
_json, ast, cryptography, curses, fcntl, gc, imaplib, ipaddress, marshal, modulefinder, sre_parse, tempfile GitOrigin-RevId: 026d76a70e3ec228701fc2f521edc5a2c26e7d04
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d957c80d5d
commit
9799019c57
@@ -0,0 +1,7 @@
|
||||
from typing import Any, List, Tuple, Dict, Generic, Tuple
|
||||
|
||||
def encode_basestring_ascii(*args, **kwargs) -> str: ...
|
||||
def scanstring(a, b, *args, **kwargs) -> Tuple[Any, ...]: ...
|
||||
|
||||
class Encoder(object): ...
|
||||
class Scanner(object): ...
|
||||
@@ -0,0 +1,28 @@
|
||||
# Python 2.7 ast
|
||||
|
||||
# Rename typing to _typing, as not to conflict with typing imported
|
||||
# from _ast below when loaded in an unorthodox way by the Dropbox
|
||||
# internal Bazel integration.
|
||||
import typing as _typing
|
||||
from typing import Any, Iterator, Optional, Union
|
||||
|
||||
from _ast import *
|
||||
from _ast import AST, Module
|
||||
|
||||
def parse(source: Union[str, unicode], filename: Union[str, unicode] = ..., mode: Union[str, unicode] = ...) -> Module: ...
|
||||
def copy_location(new_node: AST, old_node: AST) -> AST: ...
|
||||
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
|
||||
def fix_missing_locations(node: AST) -> AST: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> str: ...
|
||||
def increment_lineno(node: AST, n: int = ...) -> AST: ...
|
||||
def iter_child_nodes(node: AST) -> Iterator[AST]: ...
|
||||
def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ...
|
||||
def literal_eval(node_or_string: Union[str, unicode, AST]) -> Any: ...
|
||||
def walk(node: AST) -> Iterator[AST]: ...
|
||||
|
||||
class NodeVisitor():
|
||||
def visit(self, node: AST) -> Any: ...
|
||||
def generic_visit(self, node: AST) -> Any: ...
|
||||
|
||||
class NodeTransformer(NodeVisitor):
|
||||
def generic_visit(self, node: AST) -> Optional[AST]: ...
|
||||
@@ -0,0 +1,86 @@
|
||||
from typing import Any, Union, IO
|
||||
import io
|
||||
from _types import FileDescriptorLike
|
||||
|
||||
FASYNC: int
|
||||
FD_CLOEXEC: int
|
||||
|
||||
DN_ACCESS: int
|
||||
DN_ATTRIB: int
|
||||
DN_CREATE: int
|
||||
DN_DELETE: int
|
||||
DN_MODIFY: int
|
||||
DN_MULTISHOT: int
|
||||
DN_RENAME: int
|
||||
F_DUPFD: int
|
||||
F_EXLCK: int
|
||||
F_GETFD: int
|
||||
F_GETFL: int
|
||||
F_GETLEASE: int
|
||||
F_GETLK: int
|
||||
F_GETLK64: int
|
||||
F_GETOWN: int
|
||||
F_GETSIG: int
|
||||
F_NOTIFY: int
|
||||
F_RDLCK: int
|
||||
F_SETFD: int
|
||||
F_SETFL: int
|
||||
F_SETLEASE: int
|
||||
F_SETLK: int
|
||||
F_SETLK64: int
|
||||
F_SETLKW: int
|
||||
F_SETLKW64: int
|
||||
F_SETOWN: int
|
||||
F_SETSIG: int
|
||||
F_SHLCK: int
|
||||
F_UNLCK: int
|
||||
F_WRLCK: int
|
||||
I_ATMARK: int
|
||||
I_CANPUT: int
|
||||
I_CKBAND: int
|
||||
I_FDINSERT: int
|
||||
I_FIND: int
|
||||
I_FLUSH: int
|
||||
I_FLUSHBAND: int
|
||||
I_GETBAND: int
|
||||
I_GETCLTIME: int
|
||||
I_GETSIG: int
|
||||
I_GRDOPT: int
|
||||
I_GWROPT: int
|
||||
I_LINK: int
|
||||
I_LIST: int
|
||||
I_LOOK: int
|
||||
I_NREAD: int
|
||||
I_PEEK: int
|
||||
I_PLINK: int
|
||||
I_POP: int
|
||||
I_PUNLINK: int
|
||||
I_PUSH: int
|
||||
I_RECVFD: int
|
||||
I_SENDFD: int
|
||||
I_SETCLTIME: int
|
||||
I_SETSIG: int
|
||||
I_SRDOPT: int
|
||||
I_STR: int
|
||||
I_SWROPT: int
|
||||
I_UNLINK: int
|
||||
LOCK_EX: int
|
||||
LOCK_MAND: int
|
||||
LOCK_NB: int
|
||||
LOCK_READ: int
|
||||
LOCK_RW: int
|
||||
LOCK_SH: int
|
||||
LOCK_UN: int
|
||||
LOCK_WRITE: int
|
||||
|
||||
# TODO All these return either int or bytes depending on the value of
|
||||
# cmd (not on the type of arg).
|
||||
def fcntl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ...) -> Any: ...
|
||||
|
||||
# TODO: arg: int or read-only buffer interface or read-write buffer interface
|
||||
def ioctl(fd: FileDescriptorLike, op: int, arg: Union[int, bytes] = ...,
|
||||
mutate_flag: bool = ...) -> Any: ...
|
||||
|
||||
def flock(fd: FileDescriptorLike, op: int) -> None: ...
|
||||
def lockf(fd: FileDescriptorLike, op: int, length: int = ..., start: int = ...,
|
||||
whence: int = ...) -> Any: ...
|
||||
@@ -0,0 +1,29 @@
|
||||
# Stubs for gc
|
||||
|
||||
from typing import Any, List, Tuple
|
||||
|
||||
|
||||
def enable() -> None: ...
|
||||
def disable() -> None: ...
|
||||
def isenabled() -> bool: ...
|
||||
def collect(generation: int = ...) -> int: ...
|
||||
def set_debug(flags: int) -> None: ...
|
||||
def get_debug() -> int: ...
|
||||
def get_objects() -> List[Any]: ...
|
||||
def set_threshold(threshold0: int, threshold1: int = ...,
|
||||
threshold2: int = ...) -> None: ...
|
||||
def get_count() -> Tuple[int, int, int]: ...
|
||||
def get_threshold() -> Tuple[int, int, int]: ...
|
||||
def get_referrers(*objs: Any) -> List[Any]: ...
|
||||
def get_referents(*objs: Any) -> List[Any]: ...
|
||||
def is_tracked(obj: Any) -> bool: ...
|
||||
|
||||
garbage: List[Any]
|
||||
|
||||
DEBUG_STATS: int
|
||||
DEBUG_COLLECTABLE: int
|
||||
DEBUG_UNCOLLECTABLE: int
|
||||
DEBUG_INSTANCES: int
|
||||
DEBUG_OBJECTS: int
|
||||
DEBUG_SAVEALL: int
|
||||
DEBUG_LEAK: int
|
||||
@@ -0,0 +1,63 @@
|
||||
# Source: https://hg.python.org/cpython/file/2.7/Lib/sre_parse.py
|
||||
|
||||
from typing import Any, Dict, Iterable, List, Match, Optional, Pattern as _Pattern, Set, Tuple, Union
|
||||
|
||||
SPECIAL_CHARS: str
|
||||
REPEAT_CHARS: str
|
||||
DIGITS: Set[Any]
|
||||
OCTDIGITS: Set[Any]
|
||||
HEXDIGITS: Set[Any]
|
||||
WHITESPACE: Set[Any]
|
||||
ESCAPES: Dict[str, Tuple[str, int]]
|
||||
CATEGORIES: Dict[str, Union[Tuple[str, str], Tuple[str, List[Tuple[str, str]]]]]
|
||||
FLAGS: Dict[str, int]
|
||||
|
||||
class Pattern:
|
||||
flags: int
|
||||
open: List[int]
|
||||
groups: int
|
||||
groupdict: Dict[str, int]
|
||||
lookbehind: int
|
||||
def __init__(self) -> None: ...
|
||||
def opengroup(self, name: str = ...) -> int: ...
|
||||
def closegroup(self, gid: int) -> None: ...
|
||||
def checkgroup(self, gid: int) -> bool: ...
|
||||
|
||||
|
||||
_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern]
|
||||
_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern]
|
||||
_OpInType = List[Tuple[str, int]]
|
||||
_OpBranchType = Tuple[None, List[SubPattern]]
|
||||
_AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType]
|
||||
_CodeType = Union[str, _AvType]
|
||||
|
||||
class SubPattern:
|
||||
pattern: str
|
||||
data: List[_CodeType]
|
||||
width: Optional[int]
|
||||
def __init__(self, pattern, data: List[_CodeType] = ...) -> None: ...
|
||||
def dump(self, level: int = ...) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __delitem__(self, index: Union[int, slice]) -> None: ...
|
||||
def __getitem__(self, index: Union[int, slice]) -> Union[SubPattern, _CodeType]: ...
|
||||
def __setitem__(self, index: Union[int, slice], code: _CodeType): ...
|
||||
def insert(self, index, code: _CodeType) -> None: ...
|
||||
def append(self, code: _CodeType) -> None: ...
|
||||
def getwidth(self) -> int: ...
|
||||
|
||||
class Tokenizer:
|
||||
string: str
|
||||
index: int
|
||||
def __init__(self, string: str) -> None: ...
|
||||
def match(self, char: str, skip: int = ...) -> int: ...
|
||||
def get(self) -> Optional[str]: ...
|
||||
def tell(self) -> Tuple[int, Optional[str]]: ...
|
||||
def seek(self, index: int) -> None: ...
|
||||
|
||||
def isident(char: str) -> bool: ...
|
||||
def isdigit(char: str) -> bool: ...
|
||||
def isname(name: str) -> bool: ...
|
||||
def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ...
|
||||
_Template = Tuple[List[Tuple[int, int]], List[Optional[int]]]
|
||||
def parse_template(source: str, pattern: _Pattern[Any]) -> _Template: ...
|
||||
def expand_template(template: _Template, match: Match[Any]) -> str: ...
|
||||
@@ -0,0 +1,111 @@
|
||||
from typing import Any, AnyStr, IO, Iterable, Iterator, List, Optional, overload, Text, Tuple, Union
|
||||
from thread import LockType
|
||||
from random import Random
|
||||
|
||||
TMP_MAX: int
|
||||
tempdir: str
|
||||
template: str
|
||||
_name_sequence: Optional[_RandomNameSequence]
|
||||
|
||||
class _RandomNameSequence:
|
||||
characters: str = ...
|
||||
mutex: LockType
|
||||
@property
|
||||
def rng(self) -> Random: ...
|
||||
def __iter__(self) -> _RandomNameSequence: ...
|
||||
def next(self) -> str: ...
|
||||
# from os.path:
|
||||
def normcase(self, path: AnyStr) -> AnyStr: ...
|
||||
|
||||
class _TemporaryFileWrapper(IO[str]):
|
||||
delete: bool
|
||||
file: IO[str]
|
||||
name: Any
|
||||
def __init__(self, file: IO[str], name: Any, delete: bool = ...) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
def __enter__(self) -> _TemporaryFileWrapper: ...
|
||||
def __exit__(self, exc, value, tb) -> Optional[bool]: ...
|
||||
def __getattr__(self, name: unicode) -> Any: ...
|
||||
def close(self) -> None: ...
|
||||
def unlink(self, path: unicode) -> None: ...
|
||||
# These methods don't exist directly on this object, but
|
||||
# are delegated to the underlying IO object through __getattr__.
|
||||
# We need to add them here so that this class is concrete.
|
||||
def __iter__(self) -> Iterator[str]: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def next(self) -> str: ...
|
||||
def read(self, n: int = ...) -> str: ...
|
||||
def readable(self) -> bool: ...
|
||||
def readline(self, limit: int = ...) -> str: ...
|
||||
def readlines(self, hint: int = ...) -> List[str]: ...
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
def write(self, s: Text) -> int: ...
|
||||
def writelines(self, lines: Iterable[str]) -> None: ...
|
||||
|
||||
|
||||
# TODO text files
|
||||
|
||||
def TemporaryFile(
|
||||
mode: Union[bytes, unicode] = ...,
|
||||
bufsize: int = ...,
|
||||
suffix: Union[bytes, unicode] = ...,
|
||||
prefix: Union[bytes, unicode] = ...,
|
||||
dir: Union[bytes, unicode] = ...
|
||||
) -> _TemporaryFileWrapper:
|
||||
...
|
||||
|
||||
def NamedTemporaryFile(
|
||||
mode: Union[bytes, unicode] = ...,
|
||||
bufsize: int = ...,
|
||||
suffix: Union[bytes, unicode] = ...,
|
||||
prefix: Union[bytes, unicode] = ...,
|
||||
dir: Union[bytes, unicode] = ...,
|
||||
delete: bool = ...
|
||||
) -> _TemporaryFileWrapper:
|
||||
...
|
||||
|
||||
def SpooledTemporaryFile(
|
||||
max_size: int = ...,
|
||||
mode: Union[bytes, unicode] = ...,
|
||||
buffering: int = ...,
|
||||
suffix: Union[bytes, unicode] = ...,
|
||||
prefix: Union[bytes, unicode] = ...,
|
||||
dir: Union[bytes, unicode] = ...
|
||||
) -> _TemporaryFileWrapper:
|
||||
...
|
||||
|
||||
class TemporaryDirectory:
|
||||
name: Any
|
||||
def __init__(self,
|
||||
suffix: Union[bytes, unicode] = ...,
|
||||
prefix: Union[bytes, unicode] = ...,
|
||||
dir: Union[bytes, unicode] = ...) -> None: ...
|
||||
def cleanup(self) -> None: ...
|
||||
def __enter__(self) -> Any: ... # Can be str or unicode
|
||||
def __exit__(self, type, value, traceback) -> None: ...
|
||||
|
||||
@overload
|
||||
def mkstemp() -> Tuple[int, str]: ...
|
||||
@overload
|
||||
def mkstemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: Optional[AnyStr] = ...,
|
||||
text: bool = ...) -> Tuple[int, AnyStr]: ...
|
||||
@overload
|
||||
def mkdtemp() -> str: ...
|
||||
@overload
|
||||
def mkdtemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: Optional[AnyStr] = ...) -> AnyStr: ...
|
||||
@overload
|
||||
def mktemp() -> str: ...
|
||||
@overload
|
||||
def mktemp(suffix: AnyStr = ..., prefix: AnyStr = ..., dir: Optional[AnyStr] = ...) -> AnyStr: ...
|
||||
def gettempdir() -> str: ...
|
||||
def gettempprefix() -> str: ...
|
||||
|
||||
def _candidate_tempdir_list() -> List[str]: ...
|
||||
def _get_candidate_names() -> Optional[_RandomNameSequence]: ...
|
||||
def _get_default_tempdir() -> str: ...
|
||||
@@ -0,0 +1,15 @@
|
||||
from _curses import * # noqa: F403
|
||||
from _curses import _CursesWindow as _CursesWindow
|
||||
from typing import TypeVar, Callable, Any
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
# available after calling `curses.initscr()`
|
||||
LINES: int
|
||||
COLS: int
|
||||
|
||||
# available after calling `curses.start_color()`
|
||||
COLORS: int
|
||||
COLOR_PAIRS: int
|
||||
|
||||
def wrapper(__func: Callable[..., _T], *arg: Any, **kwds: Any) -> _T: ...
|
||||
@@ -0,0 +1,62 @@
|
||||
from typing import List, Union, overload, TypeVar
|
||||
|
||||
_Ch = TypeVar('_Ch', str, int)
|
||||
|
||||
NUL: int
|
||||
SOH: int
|
||||
STX: int
|
||||
ETX: int
|
||||
EOT: int
|
||||
ENQ: int
|
||||
ACK: int
|
||||
BEL: int
|
||||
BS: int
|
||||
TAB: int
|
||||
HT: int
|
||||
LF: int
|
||||
NL: int
|
||||
VT: int
|
||||
FF: int
|
||||
CR: int
|
||||
SO: int
|
||||
SI: int
|
||||
DLE: int
|
||||
DC1: int
|
||||
DC2: int
|
||||
DC3: int
|
||||
DC4: int
|
||||
NAK: int
|
||||
SYN: int
|
||||
ETB: int
|
||||
CAN: int
|
||||
EM: int
|
||||
SUB: int
|
||||
ESC: int
|
||||
FS: int
|
||||
GS: int
|
||||
RS: int
|
||||
US: int
|
||||
SP: int
|
||||
DEL: int
|
||||
|
||||
controlnames: List[int]
|
||||
|
||||
def isalnum(c: Union[str, int]) -> bool: ...
|
||||
def isalpha(c: Union[str, int]) -> bool: ...
|
||||
def isascii(c: Union[str, int]) -> bool: ...
|
||||
def isblank(c: Union[str, int]) -> bool: ...
|
||||
def iscntrl(c: Union[str, int]) -> bool: ...
|
||||
def isdigit(c: Union[str, int]) -> bool: ...
|
||||
def isgraph(c: Union[str, int]) -> bool: ...
|
||||
def islower(c: Union[str, int]) -> bool: ...
|
||||
def isprint(c: Union[str, int]) -> bool: ...
|
||||
def ispunct(c: Union[str, int]) -> bool: ...
|
||||
def isspace(c: Union[str, int]) -> bool: ...
|
||||
def isupper(c: Union[str, int]) -> bool: ...
|
||||
def isxdigit(c: Union[str, int]) -> bool: ...
|
||||
def isctrl(c: Union[str, int]) -> bool: ...
|
||||
def ismeta(c: Union[str, int]) -> bool: ...
|
||||
def ascii(c: _Ch) -> _Ch: ...
|
||||
def ctrl(c: _Ch) -> _Ch: ...
|
||||
def alt(c: _Ch) -> _Ch: ...
|
||||
def unctrl(c: Union[str, int]) -> str: ...
|
||||
@@ -0,0 +1,20 @@
|
||||
from _curses import _CursesWindow
|
||||
|
||||
class _Curses_Panel: # type is <class '_curses_panel.curses panel'> (note the space in the class name)
|
||||
def above(self) -> _Curses_Panel: ...
|
||||
def below(self) -> _Curses_Panel: ...
|
||||
def bottom(self) -> None: ...
|
||||
def hidden(self) -> bool: ...
|
||||
def hide(self) -> None: ...
|
||||
def move(self, y: int, x: int) -> None: ...
|
||||
def replace(self, win: _CursesWindow) -> None: ...
|
||||
def set_userptr(self, obj: object) -> None: ...
|
||||
def show(self) -> None: ...
|
||||
def top(self) -> None: ...
|
||||
def userptr(self) -> object: ...
|
||||
def window(self) -> _CursesWindow: ...
|
||||
|
||||
def bottom_panel() -> _Curses_Panel: ...
|
||||
def new_panel(__win: _CursesWindow) -> _Curses_Panel: ...
|
||||
def top_panel() -> _Curses_Panel: ...
|
||||
def update_panels() -> _Curses_Panel: ...
|
||||
@@ -0,0 +1,11 @@
|
||||
from _curses import _CursesWindow
|
||||
from typing import Callable, Optional, Union
|
||||
|
||||
def rectangle(win: _CursesWindow, uly: int, ulx: int, lry: int, lrx: int) -> None: ...
|
||||
|
||||
class Textbox:
|
||||
stripspaces: bool
|
||||
def __init__(self, win: _CursesWindow, insert_mode: bool = ...) -> None: ...
|
||||
def edit(self, validate: Optional[Callable[[int], int]] = ...) -> str: ...
|
||||
def do_command(self, ch: Union[str, int]) -> None: ...
|
||||
def gather(self) -> str: ...
|
||||
@@ -0,0 +1,146 @@
|
||||
import imaplib
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from socket import socket as _socket
|
||||
from ssl import SSLSocket, SSLContext
|
||||
from typing import Any, Callable, Dict, IO, List, Optional, Pattern, Text, Tuple, Type, Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
# TODO: Commands should use their actual return types, not this type alias.
|
||||
# E.g. Tuple[Literal["OK"], List[bytes]]
|
||||
_CommandResults = Tuple[str, List[Any]]
|
||||
|
||||
_AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]]
|
||||
|
||||
class IMAP4:
|
||||
error: Type[Exception] = ...
|
||||
abort: Type[Exception] = ...
|
||||
readonly: Type[Exception] = ...
|
||||
mustquote: Pattern[Text] = ...
|
||||
debug: int = ...
|
||||
state: str = ...
|
||||
literal: Optional[Text] = ...
|
||||
tagged_commands: Dict[bytes, Optional[List[bytes]]]
|
||||
untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]]
|
||||
continuation_response: str = ...
|
||||
is_readonly: bool = ...
|
||||
tagnum: int = ...
|
||||
tagpre: str = ...
|
||||
tagre: Pattern[Text] = ...
|
||||
welcome: bytes = ...
|
||||
capabilities: Tuple[str] = ...
|
||||
PROTOCOL_VERSION: str = ...
|
||||
def __init__(self, host: str = ..., port: int = ...) -> None: ...
|
||||
def __getattr__(self, attr: str) -> Any: ...
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
sock: _socket = ...
|
||||
file: Union[IO[Text], IO[bytes]] = ...
|
||||
def open(self, host: str = ..., port: int = ...) -> None: ...
|
||||
def read(self, size: int) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
def send(self, data: bytes) -> None: ...
|
||||
def shutdown(self) -> None: ...
|
||||
def socket(self) -> _socket: ...
|
||||
def recent(self) -> _CommandResults: ...
|
||||
def response(self, code: str) -> _CommandResults: ...
|
||||
def append(self, mailbox: str, flags: str, date_time: str, message: str) -> str: ...
|
||||
def authenticate(self, mechanism: str, authobject: Callable[[bytes], Optional[bytes]]) -> Tuple[str, str]: ...
|
||||
def capability(self) -> _CommandResults: ...
|
||||
def check(self) -> _CommandResults: ...
|
||||
def close(self) -> _CommandResults: ...
|
||||
def copy(self, message_set: str, new_mailbox: str) -> _CommandResults: ...
|
||||
def create(self, mailbox: str) -> _CommandResults: ...
|
||||
def delete(self, mailbox: str) -> _CommandResults: ...
|
||||
def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def enable(self, capability: str) -> _CommandResults: ...
|
||||
def __enter__(self) -> IMAP4: ...
|
||||
def __exit__(self, *args) -> None: ...
|
||||
def expunge(self) -> _CommandResults: ...
|
||||
def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ...
|
||||
def getacl(self, mailbox: str) -> _CommandResults: ...
|
||||
def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ...
|
||||
def getquota(self, root: str) -> _CommandResults: ...
|
||||
def getquotaroot(self, mailbox: str) -> _CommandResults: ...
|
||||
def list(self, directory: str = ..., pattern: str = ...) -> Tuple[str, _AnyResponseData]: ...
|
||||
def login(self, user: str, password: str) -> Tuple[Literal["OK"], List[bytes]]: ...
|
||||
def login_cram_md5(self, user: str, password: str) -> _CommandResults: ...
|
||||
def logout(self) -> Tuple[str, _AnyResponseData]: ...
|
||||
def lsub(self, directory: str = ..., pattern: str = ...) -> _CommandResults: ...
|
||||
def myrights(self, mailbox: str) -> _CommandResults: ...
|
||||
def namespace(self) -> _CommandResults: ...
|
||||
def noop(self) -> Tuple[str, List[bytes]]: ...
|
||||
def partial(self, message_num: str, message_part: str, start: str, length: str) -> _CommandResults: ...
|
||||
def proxyauth(self, user: str) -> _CommandResults: ...
|
||||
def rename(self, oldmailbox: str, newmailbox: str) -> _CommandResults: ...
|
||||
def search(self, charset: Optional[str], *criteria: str) -> _CommandResults: ...
|
||||
def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[Optional[bytes]]]: ...
|
||||
def setacl(self, mailbox: str, who: str, what: str) -> _CommandResults: ...
|
||||
def setannotation(self, *args: str) -> _CommandResults: ...
|
||||
def setquota(self, root: str, limits: str) -> _CommandResults: ...
|
||||
def sort(self, sort_criteria: str, charset: str, *search_criteria: str) -> _CommandResults: ...
|
||||
if sys.version_info >= (3,):
|
||||
def starttls(self, ssl_context: Optional[Any] = ...) -> Tuple[Literal["OK"], List[None]]: ...
|
||||
def status(self, mailbox: str, names: str) -> _CommandResults: ...
|
||||
def store(self, message_set: str, command: str, flags: str) -> _CommandResults: ...
|
||||
def subscribe(self, mailbox: str) -> _CommandResults: ...
|
||||
def thread(self, threading_algorithm: str, charset: str, *search_criteria: str) -> _CommandResults: ...
|
||||
def uid(self, command: str, *args: str) -> _CommandResults: ...
|
||||
def unsubscribe(self, mailbox: str) -> _CommandResults: ...
|
||||
def xatom(self, name: str, *args: str) -> _CommandResults: ...
|
||||
def print_log(self) -> None: ...
|
||||
|
||||
class IMAP4_SSL(IMAP4):
|
||||
keyfile: str = ...
|
||||
certfile: str = ...
|
||||
if sys.version_info >= (3, 3):
|
||||
def __init__(self, host: str = ..., port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ..., ssl_context: Optional[SSLContext] = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, host: str = ..., port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ...) -> None: ...
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
sock: _socket = ...
|
||||
sslobj: SSLSocket = ...
|
||||
file: IO[Any] = ...
|
||||
def open(self, host: str = ..., port: Optional[int] = ...) -> None: ...
|
||||
def read(self, size: int) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
def send(self, data: bytes) -> None: ...
|
||||
def shutdown(self) -> None: ...
|
||||
def socket(self) -> _socket: ...
|
||||
def ssl(self) -> SSLSocket: ...
|
||||
|
||||
|
||||
class IMAP4_stream(IMAP4):
|
||||
command: str = ...
|
||||
def __init__(self, command: str) -> None: ...
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
sock: _socket = ...
|
||||
file: IO[Any] = ...
|
||||
process: subprocess.Popen[bytes] = ...
|
||||
writefile: IO[Any] = ...
|
||||
readfile: IO[Any] = ...
|
||||
def open(self, host: str = ..., port: Optional[int] = ...) -> None: ...
|
||||
def read(self, size: int) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
def send(self, data: bytes) -> None: ...
|
||||
def shutdown(self) -> None: ...
|
||||
|
||||
class _Authenticator:
|
||||
mech: Callable[[bytes], bytes] = ...
|
||||
def __init__(self, mechinst: Callable[[bytes], bytes]) -> None: ...
|
||||
def process(self, data: str) -> str: ...
|
||||
def encode(self, inp: bytes) -> str: ...
|
||||
def decode(self, inp: str) -> bytes: ...
|
||||
|
||||
def Internaldate2tuple(resp: str) -> time.struct_time: ...
|
||||
def Int2AP(num: int) -> str: ...
|
||||
def ParseFlags(resp: str) -> Tuple[str]: ...
|
||||
def Time2Internaldate(date_time: Union[float, time.struct_time, str]) -> str: ...
|
||||
@@ -0,0 +1,8 @@
|
||||
from typing import Any, IO
|
||||
|
||||
version: int
|
||||
|
||||
def dump(__value: Any, __file: IO[Any], __version: int = ...) -> None: ...
|
||||
def load(__file: IO[Any]) -> Any: ...
|
||||
def dumps(__value: Any, __version: int = ...) -> bytes: ...
|
||||
def loads(__bytes: bytes) -> Any: ...
|
||||
@@ -0,0 +1,58 @@
|
||||
import sys
|
||||
from typing import Optional, Container, Dict, Sequence, Tuple, List, Any, Iterator, IO, Iterable
|
||||
from types import CodeType
|
||||
|
||||
LOAD_CONST: int # undocumented
|
||||
IMPORT_NAME: int # undocumented
|
||||
STORE_NAME: int # undocumented
|
||||
STORE_GLOBAL: int # undocumented
|
||||
STORE_OPS: Tuple[int, int] # undocumented
|
||||
EXTENDED_ARG: int # undocumented
|
||||
|
||||
packagePathMap: Dict[str, List[str]] # undocumented
|
||||
def AddPackagePath(packagename: str, path: str) -> None: ...
|
||||
replacePackageMap: Dict[str, str] # undocumented
|
||||
def ReplacePackage(oldname: str, newname: str) -> None: ...
|
||||
|
||||
class Module: # undocumented
|
||||
|
||||
def __init__(self, name: str, file: Optional[str] = ..., path: Optional[str] = ...) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
|
||||
class ModuleFinder:
|
||||
|
||||
modules: Dict[str, Module]
|
||||
path: List[str] # undocumented
|
||||
badmodules: Dict[str, Dict[str, int]] # undocumented
|
||||
debug: int # undocumented
|
||||
indent: int # undocumented
|
||||
excludes: Container[str] # undocumented
|
||||
replace_paths: Sequence[Tuple[str, str]] # undocumented
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def __init__(self, path: Optional[List[str]] = ..., debug: int = ..., excludes: Optional[Container[str]] = ..., replace_paths: Optional[Sequence[Tuple[str, str]]] = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, path: Optional[List[str]] = ..., debug: int = ..., excludes: Container[str] = ..., replace_paths: Sequence[Tuple[str, str]] = ...) -> None: ...
|
||||
def msg(self, level: int, str: str, *args: Any) -> None: ... # undocumented
|
||||
def msgin(self, *args: Any) -> None: ... # undocumented
|
||||
def msgout(self, *args: Any) -> None: ... # undocumented
|
||||
def run_script(self, pathname: str) -> None: ...
|
||||
def load_file(self, pathname: str) -> None: ... # undocumented
|
||||
def import_hook(self, name: str, caller: Optional[Module] = ..., fromlist: Optional[List[str]] = ..., level: int = ...) -> Optional[Module]: ... # undocumented
|
||||
def determine_parent(self, caller: Optional[Module], level: int = ...) -> Optional[Module]: ... # undocumented
|
||||
def find_head_package(self, parent: Module, name: str) -> Tuple[Module, str]: ... # undocumented
|
||||
def load_tail(self, q: Module, tail: str) -> Module: ... # undocumented
|
||||
def ensure_fromlist(self, m: Module, fromlist: Iterable[str], recursive: int = ...) -> None: ... # undocumented
|
||||
def find_all_submodules(self, m: Module) -> Iterable[str]: ... # undocumented
|
||||
def import_module(self, partname: str, fqname: str, parent: Module) -> Optional[Module]: ... # undocumented
|
||||
def load_module(self, fqname: str, fp: IO[str], pathname: str, file_info: Tuple[str, str, str]) -> Module: ... # undocumented
|
||||
if sys.version_info >= (3, 6):
|
||||
def scan_opcodes(self, co: CodeType) -> Iterator[Tuple[str, Tuple[Any, ...]]]: ... # undocumented
|
||||
def scan_code(self, co: CodeType, m: Module) -> None: ... # undocumented
|
||||
def load_package(self, fqname: str, pathname: str) -> Module: ... # undocumented
|
||||
def add_module(self, fqname: str) -> Module: ... # undocumented
|
||||
def find_module(self, name: str, path: Optional[str], parent: Optional[Module] = ...) -> Tuple[Optional[IO[Any]], Optional[str], Tuple[str, str, int]]: ... # undocumented
|
||||
def report(self) -> None: ...
|
||||
def any_missing(self) -> List[str]: ... # undocumented
|
||||
def any_missing_maybe(self) -> Tuple[List[str], List[str]]: ... # undocumented
|
||||
def replace_paths_in_code(self, co: CodeType) -> CodeType: ... # undocumented
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Stub file for the '_json' module."""
|
||||
|
||||
from typing import Any, Tuple, Optional, Dict, Callable
|
||||
|
||||
class make_encoder:
|
||||
sort_keys: Any
|
||||
skipkeys: Any
|
||||
key_separator: Any
|
||||
indent: Any
|
||||
markers: Any
|
||||
default: Any
|
||||
encoder: Any
|
||||
item_separator: Any
|
||||
def __init__(self, markers: Optional[Dict[int, Any]], default: Callable[[Any], Any], encoder: Callable[[str], str],
|
||||
indent: Optional[int], key_separator: str, item_separator: str, sort_keys: bool, skipkeys: bool,
|
||||
allow_nan: bool) -> None: ...
|
||||
def __call__(self, obj: object, _current_indent_level: int) -> Any: ...
|
||||
|
||||
class make_scanner:
|
||||
object_hook: Any
|
||||
object_pairs_hook: Any
|
||||
parse_int: Any
|
||||
parse_constant: Any
|
||||
parse_float: Any
|
||||
strict: bool
|
||||
# TODO: 'context' needs the attrs above (ducktype), but not __call__.
|
||||
def __init__(self, context: make_scanner) -> None: ...
|
||||
def __call__(self, string: str, index: int) -> Tuple[Any, int]: ...
|
||||
|
||||
def encode_basestring_ascii(s: str) -> str: ...
|
||||
def scanstring(string: str, end: int, strict: bool = ...) -> Tuple[str, int]: ...
|
||||
@@ -0,0 +1,76 @@
|
||||
import sys
|
||||
# Rename typing to _typing, as not to conflict with typing imported
|
||||
# from _ast below when loaded in an unorthodox way by the Dropbox
|
||||
# internal Bazel integration.
|
||||
import typing as _typing
|
||||
from typing import Any, Iterator, Optional, TypeVar, Union, overload
|
||||
|
||||
# The same unorthodox Bazel integration causes issues with sys, which
|
||||
# is imported in both modules. unfortunately we can't just rename sys,
|
||||
# since mypy only supports version checks with a sys that is named
|
||||
# sys.
|
||||
from _ast import * # type: ignore
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
class NodeVisitor:
|
||||
def visit(self, node: AST) -> Any: ...
|
||||
def generic_visit(self, node: AST) -> Any: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def visit_Constant(self, node: Constant) -> Any: ...
|
||||
|
||||
class NodeTransformer(NodeVisitor):
|
||||
def generic_visit(self, node: AST) -> Optional[AST]: ...
|
||||
|
||||
_T = TypeVar("_T", bound=AST)
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def parse(
|
||||
source: Union[str, bytes],
|
||||
filename: Union[str, bytes] = ...,
|
||||
mode: Literal["exec"] = ...,
|
||||
*,
|
||||
type_comments: bool = ...,
|
||||
feature_version: Union[None, int, _typing.Tuple[int, int]] = ...,
|
||||
) -> Module: ...
|
||||
@overload
|
||||
def parse(
|
||||
source: Union[str, bytes],
|
||||
filename: Union[str, bytes] = ...,
|
||||
mode: str = ...,
|
||||
*,
|
||||
type_comments: bool = ...,
|
||||
feature_version: Union[None, int, _typing.Tuple[int, int]] = ...,
|
||||
) -> AST: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: Literal["exec"] = ...) -> Module: ...
|
||||
@overload
|
||||
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
def unparse(ast_obj: AST) -> str: ...
|
||||
|
||||
def copy_location(new_node: _T, old_node: AST) -> _T: ...
|
||||
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
|
||||
def fix_missing_locations(node: _T) -> _T: ...
|
||||
def get_docstring(node: AST, clean: bool = ...) -> str: ...
|
||||
def increment_lineno(node: _T, n: int = ...) -> _T: ...
|
||||
def iter_child_nodes(node: AST) -> Iterator[AST]: ...
|
||||
def iter_fields(node: AST) -> Iterator[_typing.Tuple[str, Any]]: ...
|
||||
def literal_eval(node_or_string: Union[str, AST]) -> Any: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> Optional[str]: ...
|
||||
def walk(node: AST) -> Iterator[AST]: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class Num(Constant): ...
|
||||
class Str(Constant): ...
|
||||
class Bytes(Constant): ...
|
||||
class NameConstant(Constant): ...
|
||||
class Ellipsis(Constant): ...
|
||||
@@ -0,0 +1,120 @@
|
||||
# Stubs for fcntl
|
||||
from array import array
|
||||
from io import IOBase
|
||||
from typing import IO, Any, Union, overload
|
||||
from _types import FileDescriptorLike
|
||||
import sys
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
FASYNC: int
|
||||
FD_CLOEXEC: int
|
||||
DN_ACCESS: int
|
||||
DN_ATTRIB: int
|
||||
DN_CREATE: int
|
||||
DN_DELETE: int
|
||||
DN_MODIFY: int
|
||||
DN_MULTISHOT: int
|
||||
DN_RENAME: int
|
||||
F_DUPFD: int
|
||||
F_DUPFD_CLOEXEC: int
|
||||
F_FULLFSYNC: int
|
||||
F_EXLCK: int
|
||||
F_GETFD: int
|
||||
F_GETFL: int
|
||||
F_GETLEASE: int
|
||||
F_GETLK: int
|
||||
F_GETLK64: int
|
||||
F_GETOWN: int
|
||||
F_NOCACHE: int
|
||||
F_GETSIG: int
|
||||
F_NOTIFY: int
|
||||
F_RDLCK: int
|
||||
F_SETFD: int
|
||||
F_SETFL: int
|
||||
F_SETLEASE: int
|
||||
F_SETLK: int
|
||||
F_SETLK64: int
|
||||
F_SETLKW: int
|
||||
F_SETLKW64: int
|
||||
F_SETOWN: int
|
||||
F_SETSIG: int
|
||||
F_SHLCK: int
|
||||
F_UNLCK: int
|
||||
F_WRLCK: int
|
||||
I_ATMARK: int
|
||||
I_CANPUT: int
|
||||
I_CKBAND: int
|
||||
I_FDINSERT: int
|
||||
I_FIND: int
|
||||
I_FLUSH: int
|
||||
I_FLUSHBAND: int
|
||||
I_GETBAND: int
|
||||
I_GETCLTIME: int
|
||||
I_GETSIG: int
|
||||
I_GRDOPT: int
|
||||
I_GWROPT: int
|
||||
I_LINK: int
|
||||
I_LIST: int
|
||||
I_LOOK: int
|
||||
I_NREAD: int
|
||||
I_PEEK: int
|
||||
I_PLINK: int
|
||||
I_POP: int
|
||||
I_PUNLINK: int
|
||||
I_PUSH: int
|
||||
I_RECVFD: int
|
||||
I_SENDFD: int
|
||||
I_SETCLTIME: int
|
||||
I_SETSIG: int
|
||||
I_SRDOPT: int
|
||||
I_STR: int
|
||||
I_SWROPT: int
|
||||
I_UNLINK: int
|
||||
LOCK_EX: int
|
||||
LOCK_MAND: int
|
||||
LOCK_NB: int
|
||||
LOCK_READ: int
|
||||
LOCK_RW: int
|
||||
LOCK_SH: int
|
||||
LOCK_UN: int
|
||||
LOCK_WRITE: int
|
||||
|
||||
@overload
|
||||
def fcntl(__fd: FileDescriptorLike,
|
||||
__cmd: int,
|
||||
__arg: int = ...) -> int: ...
|
||||
@overload
|
||||
def fcntl(__fd: FileDescriptorLike,
|
||||
__cmd: int,
|
||||
__arg: bytes) -> bytes: ...
|
||||
_ReadOnlyBuffer = bytes
|
||||
_WritableBuffer = Union[bytearray, memoryview, array]
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike,
|
||||
__request: int,
|
||||
__arg: int = ...,
|
||||
__mutate_flag: bool = ...) -> int: ...
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike,
|
||||
__request: int,
|
||||
__arg: _WritableBuffer,
|
||||
__mutate_flag: Literal[True] = ...) -> int: ...
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike,
|
||||
__request: int,
|
||||
__arg: _WritableBuffer,
|
||||
__mutate_flag: Literal[False]) -> bytes: ...
|
||||
@overload
|
||||
def ioctl(__fd: FileDescriptorLike,
|
||||
__request: int,
|
||||
__arg: _ReadOnlyBuffer,
|
||||
__mutate_flag: bool) -> bytes: ...
|
||||
def flock(__fd: FileDescriptorLike, __operation: int) -> None: ...
|
||||
def lockf(__fd: FileDescriptorLike,
|
||||
__cmd: int,
|
||||
__len: int = ...,
|
||||
__start: int = ...,
|
||||
__whence: int = ...) -> Any: ...
|
||||
@@ -0,0 +1,32 @@
|
||||
# Stubs for gc
|
||||
|
||||
import sys
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
|
||||
DEBUG_COLLECTABLE: int
|
||||
DEBUG_LEAK: int
|
||||
DEBUG_SAVEALL: int
|
||||
DEBUG_STATS: int
|
||||
DEBUG_UNCOLLECTABLE: int
|
||||
callbacks: List[Any]
|
||||
garbage: List[Any]
|
||||
|
||||
def collect(generation: int = ...) -> int: ...
|
||||
def disable() -> None: ...
|
||||
def enable() -> None: ...
|
||||
def get_count() -> Tuple[int, int, int]: ...
|
||||
def get_debug() -> int: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_objects(generation: Optional[int] = ...) -> List[Any]: ...
|
||||
else:
|
||||
def get_objects() -> List[Any]: ...
|
||||
def get_referents(*objs: Any) -> List[Any]: ...
|
||||
def get_referrers(*objs: Any) -> List[Any]: ...
|
||||
def get_stats() -> List[Dict[str, Any]]: ...
|
||||
def get_threshold() -> Tuple[int, int, int]: ...
|
||||
def is_tracked(__obj: Any) -> bool: ...
|
||||
def isenabled() -> bool: ...
|
||||
def set_debug(__flags: int) -> None: ...
|
||||
def set_threshold(threshold0: int, threshold1: int = ...,
|
||||
threshold2: int = ...) -> None: ...
|
||||
@@ -0,0 +1,149 @@
|
||||
from typing import (Any, Container, Generic, Iterable, Iterator, Optional,
|
||||
overload, SupportsInt, Text, Tuple, TypeVar)
|
||||
|
||||
# Undocumented length constants
|
||||
IPV4LENGTH: int
|
||||
IPV6LENGTH: int
|
||||
|
||||
_A = TypeVar("_A", IPv4Address, IPv6Address)
|
||||
_N = TypeVar("_N", IPv4Network, IPv6Network)
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def ip_address(address: object) -> Any: ... # morally Union[IPv4Address, IPv6Address]
|
||||
def ip_network(address: object, strict: bool = ...) -> Any: ... # morally Union[IPv4Network, IPv6Network]
|
||||
def ip_interface(address: object) -> Any: ... # morally Union[IPv4Interface, IPv6Interface]
|
||||
|
||||
class _IPAddressBase:
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
def __ge__(self: _T, other: _T) -> bool: ...
|
||||
def __gt__(self: _T, other: _T) -> bool: ...
|
||||
def __le__(self: _T, other: _T) -> bool: ...
|
||||
def __lt__(self: _T, other: _T) -> bool: ...
|
||||
def __ne__(self, other: Any) -> bool: ...
|
||||
@property
|
||||
def compressed(self) -> Text: ...
|
||||
@property
|
||||
def exploded(self) -> Text: ...
|
||||
@property
|
||||
def reverse_pointer(self) -> Text: ...
|
||||
@property
|
||||
def version(self) -> int: ...
|
||||
|
||||
class _BaseAddress(_IPAddressBase, SupportsInt):
|
||||
def __init__(self, address: object) -> None: ...
|
||||
def __add__(self: _T, other: int) -> _T: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __int__(self) -> int: ...
|
||||
def __sub__(self: _T, other: int) -> _T: ...
|
||||
@property
|
||||
def is_global(self) -> bool: ...
|
||||
@property
|
||||
def is_link_local(self) -> bool: ...
|
||||
@property
|
||||
def is_loopback(self) -> bool: ...
|
||||
@property
|
||||
def is_multicast(self) -> bool: ...
|
||||
@property
|
||||
def is_private(self) -> bool: ...
|
||||
@property
|
||||
def is_reserved(self) -> bool: ...
|
||||
@property
|
||||
def is_unspecified(self) -> bool: ...
|
||||
@property
|
||||
def max_prefixlen(self) -> int: ...
|
||||
@property
|
||||
def packed(self) -> bytes: ...
|
||||
|
||||
class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
|
||||
network_address: _A
|
||||
netmask: _A
|
||||
def __init__(self, address: object, strict: bool = ...) -> None: ...
|
||||
def __contains__(self, other: Any) -> bool: ...
|
||||
def __getitem__(self, n: int) -> _A: ...
|
||||
def __iter__(self) -> Iterator[_A]: ...
|
||||
def address_exclude(self: _T, other: _T) -> Iterator[_T]: ...
|
||||
@property
|
||||
def broadcast_address(self) -> _A: ...
|
||||
def compare_networks(self: _T, other: _T) -> int: ...
|
||||
def hosts(self) -> Iterator[_A]: ...
|
||||
@property
|
||||
def is_global(self) -> bool: ...
|
||||
@property
|
||||
def is_link_local(self) -> bool: ...
|
||||
@property
|
||||
def is_loopback(self) -> bool: ...
|
||||
@property
|
||||
def is_multicast(self) -> bool: ...
|
||||
@property
|
||||
def is_private(self) -> bool: ...
|
||||
@property
|
||||
def is_reserved(self) -> bool: ...
|
||||
@property
|
||||
def is_unspecified(self) -> bool: ...
|
||||
@property
|
||||
def max_prefixlen(self) -> int: ...
|
||||
@property
|
||||
def num_addresses(self) -> int: ...
|
||||
def overlaps(self: _T, other: _T) -> bool: ...
|
||||
@property
|
||||
def prefixlen(self) -> int: ...
|
||||
def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ...
|
||||
def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ...
|
||||
@property
|
||||
def with_hostmask(self) -> Text: ...
|
||||
@property
|
||||
def with_netmask(self) -> Text: ...
|
||||
@property
|
||||
def with_prefixlen(self) -> Text: ...
|
||||
@property
|
||||
def hostmask(self) -> _A: ...
|
||||
|
||||
class _BaseInterface(_BaseAddress, Generic[_A, _N]):
|
||||
hostmask: _A
|
||||
netmask: _A
|
||||
network: _N
|
||||
@property
|
||||
def ip(self) -> _A: ...
|
||||
@property
|
||||
def with_hostmask(self) -> Text: ...
|
||||
@property
|
||||
def with_netmask(self) -> Text: ...
|
||||
@property
|
||||
def with_prefixlen(self) -> Text: ...
|
||||
|
||||
class IPv4Address(_BaseAddress): ...
|
||||
class IPv4Network(_BaseNetwork[IPv4Address]): ...
|
||||
class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): ...
|
||||
|
||||
class IPv6Address(_BaseAddress):
|
||||
@property
|
||||
def ipv4_mapped(self) -> Optional[IPv4Address]: ...
|
||||
@property
|
||||
def is_site_local(self) -> bool: ...
|
||||
@property
|
||||
def sixtofour(self) -> Optional[IPv4Address]: ...
|
||||
@property
|
||||
def teredo(self) -> Optional[Tuple[IPv4Address, IPv4Address]]: ...
|
||||
|
||||
class IPv6Network(_BaseNetwork[IPv6Address]):
|
||||
@property
|
||||
def is_site_local(self) -> bool: ...
|
||||
|
||||
class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]): ...
|
||||
|
||||
def v4_int_to_packed(address: int) -> bytes: ...
|
||||
def v6_int_to_packed(address: int) -> bytes: ...
|
||||
@overload
|
||||
def summarize_address_range(first: IPv4Address, last: IPv4Address) -> Iterator[IPv4Network]: ...
|
||||
@overload
|
||||
def summarize_address_range(first: IPv6Address, last: IPv6Address) -> Iterator[IPv6Network]: ...
|
||||
def collapse_addresses(addresses: Iterable[_N]) -> Iterator[_N]: ...
|
||||
@overload
|
||||
def get_mixed_type_key(obj: _A) -> Tuple[int, _A]: ...
|
||||
@overload
|
||||
def get_mixed_type_key(obj: IPv4Network) -> Tuple[int, IPv4Address, IPv4Address]: ...
|
||||
@overload
|
||||
def get_mixed_type_key(obj: IPv6Network) -> Tuple[int, IPv6Address, IPv6Address]: ...
|
||||
|
||||
class AddressValueError(ValueError): ...
|
||||
class NetmaskValueError(ValueError): ...
|
||||
@@ -0,0 +1,102 @@
|
||||
# Source: https://github.com/python/cpython/blob/master/Lib/sre_parse.py
|
||||
|
||||
from typing import (
|
||||
Any, Dict, FrozenSet, Iterable, List, Match,
|
||||
Optional, Pattern as _Pattern, Tuple, Union
|
||||
)
|
||||
import sys
|
||||
from sre_constants import _NamedIntConstant as _NIC, error as _Error
|
||||
|
||||
SPECIAL_CHARS: str
|
||||
REPEAT_CHARS: str
|
||||
DIGITS: FrozenSet[str]
|
||||
OCTDIGITS: FrozenSet[str]
|
||||
HEXDIGITS: FrozenSet[str]
|
||||
ASCIILETTERS: FrozenSet[str]
|
||||
WHITESPACE: FrozenSet[str]
|
||||
ESCAPES: Dict[str, Tuple[_NIC, int]]
|
||||
CATEGORIES: Dict[str, Union[Tuple[_NIC, _NIC], Tuple[_NIC, List[Tuple[_NIC, _NIC]]]]]
|
||||
FLAGS: Dict[str, int]
|
||||
if sys.version_info >= (3, 6):
|
||||
GLOBAL_FLAGS: int
|
||||
|
||||
class Verbose(Exception): ...
|
||||
|
||||
class _State:
|
||||
flags: int
|
||||
groupdict: Dict[str, int]
|
||||
groupwidths: List[Optional[int]]
|
||||
lookbehindgroups: Optional[int]
|
||||
def __init__(self) -> None: ...
|
||||
@property
|
||||
def groups(self) -> int: ...
|
||||
def opengroup(self, name: str = ...) -> int: ...
|
||||
def closegroup(self, gid: int, p: SubPattern) -> None: ...
|
||||
def checkgroup(self, gid: int) -> bool: ...
|
||||
def checklookbehindgroup(self, gid: int, source: Tokenizer) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
State = _State
|
||||
else:
|
||||
Pattern = _State
|
||||
|
||||
|
||||
_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern]
|
||||
_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern]
|
||||
_OpInType = List[Tuple[_NIC, int]]
|
||||
_OpBranchType = Tuple[None, List[SubPattern]]
|
||||
_AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType]
|
||||
_CodeType = Tuple[_NIC, _AvType]
|
||||
|
||||
|
||||
class SubPattern:
|
||||
data: List[_CodeType]
|
||||
width: Optional[int]
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
state: State
|
||||
def __init__(self, state: State, data: Optional[List[_CodeType]] = ...) -> None: ...
|
||||
else:
|
||||
pattern: Pattern
|
||||
def __init__(self, pattern: Pattern, data: Optional[List[_CodeType]] = ...) -> None: ...
|
||||
|
||||
def dump(self, level: int = ...) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __delitem__(self, index: Union[int, slice]) -> None: ...
|
||||
def __getitem__(self, index: Union[int, slice]) -> Union[SubPattern, _CodeType]: ...
|
||||
def __setitem__(self, index: Union[int, slice], code: _CodeType) -> None: ...
|
||||
def insert(self, index: int, code: _CodeType) -> None: ...
|
||||
def append(self, code: _CodeType) -> None: ...
|
||||
def getwidth(self) -> int: ...
|
||||
|
||||
|
||||
class Tokenizer:
|
||||
istext: bool
|
||||
string: Any
|
||||
decoded_string: str
|
||||
index: int
|
||||
next: Optional[str]
|
||||
def __init__(self, string: Any) -> None: ...
|
||||
def match(self, char: str) -> bool: ...
|
||||
def get(self) -> Optional[str]: ...
|
||||
def getwhile(self, n: int, charset: Iterable[str]) -> str: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def getuntil(self, terminator: str, name: str) -> str: ...
|
||||
else:
|
||||
def getuntil(self, terminator: str) -> str: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
@property
|
||||
def pos(self) -> int: ...
|
||||
def tell(self) -> int: ...
|
||||
def seek(self, index: int) -> None: ...
|
||||
def error(self, msg: str, offset: int = ...) -> _Error: ...
|
||||
|
||||
def fix_flags(src: Union[str, bytes], flags: int) -> int: ...
|
||||
_TemplateType = Tuple[List[Tuple[int, int]], List[str]]
|
||||
if sys.version_info >= (3, 8):
|
||||
def parse(str: str, flags: int = ..., state: Optional[State] = ...) -> SubPattern: ...
|
||||
def parse_template(source: str, state: _Pattern[Any]) -> _TemplateType: ...
|
||||
else:
|
||||
def parse(str: str, flags: int = ..., pattern: Optional[Pattern] = ...) -> SubPattern: ...
|
||||
def parse_template(source: str, pattern: _Pattern[Any]) -> _TemplateType: ...
|
||||
def expand_template(template: _TemplateType, match: Match[Any]) -> str: ...
|
||||
@@ -0,0 +1,308 @@
|
||||
# Stubs for tempfile
|
||||
# Ron Murawski <ron@horizonchess.com>
|
||||
|
||||
# based on http://docs.python.org/3.3/library/tempfile.html
|
||||
|
||||
import os
|
||||
import sys
|
||||
from types import TracebackType
|
||||
from typing import Any, AnyStr, Generic, IO, Iterable, Iterator, List, Optional, overload, Tuple, Type, TypeVar, Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
# global variables
|
||||
TMP_MAX: int
|
||||
tempdir: Optional[str]
|
||||
template: str
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T") # for pytype, define typevar in same file as alias
|
||||
if sys.version_info >= (3, 6):
|
||||
_DirT = Union[_T, os.PathLike[_T]]
|
||||
else:
|
||||
_DirT = Union[_T]
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def TemporaryFile(
|
||||
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"],
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> IO[str]: ...
|
||||
@overload
|
||||
def TemporaryFile(
|
||||
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> IO[bytes]: ...
|
||||
@overload
|
||||
def TemporaryFile(
|
||||
mode: str = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> IO[Any]: ...
|
||||
else:
|
||||
@overload
|
||||
def TemporaryFile(
|
||||
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"],
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
) -> IO[str]: ...
|
||||
@overload
|
||||
def TemporaryFile(
|
||||
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
) -> IO[bytes]: ...
|
||||
@overload
|
||||
def TemporaryFile(
|
||||
mode: str = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
) -> IO[Any]: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def NamedTemporaryFile(
|
||||
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"],
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
delete: bool = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> IO[str]: ...
|
||||
@overload
|
||||
def NamedTemporaryFile(
|
||||
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
delete: bool = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> IO[bytes]: ...
|
||||
@overload
|
||||
def NamedTemporaryFile(
|
||||
mode: str = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
delete: bool = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> IO[Any]: ...
|
||||
else:
|
||||
@overload
|
||||
def NamedTemporaryFile(
|
||||
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"],
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
delete: bool = ...,
|
||||
) -> IO[str]: ...
|
||||
@overload
|
||||
def NamedTemporaryFile(
|
||||
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
delete: bool = ...,
|
||||
) -> IO[bytes]: ...
|
||||
@overload
|
||||
def NamedTemporaryFile(
|
||||
mode: str = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[AnyStr] = ...,
|
||||
prefix: Optional[AnyStr] = ...,
|
||||
dir: Optional[_DirT[AnyStr]] = ...,
|
||||
delete: bool = ...,
|
||||
) -> IO[Any]: ...
|
||||
|
||||
# It does not actually derive from IO[AnyStr], but it does implement the
|
||||
# protocol.
|
||||
class SpooledTemporaryFile(IO[AnyStr]):
|
||||
# bytes needs to go first, as default mode is to open as bytes
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def __init__(
|
||||
self: SpooledTemporaryFile[bytes],
|
||||
max_size: int = ...,
|
||||
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[str] = ...,
|
||||
prefix: Optional[str] = ...,
|
||||
dir: Optional[str] = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self: SpooledTemporaryFile[str],
|
||||
max_size: int = ...,
|
||||
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[str] = ...,
|
||||
prefix: Optional[str] = ...,
|
||||
dir: Optional[str] = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
max_size: int = ...,
|
||||
mode: str = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[str] = ...,
|
||||
prefix: Optional[str] = ...,
|
||||
dir: Optional[str] = ...,
|
||||
*,
|
||||
errors: Optional[str] = ...
|
||||
) -> None: ...
|
||||
|
||||
@property
|
||||
def errors(self) -> Optional[str]: ...
|
||||
else:
|
||||
@overload
|
||||
def __init__(
|
||||
self: SpooledTemporaryFile[bytes],
|
||||
max_size: int = ...,
|
||||
mode: Literal["rb", "wb", "ab", "xb", "r+b", "w+b", "a+b", "x+b"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[str] = ...,
|
||||
prefix: Optional[str] = ...,
|
||||
dir: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self: SpooledTemporaryFile[str],
|
||||
max_size: int = ...,
|
||||
mode: Literal["r", "w", "a", "x", "r+", "w+", "a+", "x+", "rt", "wt", "at", "xt", "r+t", "w+t", "a+t", "x+t"] = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[str] = ...,
|
||||
prefix: Optional[str] = ...,
|
||||
dir: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
max_size: int = ...,
|
||||
mode: str = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
suffix: Optional[str] = ...,
|
||||
prefix: Optional[str] = ...,
|
||||
dir: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def rollover(self) -> None: ...
|
||||
def __enter__(self: _S) -> _S: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> Optional[bool]: ...
|
||||
# These methods are copied from the abstract methods of IO, because
|
||||
# SpooledTemporaryFile implements IO.
|
||||
# See also https://github.com/python/typeshed/pull/2452#issuecomment-420657918.
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def read(self, n: int = ...) -> AnyStr: ...
|
||||
def readline(self, limit: int = ...) -> AnyStr: ...
|
||||
def readlines(self, hint: int = ...) -> List[AnyStr]: ...
|
||||
def seek(self, offset: int, whence: int = ...) -> int: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, size: Optional[int] = ...) -> int: ...
|
||||
def write(self, s: AnyStr) -> int: ...
|
||||
def writelines(self, iterable: Iterable[AnyStr]) -> None: ...
|
||||
def __iter__(self) -> Iterator[AnyStr]: ...
|
||||
# Other than the following methods, which do not exist on SpooledTemporaryFile
|
||||
def readable(self) -> bool: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def writable(self) -> bool: ...
|
||||
def __next__(self) -> AnyStr: ...
|
||||
|
||||
class TemporaryDirectory(Generic[AnyStr]):
|
||||
name: str
|
||||
def __init__(
|
||||
self, suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...
|
||||
) -> None: ...
|
||||
def cleanup(self) -> None: ...
|
||||
def __enter__(self) -> AnyStr: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
|
||||
def mkstemp(
|
||||
suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ..., text: bool = ...
|
||||
) -> Tuple[int, AnyStr]: ...
|
||||
@overload
|
||||
def mkdtemp() -> str: ...
|
||||
@overload
|
||||
def mkdtemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
|
||||
def mktemp(suffix: Optional[AnyStr] = ..., prefix: Optional[AnyStr] = ..., dir: Optional[_DirT[AnyStr]] = ...) -> AnyStr: ...
|
||||
def gettempdirb() -> bytes: ...
|
||||
def gettempprefixb() -> bytes: ...
|
||||
def gettempdir() -> str: ...
|
||||
def gettempprefix() -> str: ...
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
from typing import (Any, Container, Generic, Iterable, Iterator, Optional,
|
||||
overload, SupportsInt, Text, Tuple, TypeVar)
|
||||
|
||||
# Undocumented length constants
|
||||
IPV4LENGTH: int
|
||||
IPV6LENGTH: int
|
||||
|
||||
_A = TypeVar("_A", IPv4Address, IPv6Address)
|
||||
_N = TypeVar("_N", IPv4Network, IPv6Network)
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def ip_address(address: object) -> Any: ... # morally Union[IPv4Address, IPv6Address]
|
||||
def ip_network(address: object, strict: bool = ...) -> Any: ... # morally Union[IPv4Network, IPv6Network]
|
||||
def ip_interface(address: object) -> Any: ... # morally Union[IPv4Interface, IPv6Interface]
|
||||
|
||||
class _IPAddressBase:
|
||||
def __eq__(self, other: Any) -> bool: ...
|
||||
def __ge__(self: _T, other: _T) -> bool: ...
|
||||
def __gt__(self: _T, other: _T) -> bool: ...
|
||||
def __le__(self: _T, other: _T) -> bool: ...
|
||||
def __lt__(self: _T, other: _T) -> bool: ...
|
||||
def __ne__(self, other: Any) -> bool: ...
|
||||
@property
|
||||
def compressed(self) -> Text: ...
|
||||
@property
|
||||
def exploded(self) -> Text: ...
|
||||
@property
|
||||
def reverse_pointer(self) -> Text: ...
|
||||
@property
|
||||
def version(self) -> int: ...
|
||||
|
||||
class _BaseAddress(_IPAddressBase, SupportsInt):
|
||||
def __init__(self, address: object) -> None: ...
|
||||
def __add__(self: _T, other: int) -> _T: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __int__(self) -> int: ...
|
||||
def __sub__(self: _T, other: int) -> _T: ...
|
||||
@property
|
||||
def is_global(self) -> bool: ...
|
||||
@property
|
||||
def is_link_local(self) -> bool: ...
|
||||
@property
|
||||
def is_loopback(self) -> bool: ...
|
||||
@property
|
||||
def is_multicast(self) -> bool: ...
|
||||
@property
|
||||
def is_private(self) -> bool: ...
|
||||
@property
|
||||
def is_reserved(self) -> bool: ...
|
||||
@property
|
||||
def is_unspecified(self) -> bool: ...
|
||||
@property
|
||||
def max_prefixlen(self) -> int: ...
|
||||
@property
|
||||
def packed(self) -> bytes: ...
|
||||
|
||||
class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
|
||||
network_address: _A
|
||||
netmask: _A
|
||||
def __init__(self, address: object, strict: bool = ...) -> None: ...
|
||||
def __contains__(self, other: Any) -> bool: ...
|
||||
def __getitem__(self, n: int) -> _A: ...
|
||||
def __iter__(self) -> Iterator[_A]: ...
|
||||
def address_exclude(self: _T, other: _T) -> Iterator[_T]: ...
|
||||
@property
|
||||
def broadcast_address(self) -> _A: ...
|
||||
def compare_networks(self: _T, other: _T) -> int: ...
|
||||
def hosts(self) -> Iterator[_A]: ...
|
||||
@property
|
||||
def is_global(self) -> bool: ...
|
||||
@property
|
||||
def is_link_local(self) -> bool: ...
|
||||
@property
|
||||
def is_loopback(self) -> bool: ...
|
||||
@property
|
||||
def is_multicast(self) -> bool: ...
|
||||
@property
|
||||
def is_private(self) -> bool: ...
|
||||
@property
|
||||
def is_reserved(self) -> bool: ...
|
||||
@property
|
||||
def is_unspecified(self) -> bool: ...
|
||||
@property
|
||||
def max_prefixlen(self) -> int: ...
|
||||
@property
|
||||
def num_addresses(self) -> int: ...
|
||||
def overlaps(self: _T, other: _T) -> bool: ...
|
||||
@property
|
||||
def prefixlen(self) -> int: ...
|
||||
def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ...
|
||||
def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ...
|
||||
@property
|
||||
def with_hostmask(self) -> Text: ...
|
||||
@property
|
||||
def with_netmask(self) -> Text: ...
|
||||
@property
|
||||
def with_prefixlen(self) -> Text: ...
|
||||
@property
|
||||
def hostmask(self) -> _A: ...
|
||||
|
||||
class _BaseInterface(_BaseAddress, Generic[_A, _N]):
|
||||
hostmask: _A
|
||||
netmask: _A
|
||||
network: _N
|
||||
@property
|
||||
def ip(self) -> _A: ...
|
||||
@property
|
||||
def with_hostmask(self) -> Text: ...
|
||||
@property
|
||||
def with_netmask(self) -> Text: ...
|
||||
@property
|
||||
def with_prefixlen(self) -> Text: ...
|
||||
|
||||
class IPv4Address(_BaseAddress): ...
|
||||
class IPv4Network(_BaseNetwork[IPv4Address]): ...
|
||||
class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): ...
|
||||
|
||||
class IPv6Address(_BaseAddress):
|
||||
@property
|
||||
def ipv4_mapped(self) -> Optional[IPv4Address]: ...
|
||||
@property
|
||||
def is_site_local(self) -> bool: ...
|
||||
@property
|
||||
def sixtofour(self) -> Optional[IPv4Address]: ...
|
||||
@property
|
||||
def teredo(self) -> Optional[Tuple[IPv4Address, IPv4Address]]: ...
|
||||
|
||||
class IPv6Network(_BaseNetwork[IPv6Address]):
|
||||
@property
|
||||
def is_site_local(self) -> bool: ...
|
||||
|
||||
class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]): ...
|
||||
|
||||
def v4_int_to_packed(address: int) -> bytes: ...
|
||||
def v6_int_to_packed(address: int) -> bytes: ...
|
||||
@overload
|
||||
def summarize_address_range(first: IPv4Address, last: IPv4Address) -> Iterator[IPv4Network]: ...
|
||||
@overload
|
||||
def summarize_address_range(first: IPv6Address, last: IPv6Address) -> Iterator[IPv6Network]: ...
|
||||
def collapse_addresses(addresses: Iterable[_N]) -> Iterator[_N]: ...
|
||||
@overload
|
||||
def get_mixed_type_key(obj: _A) -> Tuple[int, _A]: ...
|
||||
@overload
|
||||
def get_mixed_type_key(obj: IPv4Network) -> Tuple[int, IPv4Address, IPv4Address]: ...
|
||||
@overload
|
||||
def get_mixed_type_key(obj: IPv6Network) -> Tuple[int, IPv6Address, IPv6Address]: ...
|
||||
|
||||
class AddressValueError(ValueError): ...
|
||||
class NetmaskValueError(ValueError): ...
|
||||
@@ -0,0 +1,7 @@
|
||||
class AlreadyFinalized(Exception): ...
|
||||
class AlreadyUpdated(Exception): ...
|
||||
class InvalidKey(Exception): ...
|
||||
class InvalidSignature(Exception): ...
|
||||
class InvalidTag(Exception): ...
|
||||
class NotYetFinalized(Exception): ...
|
||||
class UnsupportedAlgorithm(Exception): ...
|
||||
@@ -0,0 +1,17 @@
|
||||
from typing import List, Optional
|
||||
|
||||
class InvalidToken(Exception): ...
|
||||
|
||||
class Fernet(object):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
def decrypt(self, token: bytes, ttl: Optional[int] = ...) -> bytes: ...
|
||||
def encrypt(self, data: bytes) -> bytes: ...
|
||||
def extract_timestamp(self, token: bytes) -> int: ...
|
||||
@classmethod
|
||||
def generate_key(cls) -> bytes: ...
|
||||
|
||||
class MultiFernet(object):
|
||||
def __init__(self, fernets: List[Fernet]) -> None: ...
|
||||
def decrypt(self, token: bytes, ttl: Optional[int] = ...) -> bytes: ...
|
||||
def encrypt(self, data: bytes) -> bytes: ...
|
||||
def rotate(self, msg: bytes) -> bytes: ...
|
||||
@@ -0,0 +1,3 @@
|
||||
from typing import Any
|
||||
|
||||
def __getattr__(name: str) -> Any: ...
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
from typing import Any
|
||||
|
||||
def default_backend() -> Any: ...
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from cryptography.hazmat.primitives.asymmetric.dh import (
|
||||
DHParameterNumbers,
|
||||
DHParameters,
|
||||
DHPrivateKey,
|
||||
DHPrivateNumbers,
|
||||
DHPublicKey,
|
||||
DHPublicNumbers,
|
||||
)
|
||||
from cryptography.hazmat.primitives.asymmetric.dsa import (
|
||||
DSAParameterNumbers,
|
||||
DSAParameters,
|
||||
DSAPrivateKey,
|
||||
DSAPrivateNumbers,
|
||||
DSAPublicKey,
|
||||
DSAPublicNumbers,
|
||||
)
|
||||
from cryptography.hazmat.primitives.asymmetric.ec import (
|
||||
EllipticCurve,
|
||||
EllipticCurvePrivateKey,
|
||||
EllipticCurvePrivateNumbers,
|
||||
EllipticCurvePublicKey,
|
||||
EllipticCurvePublicNumbers,
|
||||
EllipticCurveSignatureAlgorithm,
|
||||
)
|
||||
from cryptography.hazmat.primitives.asymmetric.padding import AsymmetricPadding
|
||||
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPrivateNumbers, RSAPublicKey, RSAPublicNumbers
|
||||
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm, CipherAlgorithm, CipherContext
|
||||
from cryptography.hazmat.primitives.ciphers.modes import Mode
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm, HashContext
|
||||
from cryptography.x509 import (
|
||||
Certificate,
|
||||
CertificateBuilder,
|
||||
CertificateRevocationList,
|
||||
CertificateRevocationListBuilder,
|
||||
CertificateSigningRequest,
|
||||
CertificateSigningRequestBuilder,
|
||||
Name,
|
||||
RevokedCertificate,
|
||||
RevokedCertificateBuilder,
|
||||
)
|
||||
|
||||
class CipherBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def cipher_supported(self, cipher: CipherAlgorithm, mode: Mode) -> bool: ...
|
||||
@abstractmethod
|
||||
def create_symmetric_encryption_ctx(self, cipher: CipherAlgorithm, mode: Mode) -> CipherContext: ...
|
||||
@abstractmethod
|
||||
def create_symmetric_decryption_ctx(self, cipher: CipherAlgorithm, mode: Mode) -> CipherContext: ...
|
||||
|
||||
class CMACBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def cmac_algorithm_supported(self, algorithm: BlockCipherAlgorithm) -> bool: ...
|
||||
@abstractmethod
|
||||
def create_cmac_ctx(self, algorithm: BlockCipherAlgorithm) -> Any: ...
|
||||
|
||||
class DERSerializationBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def load_der_parameters(self, data: bytes) -> Any: ...
|
||||
@abstractmethod
|
||||
def load_der_private_key(self, data: bytes, password: Optional[bytes]) -> Any: ...
|
||||
@abstractmethod
|
||||
def load_der_public_key(self, data: bytes) -> Any: ...
|
||||
|
||||
class DHBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def dh_parameters_supported(self, p: int, g: int, q: Optional[int]) -> bool: ...
|
||||
@abstractmethod
|
||||
def dh_x942_serialization_supported(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def generate_dh_parameters(self, generator: int, key_size: int) -> DHParameters: ...
|
||||
@abstractmethod
|
||||
def generate_dh_private_key(self, parameters: DHParameters) -> DHPrivateKey: ...
|
||||
@abstractmethod
|
||||
def generate_dh_private_key_and_parameters(self, generator: int, key_size: int) -> DHPrivateKey: ...
|
||||
@abstractmethod
|
||||
def load_dh_parameter_numbers(self, numbers: DHParameterNumbers) -> DHParameters: ...
|
||||
@abstractmethod
|
||||
def load_dh_private_numbers(self, numbers: DHPrivateNumbers) -> DHPrivateKey: ...
|
||||
@abstractmethod
|
||||
def load_dh_public_numbers(self, numbers: DHPublicNumbers) -> DHPublicKey: ...
|
||||
|
||||
class DSABackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def dsa_hash_supported(self, algorithm: HashAlgorithm) -> bool: ...
|
||||
@abstractmethod
|
||||
def dsa_parameters_supported(self, p: int, q: int, g: int) -> bool: ...
|
||||
@abstractmethod
|
||||
def generate_dsa_parameters(self, key_size: int) -> DSAParameters: ...
|
||||
@abstractmethod
|
||||
def generate_dsa_private_key(self, parameters: DSAParameters) -> DSAPrivateKey: ...
|
||||
@abstractmethod
|
||||
def generate_dsa_private_key_and_parameters(self, key_size: int) -> DSAPrivateKey: ...
|
||||
@abstractmethod
|
||||
def load_dsa_parameter_numbers(self, numbers: DSAParameterNumbers) -> DSAParameters: ...
|
||||
@abstractmethod
|
||||
def load_dsa_private_numbers(self, numbers: DSAPrivateNumbers) -> DSAPrivateKey: ...
|
||||
@abstractmethod
|
||||
def load_dsa_public_numbers(self, numbers: DSAPublicNumbers) -> DSAPublicKey: ...
|
||||
|
||||
class EllipticCurveBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def derive_elliptic_curve_private_key(self, private_value: int, curve: EllipticCurve) -> EllipticCurvePrivateKey: ...
|
||||
@abstractmethod
|
||||
def elliptic_curve_signature_algorithm_supported(
|
||||
self, signature_algorithm: EllipticCurveSignatureAlgorithm, curve: EllipticCurve
|
||||
) -> bool: ...
|
||||
@abstractmethod
|
||||
def elliptic_curve_supported(self, curve: EllipticCurve) -> bool: ...
|
||||
@abstractmethod
|
||||
def generate_elliptic_curve_private_key(self, curve: EllipticCurve) -> EllipticCurvePrivateKey: ...
|
||||
@abstractmethod
|
||||
def load_elliptic_curve_private_numbers(self, numbers: EllipticCurvePrivateNumbers) -> EllipticCurvePrivateKey: ...
|
||||
@abstractmethod
|
||||
def load_elliptic_curve_public_numbers(self, numbers: EllipticCurvePublicNumbers) -> EllipticCurvePublicKey: ...
|
||||
|
||||
class HMACBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def create_hmac_ctx(self, key: bytes, algorithm: HashAlgorithm) -> HashContext: ...
|
||||
@abstractmethod
|
||||
def cmac_algorithm_supported(self, algorithm: HashAlgorithm) -> bool: ...
|
||||
|
||||
class HashBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def create_hash_ctx(self, algorithm: HashAlgorithm) -> HashContext: ...
|
||||
@abstractmethod
|
||||
def hash_supported(self, algorithm: HashAlgorithm) -> bool: ...
|
||||
|
||||
class PBKDF2HMACBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def derive_pbkdf2_hmac(
|
||||
self, algorithm: HashAlgorithm, length: int, salt: bytes, iterations: int, key_material: bytes
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def pbkdf2_hmac_supported(self, algorithm: HashAlgorithm) -> bool: ...
|
||||
|
||||
class PEMSerializationBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def load_pem_parameters(self, data: bytes) -> Any: ...
|
||||
@abstractmethod
|
||||
def load_pem_private_key(self, data: bytes, password: Optional[bytes]) -> Any: ...
|
||||
@abstractmethod
|
||||
def load_pem_public_key(self, data: bytes) -> Any: ...
|
||||
|
||||
class RSABackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def generate_rsa_parameters_supported(self, public_exponent: int, key_size: int) -> bool: ...
|
||||
@abstractmethod
|
||||
def generate_rsa_private_key(self, public_exponent: int, key_size: int) -> RSAPrivateKey: ...
|
||||
@abstractmethod
|
||||
def load_rsa_public_numbers(self, numbers: RSAPublicNumbers) -> RSAPublicKey: ...
|
||||
@abstractmethod
|
||||
def load_rsa_private_numbers(self, numbers: RSAPrivateNumbers) -> RSAPrivateKey: ...
|
||||
@abstractmethod
|
||||
def rsa_padding_supported(self, padding: AsymmetricPadding) -> bool: ...
|
||||
|
||||
class ScryptBackend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def derive_scrypt(self, key_material: bytes, salt: bytes, length: int, n: int, r: int, p: int) -> bytes: ...
|
||||
|
||||
class X509Backend(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def create_x509_certificate(
|
||||
self,
|
||||
builder: CertificateBuilder,
|
||||
private_key: Union[DSAPrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: HashAlgorithm,
|
||||
) -> Certificate: ...
|
||||
@abstractmethod
|
||||
def create_x509_crl(
|
||||
self,
|
||||
builder: CertificateRevocationListBuilder,
|
||||
private_key: Union[DSAPrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: HashAlgorithm,
|
||||
) -> CertificateRevocationList: ...
|
||||
@abstractmethod
|
||||
def create_x509_csr(
|
||||
self,
|
||||
builder: CertificateSigningRequestBuilder,
|
||||
private_key: Union[DSAPrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: HashAlgorithm,
|
||||
) -> CertificateSigningRequest: ...
|
||||
@abstractmethod
|
||||
def create_x509_revoked_certificate(self, builder: RevokedCertificateBuilder) -> RevokedCertificate: ...
|
||||
@abstractmethod
|
||||
def load_der_x509_certificate(self, data: bytes) -> Certificate: ...
|
||||
@abstractmethod
|
||||
def load_der_x509_csr(self, data: bytes) -> CertificateSigningRequest: ...
|
||||
@abstractmethod
|
||||
def load_pem_x509_certificate(self, data: bytes) -> Certificate: ...
|
||||
@abstractmethod
|
||||
def load_pem_x509_csr(self, data: bytes) -> CertificateSigningRequest: ...
|
||||
@abstractmethod
|
||||
def x509_name_bytes(self, name: Name) -> bytes: ...
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
class Binding(object):
|
||||
ffi: Optional[Any]
|
||||
lib: Optional[Any]
|
||||
def init_static_locks(self) -> None: ...
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
from typing import Any
|
||||
|
||||
def __getattr__(name: str) -> Any: ...
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
from typing import Any
|
||||
|
||||
def __getattr__(name: str) -> Any: ...
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import DHBackend
|
||||
from cryptography.hazmat.primitives.serialization import (
|
||||
Encoding,
|
||||
KeySerializationEncryption,
|
||||
ParameterFormat,
|
||||
PrivateFormat,
|
||||
PublicFormat,
|
||||
)
|
||||
|
||||
class DHParameters(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def generate_private_key(self) -> DHPrivateKey: ...
|
||||
@abstractmethod
|
||||
def parameter_bytes(self, encoding: Encoding, format: ParameterFormat) -> bytes: ...
|
||||
@abstractmethod
|
||||
def parameter_numbers(self) -> DHParameterNumbers: ...
|
||||
|
||||
DHParametersWithSerialization = DHParameters
|
||||
|
||||
class DHParameterNumbers(object):
|
||||
@property
|
||||
def p(self) -> int: ...
|
||||
@property
|
||||
def g(self) -> int: ...
|
||||
@property
|
||||
def q(self) -> int: ...
|
||||
def __init__(self, p: int, g: int, q: Optional[int]) -> None: ...
|
||||
def parameters(self, backend: DHBackend) -> DHParameters: ...
|
||||
|
||||
class DHPrivateKey(metaclass=ABCMeta):
|
||||
key_size: int
|
||||
@abstractmethod
|
||||
def exchange(self, peer_public_key: DHPublicKey) -> bytes: ...
|
||||
@abstractmethod
|
||||
def parameters(self) -> DHParameters: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> DHPublicKey: ...
|
||||
|
||||
class DHPrivateKeyWithSerialization(DHPrivateKey):
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def private_numbers(self) -> DHPrivateNumbers: ...
|
||||
|
||||
class DHPrivateNumbers(object):
|
||||
@property
|
||||
def public_numbers(self) -> DHPublicNumbers: ...
|
||||
@property
|
||||
def x(self) -> int: ...
|
||||
def __init__(self, x: int, public_numbers: DHPublicNumbers) -> None: ...
|
||||
def private_key(self, backend: DHBackend) -> DHPrivateKey: ...
|
||||
|
||||
class DHPublicKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@abstractmethod
|
||||
def parameters(self) -> DHParameters: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_numbers(self) -> DHPublicNumbers: ...
|
||||
|
||||
DHPublicKeyWithSerialization = DHPublicKey
|
||||
|
||||
class DHPublicNumbers(object):
|
||||
@property
|
||||
def parameter_numbers(self) -> DHParameterNumbers: ...
|
||||
@property
|
||||
def y(self) -> int: ...
|
||||
def __init__(self, y: int, parameter_numbers: DHParameterNumbers) -> None: ...
|
||||
def public_key(self, backend: DHBackend) -> DHPublicKey: ...
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from typing import Union
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import DSABackend
|
||||
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
|
||||
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
|
||||
|
||||
class DSAParameters(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def generate_private_key(self) -> DSAPrivateKey: ...
|
||||
|
||||
class DSAParametersWithNumbers(DSAParameters):
|
||||
@abstractmethod
|
||||
def parameter_numbers(self) -> DSAParameterNumbers: ...
|
||||
|
||||
class DSAParameterNumbers(object):
|
||||
@property
|
||||
def p(self) -> int: ...
|
||||
@property
|
||||
def q(self) -> int: ...
|
||||
@property
|
||||
def g(self) -> int: ...
|
||||
def __init__(self, p: int, q: int, g: int) -> None: ...
|
||||
def parameters(self, backend: DSABackend) -> DSAParameters: ...
|
||||
|
||||
class DSAPrivateKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@abstractmethod
|
||||
def parameters(self) -> DSAParameters: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> DSAPublicKey: ...
|
||||
@abstractmethod
|
||||
def sign(self, data: bytes, algorithm: Union[HashAlgorithm, Prehashed]) -> bytes: ...
|
||||
|
||||
class DSAPrivateKeyWithSerialization(DSAPrivateKey):
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def private_numbers(self) -> DSAPrivateNumbers: ...
|
||||
|
||||
class DSAPrivateNumbers(object):
|
||||
@property
|
||||
def x(self) -> int: ...
|
||||
@property
|
||||
def public_numbers(self) -> DSAPublicNumbers: ...
|
||||
def __init__(self, x: int, public_numbers: DSAPublicNumbers) -> None: ...
|
||||
|
||||
class DSAPublicKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_numbers(self) -> DSAPublicNumbers: ...
|
||||
@abstractmethod
|
||||
def verifier(self, signature: bytes,
|
||||
signature_algorithm: Union[HashAlgorithm, Prehashed]) -> AsymmetricVerificationContext: ...
|
||||
@abstractmethod
|
||||
def verify(self, signature: bytes, data: bytes, algorithm: Union[HashAlgorithm, Prehashed]) -> None: ...
|
||||
|
||||
DSAPublicKeyWithSerialization = DSAPublicKey
|
||||
|
||||
class DSAPublicNumbers(object):
|
||||
@property
|
||||
def y(self) -> int: ...
|
||||
@property
|
||||
def parameter_numbers(self) -> DSAParameterNumbers: ...
|
||||
def __init__(self, y: int, parameter_numbers: DSAParameterNumbers) -> None: ...
|
||||
|
||||
def generate_parameters(key_size: int, backend: DSABackend) -> DSAParameters: ...
|
||||
def generate_private_key(key_size: int, backend: DSABackend) -> DSAPrivateKey: ...
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import ClassVar, Union
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import EllipticCurveBackend
|
||||
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
|
||||
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
|
||||
from cryptography.x509 import ObjectIdentifier
|
||||
|
||||
class EllipticCurve(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
@abstractmethod
|
||||
def name(self) -> str: ...
|
||||
|
||||
class BrainpoolP256R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class BrainpoolP384R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class BrainpoolP512R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECP192R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECP224R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECP256K1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECP256R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECP384R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECP521R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT163K1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT163R2(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT233K1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT233R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT283K1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT283R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT409K1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT409R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT571K1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SECT571R1(EllipticCurve):
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class EllipticCurveOID(object):
|
||||
SECP192R1: ClassVar[ObjectIdentifier]
|
||||
SECP224R1: ClassVar[ObjectIdentifier]
|
||||
SECP256K1: ClassVar[ObjectIdentifier]
|
||||
SECP256R1: ClassVar[ObjectIdentifier]
|
||||
SECP384R1: ClassVar[ObjectIdentifier]
|
||||
SECP521R1: ClassVar[ObjectIdentifier]
|
||||
BRAINPOOLP256R1: ClassVar[ObjectIdentifier]
|
||||
BRAINPOOLP384R1: ClassVar[ObjectIdentifier]
|
||||
BRAINPOOLP512R1: ClassVar[ObjectIdentifier]
|
||||
SECT163K1: ClassVar[ObjectIdentifier]
|
||||
SECT163R2: ClassVar[ObjectIdentifier]
|
||||
SECT233K1: ClassVar[ObjectIdentifier]
|
||||
SECT233R1: ClassVar[ObjectIdentifier]
|
||||
SECT283K1: ClassVar[ObjectIdentifier]
|
||||
SECT283R1: ClassVar[ObjectIdentifier]
|
||||
SECT409K1: ClassVar[ObjectIdentifier]
|
||||
SECT409R1: ClassVar[ObjectIdentifier]
|
||||
SECT571K1: ClassVar[ObjectIdentifier]
|
||||
SECT571R1: ClassVar[ObjectIdentifier]
|
||||
|
||||
class EllipticCurvePrivateKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def curve(self) -> EllipticCurve: ...
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@abstractmethod
|
||||
def exchange(self, algorithm: ECDH, peer_public_key: EllipticCurvePublicKey) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> EllipticCurvePublicKey: ...
|
||||
@abstractmethod
|
||||
def sign(self, data: bytes, signature_algorithm: EllipticCurveSignatureAlgorithm) -> bytes: ...
|
||||
|
||||
class EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey):
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def private_numbers(self) -> EllipticCurvePrivateNumbers: ...
|
||||
|
||||
class EllipticCurvePrivateNumbers(object):
|
||||
@property
|
||||
def private_value(self) -> int: ...
|
||||
@property
|
||||
def public_numbers(self) -> EllipticCurvePublicNumbers: ...
|
||||
def __init__(self, private_value: int, public_numbers: EllipticCurvePublicNumbers) -> None: ...
|
||||
def private_key(self, backend: EllipticCurveBackend) -> EllipticCurvePrivateKey: ...
|
||||
|
||||
class EllipticCurvePublicKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def curve(self) -> EllipticCurve: ...
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@classmethod
|
||||
def from_encoded_point(cls, curve: EllipticCurve, data: bytes) -> EllipticCurvePublicKey: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_numbers(self) -> EllipticCurvePublicNumbers: ...
|
||||
@abstractmethod
|
||||
def verifier(self, signature: bytes, signature_algorithm: EllipticCurveSignatureAlgorithm) -> AsymmetricVerificationContext: ...
|
||||
@abstractmethod
|
||||
def verify(self, signature: bytes, data: bytes, signature_algorithm: EllipticCurveSignatureAlgorithm) -> None: ...
|
||||
|
||||
EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey
|
||||
|
||||
class EllipticCurvePublicNumbers(object):
|
||||
@property
|
||||
def curve(self) -> EllipticCurve: ...
|
||||
@property
|
||||
def x(self) -> int: ...
|
||||
@property
|
||||
def y(self) -> int: ...
|
||||
def __init__(self, x: int, y: int, curve: EllipticCurve) -> None: ...
|
||||
@classmethod
|
||||
def from_encoded_point(cls, curve: EllipticCurve, data: bytes) -> EllipticCurvePublicNumbers: ...
|
||||
def public_key(self, backend: EllipticCurveBackend) -> EllipticCurvePublicKey: ...
|
||||
|
||||
class EllipticCurveSignatureAlgorithm(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def algorithm(self) -> Union[HashAlgorithm, Prehashed]: ...
|
||||
|
||||
class ECDH(object): ...
|
||||
|
||||
class ECDSA(EllipticCurveSignatureAlgorithm):
|
||||
def __init__(self, algorithm: HashAlgorithm): ...
|
||||
@property
|
||||
def algorithm(self) -> Union[HashAlgorithm, Prehashed]: ...
|
||||
|
||||
def derive_private_key(private_value: int, curve: EllipticCurve, backend: EllipticCurveBackend) -> EllipticCurvePrivateKey: ...
|
||||
def generate_private_key(curve: EllipticCurve, backend: EllipticCurveBackend) -> EllipticCurvePrivateKey: ...
|
||||
def get_curve_for_oid(oid: ObjectIdentifier) -> EllipticCurve: ...
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
|
||||
|
||||
class Ed25519PrivateKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def generate(cls) -> Ed25519PrivateKey: ...
|
||||
@classmethod
|
||||
def from_private_bytes(cls, data: bytes) -> Ed25519PrivateKey: ...
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> Ed25519PublicKey: ...
|
||||
@abstractmethod
|
||||
def sign(self, data: bytes) -> bytes: ...
|
||||
|
||||
class Ed25519PublicKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def from_public_bytes(cls, data: bytes) -> Ed25519PublicKey: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
@abstractmethod
|
||||
def verify(self, signature: bytes, data: bytes) -> None: ...
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
|
||||
|
||||
class Ed448PrivateKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def generate(cls) -> Ed448PrivateKey: ...
|
||||
@classmethod
|
||||
def from_private_bytes(cls, data: bytes) -> Ed448PrivateKey: ...
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> Ed448PublicKey: ...
|
||||
@abstractmethod
|
||||
def sign(self, data: bytes) -> bytes: ...
|
||||
|
||||
class Ed448PublicKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def from_public_bytes(cls, data: bytes) -> Ed448PublicKey: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
@abstractmethod
|
||||
def verify(self, signature: bytes, data: bytes) -> None: ...
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import ClassVar, Optional, Union
|
||||
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class AsymmetricPadding(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def name(self) -> str: ...
|
||||
|
||||
class MGF1(object):
|
||||
def __init__(self, algorithm: HashAlgorithm) -> None: ...
|
||||
|
||||
class OAEP(AsymmetricPadding):
|
||||
def __init__(self, mgf: MGF1, algorithm: HashAlgorithm, label: Optional[bytes]) -> None: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class PKCS1v15(AsymmetricPadding):
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class PSS(AsymmetricPadding):
|
||||
MAX_LENGTH: ClassVar[object]
|
||||
def __init__(self, mgf: MGF1, salt_length: Union[int, object]) -> None: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Tuple, Union
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import RSABackend
|
||||
from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
|
||||
from cryptography.hazmat.primitives.asymmetric.padding import AsymmetricPadding
|
||||
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
|
||||
|
||||
class RSAPrivateKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@abstractmethod
|
||||
def decrypt(self, ciphertext: bytes, padding: AsymmetricPadding) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> RSAPublicKey: ...
|
||||
@abstractmethod
|
||||
def sign(self, data: bytes, padding: AsymmetricPadding, algorithm: Union[HashAlgorithm, Prehashed]) -> bytes: ...
|
||||
|
||||
class RSAPrivateKeyWithSerialization(RSAPrivateKey):
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def private_numbers(self) -> RSAPrivateNumbers: ...
|
||||
|
||||
class RSAPublicKey(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@abstractmethod
|
||||
def encrypt(self, plaintext: bytes, padding: AsymmetricPadding) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_numbers(self) -> RSAPublicNumbers: ...
|
||||
@abstractmethod
|
||||
def verifier(self, signature: bytes, padding: AsymmetricPadding,
|
||||
algorithm: Union[HashAlgorithm, Prehashed]) -> AsymmetricVerificationContext: ...
|
||||
@abstractmethod
|
||||
def verify(self, signature: bytes, data: bytes, padding: AsymmetricPadding,
|
||||
algorithm: Union[HashAlgorithm, Prehashed]) -> None: ...
|
||||
|
||||
RSAPublicKeyWithSerialization = RSAPublicKey
|
||||
|
||||
def generate_private_key(public_exponent: int, key_size: int, backend: RSABackend) -> RSAPrivateKeyWithSerialization: ...
|
||||
def rsa_crt_iqmp(p: int, q: int) -> int: ...
|
||||
def rsa_crt_dmp1(private_exponent: int, p: int) -> int: ...
|
||||
def rsa_crt_dmq1(private_exponent: int, q: int) -> int: ...
|
||||
def rsa_recover_prime_factors(n: int, e: int, d: int) -> Tuple[int, int]: ...
|
||||
|
||||
class RSAPrivateNumbers(object):
|
||||
def __init__(self, p: int, q: int, d: int, dmp1: int, dmq1: int, iqmp: int, public_numbers: RSAPublicNumbers) -> None: ...
|
||||
@property
|
||||
def p(self) -> int: ...
|
||||
@property
|
||||
def q(self) -> int: ...
|
||||
@property
|
||||
def d(self) -> int: ...
|
||||
@property
|
||||
def dmp1(self) -> int: ...
|
||||
@property
|
||||
def dmq1(self) -> int: ...
|
||||
@property
|
||||
def iqmp(self) -> int: ...
|
||||
@property
|
||||
def public_numbers(self) -> RSAPublicNumbers: ...
|
||||
def private_key(self, backend) -> RSAPrivateKey: ...
|
||||
|
||||
class RSAPublicNumbers(object):
|
||||
def __init__(self, e: int, n: int) -> None: ...
|
||||
@property
|
||||
def e(self) -> int: ...
|
||||
@property
|
||||
def n(self) -> int: ...
|
||||
def public_key(self, backend) -> RSAPublicKey: ...
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
from typing import Tuple
|
||||
|
||||
def decode_dss_signature(signature: bytes) -> Tuple[int, int]: ...
|
||||
def encode_dss_signature(r: int, s: int) -> bytes: ...
|
||||
|
||||
class Prehashed(object): ...
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
|
||||
|
||||
class X25519PrivateKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def from_private_bytes(cls, data: bytes) -> X25519PrivateKey: ...
|
||||
@classmethod
|
||||
def generate(cls) -> X25519PrivateKey: ...
|
||||
@abstractmethod
|
||||
def exchange(self, peer_public_key: X25519PublicKey) -> bytes: ...
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> X25519PublicKey: ...
|
||||
|
||||
class X25519PublicKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def from_public_bytes(cls, data: bytes) -> X25519PublicKey: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
|
||||
|
||||
class X448PrivateKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def from_private_bytes(cls, data: bytes) -> X448PrivateKey: ...
|
||||
@classmethod
|
||||
def generate(cls) -> X448PrivateKey: ...
|
||||
@abstractmethod
|
||||
def exchange(self, peer_public_key: X448PublicKey) -> bytes: ...
|
||||
@abstractmethod
|
||||
def private_bytes(
|
||||
self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
|
||||
) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> X448PublicKey: ...
|
||||
|
||||
class X448PublicKey(metaclass=ABCMeta):
|
||||
@classmethod
|
||||
def from_public_bytes(cls, data: bytes) -> X448PublicKey: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
|
||||
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import CipherBackend
|
||||
from cryptography.hazmat.primitives.ciphers.modes import Mode
|
||||
|
||||
class AEADCipherContext(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def authenticate_additional_data(self, data: bytes) -> None: ...
|
||||
|
||||
class AEADDecryptionContext(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def finalize_with_tag(self, tag: bytes) -> bytes: ...
|
||||
|
||||
class AEADEncryptionContext(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def tag(self) -> bytes: ...
|
||||
|
||||
class BlockCipherAlgorithm(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def block_size(self) -> int: ...
|
||||
|
||||
class Cipher(object):
|
||||
def __init__(self, algorithm: CipherAlgorithm, mode: Optional[Mode], backend: CipherBackend) -> None: ...
|
||||
def decryptor(self) -> CipherContext: ...
|
||||
def encryptor(self) -> CipherContext: ...
|
||||
|
||||
class CipherAlgorithm(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
@abstractmethod
|
||||
def name(self) -> str: ...
|
||||
|
||||
class CipherContext(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def finalize(self) -> bytes: ...
|
||||
@abstractmethod
|
||||
def update(self, data: bytes) -> bytes: ...
|
||||
@abstractmethod
|
||||
def update_into(self, data: bytes, buf) -> int: ...
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
from typing import Optional
|
||||
|
||||
class AESCCM(object):
|
||||
def __init__(self, key: bytes, tag_length: Optional[int]) -> None: ...
|
||||
def decrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ...
|
||||
def encrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ...
|
||||
@classmethod
|
||||
def generate_key(cls, bit_length: int) -> bytes: ...
|
||||
|
||||
class AESGCM(object):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
def decrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ...
|
||||
def encrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ...
|
||||
@classmethod
|
||||
def generate_key(cls, bit_length: int) -> bytes: ...
|
||||
|
||||
class ChaCha20Poly1305(object):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
def decrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ...
|
||||
def encrypt(self, nonce: bytes, data: bytes, associated_data: Optional[bytes]) -> bytes: ...
|
||||
@classmethod
|
||||
def generate_key(cls) -> bytes: ...
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm, CipherAlgorithm
|
||||
from cryptography.hazmat.primitives.ciphers.modes import ModeWithNonce
|
||||
|
||||
class AES(BlockCipherAlgorithm, CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class ARC4(CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class Blowfish(BlockCipherAlgorithm, CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class Camelia(BlockCipherAlgorithm, CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class CAST5(BlockCipherAlgorithm, CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class ChaCha20(CipherAlgorithm, ModeWithNonce):
|
||||
def __init__(self, key: bytes, nonce: bytes) -> None: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def nonce(self) -> bytes: ...
|
||||
|
||||
class IDEA(CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class SEED(BlockCipherAlgorithm, CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
|
||||
class TripleDES(BlockCipherAlgorithm, CipherAlgorithm):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
@property
|
||||
def block_size(self) -> int: ...
|
||||
@property
|
||||
def key_size(self) -> int: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.primitives.ciphers import CipherAlgorithm
|
||||
|
||||
class Mode(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def name(self) -> str: ...
|
||||
@abstractmethod
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class ModeWithAuthenticationTag(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def tag(self) -> bytes: ...
|
||||
|
||||
class ModeWithInitializationVector(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def initialization_vector(self) -> bytes: ...
|
||||
|
||||
class ModeWithNonce(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def nonce(self) -> bytes: ...
|
||||
|
||||
class ModeWithTweak(metaclass=ABCMeta):
|
||||
@property
|
||||
@abstractmethod
|
||||
def tweak(self) -> bytes: ...
|
||||
|
||||
class CBC(Mode, ModeWithInitializationVector):
|
||||
def __init__(self, initialization_vector: bytes) -> None: ...
|
||||
@property
|
||||
def initialization_vector(self) -> bytes: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class CTR(Mode, ModeWithNonce):
|
||||
def __init__(self, nonce: bytes) -> None: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def nonce(self) -> bytes: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class CFB(Mode, ModeWithInitializationVector):
|
||||
def __init__(self, initialization_vector: bytes) -> None: ...
|
||||
@property
|
||||
def initialization_vector(self) -> bytes: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class CFB8(Mode, ModeWithInitializationVector):
|
||||
def __init__(self, initialization_vector: bytes) -> None: ...
|
||||
@property
|
||||
def initialization_vector(self) -> bytes: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class ECB(Mode):
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class GCM(Mode, ModeWithInitializationVector, ModeWithAuthenticationTag):
|
||||
def __init__(self, initialization_vector: bytes, tag: Optional[bytes], min_tag_length: Optional[int]) -> None: ...
|
||||
@property
|
||||
def initialization_vector(self) -> bytes: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def tag(self) -> bytes: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class OFB(Mode, ModeWithInitializationVector):
|
||||
def __init__(self, initialization_vector: bytes) -> None: ...
|
||||
@property
|
||||
def initialization_vector(self) -> bytes: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
|
||||
class XTS(Mode, ModeWithTweak):
|
||||
def __init__(self, tweak: bytes) -> None: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def tweak(self) -> bytes: ...
|
||||
def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None: ...
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
from cryptography.hazmat.backends.interfaces import CMACBackend
|
||||
from cryptography.hazmat.primitives.ciphers import BlockCipherAlgorithm
|
||||
|
||||
class CMAC(object):
|
||||
def __init__(self, algorithm: BlockCipherAlgorithm, backend: CMACBackend) -> None: ...
|
||||
def copy(self) -> CMAC: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
def update(self, data: bytes) -> None: ...
|
||||
def verify(self, signature: bytes) -> None: ...
|
||||
+1
@@ -0,0 +1 @@
|
||||
def bytes_eq(a: bytes, b: bytes) -> bool: ...
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HashBackend
|
||||
|
||||
class HashAlgorithm(metaclass=ABCMeta):
|
||||
digest_size: int
|
||||
name: str
|
||||
|
||||
class HashContext(metaclass=ABCMeta):
|
||||
algorithm: HashAlgorithm
|
||||
@abstractmethod
|
||||
def copy(self) -> HashContext: ...
|
||||
@abstractmethod
|
||||
def finalize(self) -> bytes: ...
|
||||
@abstractmethod
|
||||
def update(self, data: bytes) -> None: ...
|
||||
|
||||
class BLAKE2b(HashAlgorithm): ...
|
||||
class BLAKE2s(HashAlgorithm): ...
|
||||
class MD5(HashAlgorithm): ...
|
||||
class SHA1(HashAlgorithm): ...
|
||||
class SHA224(HashAlgorithm): ...
|
||||
class SHA256(HashAlgorithm): ...
|
||||
class SHA384(HashAlgorithm): ...
|
||||
class SHA3_224(HashAlgorithm): ...
|
||||
class SHA3_256(HashAlgorithm): ...
|
||||
class SHA3_384(HashAlgorithm): ...
|
||||
class SHA3_512(HashAlgorithm): ...
|
||||
class SHA512(HashAlgorithm): ...
|
||||
class SHA512_224(HashAlgorithm): ...
|
||||
class SHA512_256(HashAlgorithm): ...
|
||||
|
||||
class SHAKE128(HashAlgorithm):
|
||||
def __init__(self, digest_size: int) -> None: ...
|
||||
|
||||
class SHAKE256(HashAlgorithm):
|
||||
def __init__(self, digest_size: int) -> None: ...
|
||||
|
||||
class Hash(HashContext):
|
||||
def __init__(self, algorithm: HashAlgorithm, backend: HashBackend): ...
|
||||
def copy(self) -> Hash: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
def update(self, data: bytes) -> None: ...
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class HMAC(object):
|
||||
def __init__(self, key: bytes, algorithm: HashAlgorithm, backend: HMACBackend) -> None: ...
|
||||
def copy(self) -> HMAC: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
def update(self, msg: bytes) -> None: ...
|
||||
def verify(self, signature: bytes) -> None: ...
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
class KeyDerivationFunction(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
@abstractmethod
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HashBackend, HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
class ConcatKDFHash(KeyDerivationFunction):
|
||||
def __init__(self, algorithm: HashAlgorithm, length: int, otherinfo: Optional[bytes], backend: HashBackend): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
class ConcatKDFHMAC(KeyDerivationFunction):
|
||||
def __init__(
|
||||
self, algorithm: HashAlgorithm, length: int, salt: Optional[bytes], otherinfo: Optional[bytes], backend: HMACBackend
|
||||
): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
class HKDF(KeyDerivationFunction):
|
||||
def __init__(
|
||||
self, algorithm: HashAlgorithm, length: int, salt: Optional[bytes], info: Optional[bytes], backend: HMACBackend
|
||||
): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
|
||||
class HKDFExpand(KeyDerivationFunction):
|
||||
def __init__(self, algorithm: HashAlgorithm, length: int, info: Optional[bytes], backend: HMACBackend): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
class Mode(Enum):
|
||||
CounterMode: str
|
||||
|
||||
class CounterLocation(Enum):
|
||||
BeforeFixed: str
|
||||
AfterFixed: str
|
||||
|
||||
class KBKDFHMAC(KeyDerivationFunction):
|
||||
def __init__(
|
||||
self,
|
||||
algorithm: HashAlgorithm,
|
||||
mode: Mode,
|
||||
length: int,
|
||||
rlen: int,
|
||||
llen: int,
|
||||
location: CounterLocation,
|
||||
label: Optional[bytes],
|
||||
context: Optional[bytes],
|
||||
fixed: Optional[bytes],
|
||||
backend: HMACBackend,
|
||||
): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
from cryptography.hazmat.backends.interfaces import PBKDF2HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
class PBKDF2HMAC(KeyDerivationFunction):
|
||||
def __init__(self, algorithm: HashAlgorithm, length: int, salt: bytes, iterations: int, backend: PBKDF2HMACBackend): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
from cryptography.hazmat.backends.interfaces import ScryptBackend
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
class Scrypt(KeyDerivationFunction):
|
||||
def __init__(self, salt: bytes, length: int, n: int, r: int, p: int, backend: ScryptBackend): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HashBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.kdf import KeyDerivationFunction
|
||||
|
||||
class X963KDF(KeyDerivationFunction):
|
||||
def __init__(self, algorithm: HashAlgorithm, length: int, sharedinfo: Optional[bytes], backend: HashBackend): ...
|
||||
def derive(self, key_material: bytes) -> bytes: ...
|
||||
def verify(self, key_material: bytes, expected_key: bytes) -> None: ...
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
from cryptography.hazmat.backends.interfaces import CipherBackend
|
||||
|
||||
def aes_key_wrap(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend) -> bytes: ...
|
||||
def aes_key_wrap_with_padding(wrapping_key: bytes, key_to_wrap: bytes, backend: CipherBackend) -> bytes: ...
|
||||
def aes_key_unwrap(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend) -> bytes: ...
|
||||
def aes_key_unwrap_with_padding(wrapping_key: bytes, wrapped_key: bytes, backend: CipherBackend) -> bytes: ...
|
||||
|
||||
class InvalidUnwrap(Exception): ...
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
class PaddingContext(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def finalize(self) -> bytes: ...
|
||||
@abstractmethod
|
||||
def update(self, data: bytes) -> bytes: ...
|
||||
|
||||
class ANSIX923(object):
|
||||
def __init__(self, block_size: int) -> None: ...
|
||||
def padder(self) -> PaddingContext: ...
|
||||
def unpadder(self) -> PaddingContext: ...
|
||||
|
||||
class PKCS7(object):
|
||||
def __init__(self, block_size: int) -> None: ...
|
||||
def padder(self) -> PaddingContext: ...
|
||||
def unpadder(self) -> PaddingContext: ...
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class Poly1305(object):
|
||||
def __init__(self, key: bytes) -> None: ...
|
||||
def finalize(self) -> bytes: ...
|
||||
@classmethod
|
||||
def generate_tag(cls, key: bytes, data: bytes) -> bytes: ...
|
||||
def update(self, data: bytes) -> None: ...
|
||||
def verify(self, tag: bytes) -> None: ...
|
||||
@classmethod
|
||||
def verify_tag(cls, key: bytes, data: bytes, tag: bytes) -> None: ...
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
from abc import ABCMeta
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
def load_pem_private_key(data: bytes, password: Optional[bytes], backend): ...
|
||||
def load_pem_public_key(data: bytes, backend): ...
|
||||
def load_der_private_key(data: bytes, password: Optional[bytes], backend): ...
|
||||
def load_der_public_key(data: bytes, backend): ...
|
||||
def load_ssh_public_key(data: bytes, backend): ...
|
||||
|
||||
class Encoding(Enum):
|
||||
PEM: str
|
||||
DER: str
|
||||
OpenSSH: str
|
||||
Raw: str
|
||||
X962: str
|
||||
|
||||
class PrivateFormat(Enum):
|
||||
PKCS8: str
|
||||
TraditionalOpenSSL: str
|
||||
Raw: str
|
||||
|
||||
class PublicFormat(Enum):
|
||||
SubjectPublicKeyInfo: str
|
||||
PKCS1: str
|
||||
OpenSSH: str
|
||||
Raw: str
|
||||
CompressedPoint: str
|
||||
UncompressedPoint: str
|
||||
|
||||
class ParameterFormat(Enum):
|
||||
PKCS3: str
|
||||
|
||||
class KeySerializationEncryption(metaclass=ABCMeta): ...
|
||||
|
||||
class BestAvailableEncryption(KeySerializationEncryption):
|
||||
password: bytes
|
||||
def __init__(self, password: bytes) -> None: ...
|
||||
|
||||
class NoEncryption(KeySerializationEncryption): ...
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
from typing import Optional
|
||||
|
||||
def load_key_and_certificates(data: bytes, password: Optional[bytes], backend): ...
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
class InvalidToken(Exception): ...
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class HOTP(object):
|
||||
def __init__(
|
||||
self, key: bytes, length: int, algorithm: HashAlgorithm, backend: HMACBackend, enforce_key_length: bool = ...
|
||||
): ...
|
||||
def generate(self, counter: int) -> bytes: ...
|
||||
def get_provisioning_uri(self, account_name: str, counter: int, issuer: Optional[str]) -> str: ...
|
||||
def verify(self, hotp: bytes, counter: int) -> None: ...
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
from typing import Optional
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import HMACBackend
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
|
||||
class TOTP(object):
|
||||
def __init__(
|
||||
self,
|
||||
key: bytes,
|
||||
length: int,
|
||||
algorithm: HashAlgorithm,
|
||||
time_step: int,
|
||||
backend: HMACBackend,
|
||||
enforce_key_length: bool = ...,
|
||||
): ...
|
||||
def generate(self, time: int) -> bytes: ...
|
||||
def get_provisioning_uri(self, account_name: str, issuer: Optional[str]) -> str: ...
|
||||
def verify(self, totp: bytes, time: int) -> None: ...
|
||||
@@ -0,0 +1,299 @@
|
||||
import datetime
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from enum import Enum
|
||||
from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
|
||||
from typing import Any, ClassVar, Generator, List, Optional, Union, Text, Iterable, Sequence, Type
|
||||
|
||||
from cryptography.hazmat.backends.interfaces import X509Backend
|
||||
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey
|
||||
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey, EllipticCurvePublicKey
|
||||
from cryptography.hazmat.primitives.asymmetric.ed448 import Ed448PrivateKey, Ed448PublicKey
|
||||
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
|
||||
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
|
||||
from cryptography.hazmat.primitives.hashes import HashAlgorithm
|
||||
from cryptography.hazmat.primitives.serialization import Encoding
|
||||
|
||||
class ObjectIdentifier(object):
|
||||
def __init__(self, dotted_string: str) -> None: ...
|
||||
def dotted_string(self) -> str: ...
|
||||
|
||||
class CRLEntryExtensionOID(object):
|
||||
CERTIFICATE_ISSUER: ClassVar[ObjectIdentifier]
|
||||
CRL_REASON: ClassVar[ObjectIdentifier]
|
||||
INVALIDITY_DATE: ClassVar[ObjectIdentifier]
|
||||
|
||||
class ExtensionOID(object):
|
||||
AUTHORITY_INFORMATION_ACCESS: ClassVar[ObjectIdentifier]
|
||||
AUTHORITY_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
|
||||
BASIC_CONSTRAINTS: ClassVar[ObjectIdentifier]
|
||||
CERTIFICATE_POLICIES: ClassVar[ObjectIdentifier]
|
||||
CRL_DISTRIBUTION_POINTS: ClassVar[ObjectIdentifier]
|
||||
CRL_NUMBER: ClassVar[ObjectIdentifier]
|
||||
DELTA_CRL_INDICATOR: ClassVar[ObjectIdentifier]
|
||||
EXTENDED_KEY_USAGE: ClassVar[ObjectIdentifier]
|
||||
FRESHEST_CRL: ClassVar[ObjectIdentifier]
|
||||
INHIBIT_ANY_POLICY: ClassVar[ObjectIdentifier]
|
||||
ISSUER_ALTERNATIVE_NAME: ClassVar[ObjectIdentifier]
|
||||
ISSUING_DISTRIBUTION_POINT: ClassVar[ObjectIdentifier]
|
||||
KEY_USAGE: ClassVar[ObjectIdentifier]
|
||||
NAME_CONSTRAINTS: ClassVar[ObjectIdentifier]
|
||||
OCSP_NO_CHECK: ClassVar[ObjectIdentifier]
|
||||
POLICY_CONSTRAINTS: ClassVar[ObjectIdentifier]
|
||||
POLICY_MAPPINGS: ClassVar[ObjectIdentifier]
|
||||
PRECERT_POISON: ClassVar[ObjectIdentifier]
|
||||
PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS: ClassVar[ObjectIdentifier]
|
||||
SUBJECT_ALTERNATIVE_NAME: ClassVar[ObjectIdentifier]
|
||||
SUBJECT_DIRECTORY_ATTRIBUTES: ClassVar[ObjectIdentifier]
|
||||
SUBJECT_INFORMATION_ACCESS: ClassVar[ObjectIdentifier]
|
||||
SUBJECT_KEY_IDENTIFIER: ClassVar[ObjectIdentifier]
|
||||
TLS_FEATURE: ClassVar[ObjectIdentifier]
|
||||
|
||||
class NameOID(object):
|
||||
BUSINESS_CATEGORY: ClassVar[ObjectIdentifier]
|
||||
COMMON_NAME: ClassVar[ObjectIdentifier]
|
||||
COUNTRY_NAME: ClassVar[ObjectIdentifier]
|
||||
DN_QUALIFIER: ClassVar[ObjectIdentifier]
|
||||
DOMAIN_COMPONENT: ClassVar[ObjectIdentifier]
|
||||
EMAIL_ADDRESS: ClassVar[ObjectIdentifier]
|
||||
GENERATION_QUALIFIER: ClassVar[ObjectIdentifier]
|
||||
GIVEN_NAME: ClassVar[ObjectIdentifier]
|
||||
JURISDICTION_COUNTRY_NAME: ClassVar[ObjectIdentifier]
|
||||
JURISDICTION_LOCALITY_NAME: ClassVar[ObjectIdentifier]
|
||||
JURISDICTION_STATE_OR_PROVINCE_NAME: ClassVar[ObjectIdentifier]
|
||||
LOCALITY_NAME: ClassVar[ObjectIdentifier]
|
||||
ORGANIZATIONAL_UNIT_NAME: ClassVar[ObjectIdentifier]
|
||||
ORGANIZATION_NAME: ClassVar[ObjectIdentifier]
|
||||
POSTAL_ADDRESS: ClassVar[ObjectIdentifier]
|
||||
POSTAL_CODE: ClassVar[ObjectIdentifier]
|
||||
PSEUDONYM: ClassVar[ObjectIdentifier]
|
||||
SERIAL_NUMBER: ClassVar[ObjectIdentifier]
|
||||
STATE_OR_PROVINCE_NAME: ClassVar[ObjectIdentifier]
|
||||
STREET_ADDRESS: ClassVar[ObjectIdentifier]
|
||||
SURNAME: ClassVar[ObjectIdentifier]
|
||||
TITLE: ClassVar[ObjectIdentifier]
|
||||
USER_ID: ClassVar[ObjectIdentifier]
|
||||
X500_UNIQUE_IDENTIFIER: ClassVar[ObjectIdentifier]
|
||||
|
||||
class OCSPExtensionOID(object):
|
||||
NONCE: ClassVar[ObjectIdentifier]
|
||||
|
||||
class SignatureAlgorithmOID(object):
|
||||
DSA_WITH_SHA1: ClassVar[ObjectIdentifier]
|
||||
DSA_WITH_SHA224: ClassVar[ObjectIdentifier]
|
||||
DSA_WITH_SHA256: ClassVar[ObjectIdentifier]
|
||||
ECDSA_WITH_SHA1: ClassVar[ObjectIdentifier]
|
||||
ECDSA_WITH_SHA224: ClassVar[ObjectIdentifier]
|
||||
ECDSA_WITH_SHA256: ClassVar[ObjectIdentifier]
|
||||
ECDSA_WITH_SHA384: ClassVar[ObjectIdentifier]
|
||||
ECDSA_WITH_SHA512: ClassVar[ObjectIdentifier]
|
||||
ED25519: ClassVar[ObjectIdentifier]
|
||||
ED448: ClassVar[ObjectIdentifier]
|
||||
RSASSA_PSS: ClassVar[ObjectIdentifier]
|
||||
RSA_WITH_MD5: ClassVar[ObjectIdentifier]
|
||||
RSA_WITH_SHA1: ClassVar[ObjectIdentifier]
|
||||
RSA_WITH_SHA224: ClassVar[ObjectIdentifier]
|
||||
RSA_WITH_SHA256: ClassVar[ObjectIdentifier]
|
||||
RSA_WITH_SHA384: ClassVar[ObjectIdentifier]
|
||||
RSA_WITH_SHA512: ClassVar[ObjectIdentifier]
|
||||
|
||||
class NameAttribute(object):
|
||||
oid: ObjectIdentifier
|
||||
value: Text
|
||||
def __init__(self, oid: ObjectIdentifier, value: Text) -> None: ...
|
||||
def rfc4514_string(self) -> str: ...
|
||||
|
||||
class RelativeDistinguishedName(object):
|
||||
def __init__(self, attributes: List[NameAttribute]) -> None: ...
|
||||
def __iter__(self) -> Generator[NameAttribute, None, None]: ...
|
||||
def get_attributes_for_oid(self, oid: ObjectIdentifier) -> List[NameAttribute]: ...
|
||||
def rfc4514_string(self) -> str: ...
|
||||
|
||||
class Name(object):
|
||||
rdns: List[RelativeDistinguishedName]
|
||||
def __init__(self, attributes: Sequence[Union[NameAttribute, RelativeDistinguishedName]]) -> None: ...
|
||||
def __iter__(self) -> Generator[NameAttribute, None, None]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def get_attributes_for_oid(self, oid: ObjectIdentifier) -> List[NameAttribute]: ...
|
||||
def public_bytes(self, backend: X509Backend) -> bytes: ...
|
||||
def rfc4514_string(self) -> str: ...
|
||||
|
||||
class Version(Enum):
|
||||
v1: int
|
||||
v3: int
|
||||
|
||||
class Certificate(metaclass=ABCMeta):
|
||||
extensions: Extensions
|
||||
issuer: Name
|
||||
not_valid_after: datetime.datetime
|
||||
not_valid_before: datetime.datetime
|
||||
serial_number: int
|
||||
signature: bytes
|
||||
signature_algorithm_oid: ObjectIdentifier
|
||||
signature_hash_algorithm: HashAlgorithm
|
||||
tbs_certificate_bytes: bytes
|
||||
subject: Name
|
||||
version: Version
|
||||
@abstractmethod
|
||||
def fingerprint(self, algorithm: HashAlgorithm) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey]: ...
|
||||
|
||||
class CertificateBuilder(object):
|
||||
def __init__(self, issuer_name: Optional[Name] = ..., subject_name: Optional[Name] = ...,
|
||||
public_key: Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey, None] = ...,
|
||||
serial_number: Optional[int] = ...,
|
||||
not_valid_before: Optional[datetime.datetime] = ...,
|
||||
not_valid_after: Optional[datetime.datetime] = ...,
|
||||
extensions: Optional[Iterable[ExtensionType]] = ...) -> None: ...
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateBuilder: ...
|
||||
def issuer_name(self, name: Name) -> CertificateBuilder: ...
|
||||
def not_valid_after(self, time: datetime.datetime) -> CertificateBuilder: ...
|
||||
def not_valid_before(self, time: datetime.datetime) -> CertificateBuilder: ...
|
||||
def public_key(
|
||||
self, public_key: Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey]
|
||||
) -> CertificateBuilder: ...
|
||||
def serial_number(self, serial_number: int) -> CertificateBuilder: ...
|
||||
def sign(
|
||||
self,
|
||||
private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: Optional[HashAlgorithm],
|
||||
backend: X509Backend,
|
||||
) -> Certificate: ...
|
||||
def subject_name(self, name: Name) -> CertificateBuilder: ...
|
||||
|
||||
class CertificateRevocationList(metaclass=ABCMeta):
|
||||
extensions: Extensions
|
||||
issuer: Name
|
||||
last_update: datetime.datetime
|
||||
next_update: datetime.datetime
|
||||
signature: bytes
|
||||
signature_algorithm_oid: ObjectIdentifier
|
||||
signature_hash_algorithm: HashAlgorithm
|
||||
tbs_certlist_bytes: bytes
|
||||
@abstractmethod
|
||||
def fingerprint(self, algorithm: HashAlgorithm) -> bytes: ...
|
||||
@abstractmethod
|
||||
def get_revoked_certificate_by_serial_number(self, serial_number: int) -> RevokedCertificate: ...
|
||||
@abstractmethod
|
||||
def is_signature_valid(
|
||||
self, public_key: Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey]
|
||||
) -> bool: ...
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding) -> bytes: ...
|
||||
|
||||
class CertificateRevocationListBuilder(object):
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateRevocationListBuilder: ...
|
||||
def add_revoked_certificate(self, revoked_certificate: RevokedCertificate) -> CertificateRevocationListBuilder: ...
|
||||
def issuer_name(self, name: Name) -> CertificateRevocationListBuilder: ...
|
||||
def last_update(self, time: datetime.datetime) -> CertificateRevocationListBuilder: ...
|
||||
def next_update(self, time: datetime.datetime) -> CertificateRevocationListBuilder: ...
|
||||
def sign(
|
||||
self,
|
||||
private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: Optional[HashAlgorithm],
|
||||
backend: X509Backend,
|
||||
) -> CertificateRevocationList: ...
|
||||
|
||||
class CertificateSigningRequest(metaclass=ABCMeta):
|
||||
extensions: Extensions
|
||||
is_signature_valid: bool
|
||||
signature: bytes
|
||||
signature_algorithm_oid: ObjectIdentifier
|
||||
signature_hash_algorithm: HashAlgorithm
|
||||
subject: Name
|
||||
tbs_certrequest_bytes: bytes
|
||||
@abstractmethod
|
||||
def public_bytes(self, encoding: Encoding) -> bytes: ...
|
||||
@abstractmethod
|
||||
def public_key(self) -> Union[DSAPublicKey, Ed25519PublicKey, Ed448PublicKey, EllipticCurvePublicKey, RSAPublicKey]: ...
|
||||
|
||||
class CertificateSigningRequestBuilder(object):
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> CertificateSigningRequestBuilder: ...
|
||||
def subject_name(self, name: Name) -> CertificateSigningRequestBuilder: ...
|
||||
def sign(
|
||||
self,
|
||||
private_key: Union[DSAPrivateKey, Ed25519PrivateKey, Ed448PrivateKey, EllipticCurvePrivateKey, RSAPrivateKey],
|
||||
algorithm: Optional[HashAlgorithm],
|
||||
backend: X509Backend,
|
||||
) -> CertificateSigningRequest: ...
|
||||
|
||||
class RevokedCertificate(metaclass=ABCMeta):
|
||||
extensions: Extensions
|
||||
revocation_date: datetime.datetime
|
||||
serial_number: int
|
||||
|
||||
class RevokedCertificateBuilder(object):
|
||||
def add_extension(self, extension: ExtensionType, critical: bool) -> RevokedCertificateBuilder: ...
|
||||
def build(self, backend: X509Backend) -> RevokedCertificate: ...
|
||||
def revocation_date(self, time: datetime.datetime) -> RevokedCertificateBuilder: ...
|
||||
def serial_number(self, serial_number: int) -> RevokedCertificateBuilder: ...
|
||||
|
||||
# General Name Classes
|
||||
|
||||
class GeneralName(metaclass=ABCMeta):
|
||||
value: Any
|
||||
|
||||
class DirectoryName(GeneralName):
|
||||
value: Name
|
||||
def __init__(self, value: Name) -> None: ...
|
||||
|
||||
class DNSName(GeneralName):
|
||||
value: Text
|
||||
def __init__(self, value: Text) -> None: ...
|
||||
|
||||
class IPAddress(GeneralName):
|
||||
value: Union[IPv4Address, IPv6Address, IPv4Network, IPv6Network]
|
||||
def __init__(self, value: Union[IPv4Address, IPv6Address, IPv4Network, IPv6Network]) -> None: ...
|
||||
|
||||
class OtherName(GeneralName):
|
||||
type_id: ObjectIdentifier
|
||||
value: bytes
|
||||
def __init__(self, type_id: ObjectIdentifier, value: bytes) -> None: ...
|
||||
|
||||
class RegisteredID(GeneralName):
|
||||
value: ObjectIdentifier
|
||||
def __init__(self, value: ObjectIdentifier) -> None: ...
|
||||
|
||||
class RFC822Name(GeneralName):
|
||||
value: Text
|
||||
def __init__(self, value: Text) -> None: ...
|
||||
|
||||
class UniformResourceIdentifier(GeneralName):
|
||||
value: Text
|
||||
def __init__(self, value: Text) -> None: ...
|
||||
|
||||
# X.509 Extensions
|
||||
|
||||
class Extension(object):
|
||||
critical: bool
|
||||
oid: ExtensionOID
|
||||
value: ExtensionType
|
||||
|
||||
class ExtensionType(metaclass=ABCMeta):
|
||||
oid: ExtensionOID
|
||||
|
||||
class Extensions(object):
|
||||
def __init__(self, general_names: List[Extension]) -> None: ...
|
||||
def __iter__(self) -> Generator[Extension, None, None]: ...
|
||||
def get_extension_for_oid(self, oid: ObjectIdentifier) -> Extension: ...
|
||||
def get_extension_for_class(self, extclass: Type[ExtensionType]) -> Extension: ...
|
||||
|
||||
class IssuerAlternativeName(ExtensionType):
|
||||
def __init__(self, general_names: List[GeneralName]) -> None: ...
|
||||
def __iter__(self) -> Generator[GeneralName, None, None]: ...
|
||||
def get_values_for_type(self, type: Type[GeneralName]) -> List[Any]: ...
|
||||
|
||||
class SubjectAlternativeName(ExtensionType):
|
||||
def __init__(self, general_names: List[GeneralName]) -> None: ...
|
||||
def __iter__(self) -> Generator[GeneralName, None, None]: ...
|
||||
def get_values_for_type(self, type: Type[GeneralName]) -> List[Any]: ...
|
||||
|
||||
def load_der_x509_certificate(data: bytes, backend: X509Backend) -> Certificate: ...
|
||||
def load_pem_x509_certificate(data: bytes, backend: X509Backend) -> Certificate: ...
|
||||
def load_der_x509_crl(data: bytes, backend: X509Backend) -> CertificateRevocationList: ...
|
||||
def load_pem_x509_crl(data: bytes, backend: X509Backend) -> CertificateRevocationList: ...
|
||||
def load_der_x509_csr(data: bytes, backend: X509Backend) -> CertificateSigningRequest: ...
|
||||
def load_pem_x509_csr(data: bytes, backend: X509Backend) -> CertificateSigningRequest: ...
|
||||
def __getattr__(name: str) -> Any: ... # incomplete
|
||||
@@ -1 +1 @@
|
||||
collec<caret>
|
||||
collecti<caret>
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
import com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesProcessor;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
@@ -503,15 +504,17 @@ public class PyMoveTest extends PyTestCase {
|
||||
@Nullable
|
||||
private PsiNamedElement findFirstNamedElement(String name) {
|
||||
final Project project = myFixture.getProject();
|
||||
final Collection<PyClass> classes = PyClassNameIndex.find(name, project, false);
|
||||
final GlobalSearchScope scope = ProjectScope.getProjectScope(project);
|
||||
|
||||
final Collection<PyClass> classes = PyClassNameIndex.find(name, project, scope);
|
||||
if (classes.size() > 0) {
|
||||
return classes.iterator().next();
|
||||
}
|
||||
final Collection<PyFunction> functions = PyFunctionNameIndex.find(name, project);
|
||||
final Collection<PyFunction> functions = PyFunctionNameIndex.find(name, project, scope);
|
||||
if (functions.size() > 0) {
|
||||
return functions.iterator().next();
|
||||
}
|
||||
final Collection<PyTargetExpression> targets = PyVariableNameIndex.find(name, project, ProjectScope.getAllScope(project));
|
||||
final Collection<PyTargetExpression> targets = PyVariableNameIndex.find(name, project, scope);
|
||||
if (targets.size() > 0) {
|
||||
return targets.iterator().next();
|
||||
}
|
||||
|
||||
@@ -32,10 +32,12 @@ val whiteList = sequenceOf(
|
||||
"_curses",
|
||||
"_importlib_modulespec",
|
||||
"_io",
|
||||
"_json",
|
||||
"_operator",
|
||||
"_thread",
|
||||
"abc",
|
||||
"argparse",
|
||||
"ast",
|
||||
"asyncio",
|
||||
"attr",
|
||||
"audioop",
|
||||
@@ -52,8 +54,10 @@ val whiteList = sequenceOf(
|
||||
"cPickle",
|
||||
"crypt",
|
||||
"Crypto",
|
||||
"cryptography",
|
||||
"csv",
|
||||
"ctypes",
|
||||
"curses",
|
||||
"datetime",
|
||||
"dbm",
|
||||
"decimal",
|
||||
@@ -61,20 +65,26 @@ val whiteList = sequenceOf(
|
||||
"distutils",
|
||||
"email",
|
||||
"exceptions",
|
||||
"fcntl",
|
||||
"functools",
|
||||
"gc",
|
||||
"genericpath",
|
||||
"gflags",
|
||||
"hashlib",
|
||||
"heapq",
|
||||
"http",
|
||||
"imaplib",
|
||||
"inspect",
|
||||
"io",
|
||||
"ipaddress",
|
||||
"itertools",
|
||||
"json",
|
||||
"logging",
|
||||
"macpath",
|
||||
"marshal",
|
||||
"math",
|
||||
"mock",
|
||||
"modulefinder",
|
||||
"multiprocessing",
|
||||
"ntpath",
|
||||
"numbers",
|
||||
@@ -97,9 +107,11 @@ val whiteList = sequenceOf(
|
||||
"six",
|
||||
"socket",
|
||||
"sqlite3",
|
||||
"sre_parse",
|
||||
"ssl",
|
||||
"subprocess",
|
||||
"sys",
|
||||
"tempfile",
|
||||
"threading",
|
||||
"time",
|
||||
"token",
|
||||
@@ -158,12 +170,27 @@ fun sync(repo: Path, bundled: Path) {
|
||||
}
|
||||
|
||||
fun cleanTopLevelPackages(typeshed: Path, whiteList: Set<String>) {
|
||||
val blackList = mutableSetOf<String>()
|
||||
|
||||
sequenceOf(typeshed)
|
||||
.flatMap { sequenceOf(it.resolve("stdlib"), it.resolve("third_party")) }
|
||||
.flatMap { Files.newDirectoryStream(it).asSequence() }
|
||||
.flatMap { Files.newDirectoryStream(it).asSequence() }
|
||||
.filter { it.nameWithoutExtension().toLowerCase() !in whiteList }
|
||||
.filter {
|
||||
val name = it.nameWithoutExtension().toLowerCase()
|
||||
|
||||
if (name !in whiteList) {
|
||||
blackList.add(name)
|
||||
false
|
||||
}
|
||||
else {
|
||||
true
|
||||
}
|
||||
}
|
||||
.forEach { it.delete() }
|
||||
|
||||
println("White list size: ${whiteList.size}")
|
||||
println("Black list size: ${blackList.size}")
|
||||
}
|
||||
|
||||
fun Path.abs() = toAbsolutePath()
|
||||
|
||||
Reference in New Issue
Block a user