diff --git a/.flake8 b/.flake8 index 1d582c448789..362deab3ccf9 100644 --- a/.flake8 +++ b/.flake8 @@ -5,7 +5,7 @@ # 7155 E302 expected 2 blank lines # 1463 F401 imported but unused # 967 E701 multiple statements on one line (colon) -# 457 F811 redefinition +# 457 F811 redefinition (should be fixed in pyflakes 2.1.2) # 390 E305 expected 2 blank lines # 4 E741 ambiguous variable name @@ -18,8 +18,6 @@ [flake8] ignore = F401, F403, F405, F811, E301, E302, E305, E501, E701, E704, E741, B303, W504 # We are checking with Python 3 but many of the stubs are Python 2 stubs. -# A nice future improvement would be to provide separate .flake8 -# configurations for Python 2 and Python 3 files. builtins = StandardError,apply,basestring,buffer,cmp,coerce,execfile,file,intern,long,raw_input,reduce,reload,unichr,unicode,xrange exclude = .venv*,@*,.git max-line-length = 130 diff --git a/README.md b/README.md index 76f3ed924e05..1bb538f06e76 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,13 @@ pytype repo. ## Format -Each Python module is represented by a `.pyi` "stub". This is a normal Python -file (i.e., it can be interpreted by Python 3), except all the methods are empty. +Each Python module is represented by a `.pyi` "stub file". This is a +syntactically valid Python file, although it usually cannot be run by +Python 3 (since forward references don't require string quotes). All +the methods are empty. + Python function annotations ([PEP 3107](https://www.python.org/dev/peps/pep-3107/)) -are used to describe the types the function has. +are used to describe the signature of each function or method. See [PEP 484](http://www.python.org/dev/peps/pep-0484/) for the exact syntax of the stub files and [CONTRIBUTING.md](CONTRIBUTING.md) for the diff --git a/requirements-tests-py3.txt b/requirements-tests-py3.txt index 34c3a46716aa..9547f1b04bc3 100644 --- a/requirements-tests-py3.txt +++ b/requirements-tests-py3.txt @@ -2,7 +2,7 @@ git+https://github.com/python/mypy.git@master typed-ast>=1.0.4 black==19.3b0 flake8==3.7.8 -flake8-bugbear==19.3.0 +flake8-bugbear==19.8.0 flake8-pyi==19.3.0 isort==4.3.21 -pytype>=2019.7.30 +pytype>=2019.10.17 diff --git a/stdlib/2/UserDict.pyi b/stdlib/2/UserDict.pyi index 965e88e03b29..1d850cfc2750 100644 --- a/stdlib/2/UserDict.pyi +++ b/stdlib/2/UserDict.pyi @@ -6,7 +6,7 @@ _VT = TypeVar('_VT') _T = TypeVar('_T') class UserDict(Dict[_KT, _VT], Generic[_KT, _VT]): - data: Mapping[_KT, _VT] + data: Dict[_KT, _VT] def __init__(self, initialdata: Mapping[_KT, _VT] = ...) -> None: ... diff --git a/stdlib/2/UserList.pyi b/stdlib/2/UserList.pyi index 97ba17a9b513..3c71e8292e3f 100644 --- a/stdlib/2/UserList.pyi +++ b/stdlib/2/UserList.pyi @@ -1,9 +1,10 @@ -from typing import Iterable, MutableSequence, TypeVar, Union, overload +from typing import Iterable, MutableSequence, TypeVar, Union, overload, List _T = TypeVar("_T") _S = TypeVar("_S") class UserList(MutableSequence[_T]): + data: List[_T] def insert(self, index: int, object: _T) -> None: ... @overload def __setitem__(self, i: int, o: _T) -> None: ... diff --git a/stdlib/2/UserString.pyi b/stdlib/2/UserString.pyi index 8cbbfc1242e7..704a93bc0962 100644 --- a/stdlib/2/UserString.pyi +++ b/stdlib/2/UserString.pyi @@ -62,7 +62,7 @@ class UserString(Sequence[UserString]): def upper(self: _UST) -> _UST: ... def zfill(self: _UST, width: int) -> _UST: ... -class MutableString(UserString, MutableSequence[MutableString]): # type: ignore +class MutableString(UserString, MutableSequence[MutableString]): @overload def __getitem__(self: _MST, i: int) -> _MST: ... @overload diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 966e150897eb..453cc040aefa 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -11,12 +11,17 @@ from typing import ( ) from abc import abstractmethod, ABCMeta from ast import mod, AST -from types import TracebackType, CodeType, ModuleType +from types import TracebackType, CodeType import sys if sys.version_info >= (3,): from typing import SupportsBytes, SupportsRound +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + _T = TypeVar('_T') _T_co = TypeVar('_T_co', covariant=True) _KT = TypeVar('_KT') @@ -29,6 +34,9 @@ _T4 = TypeVar('_T4') _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') +class _SupportsIndex(Protocol): + def __index__(self) -> int: ... + class object: __doc__: Optional[str] __dict__: Dict[str, Any] @@ -129,10 +137,12 @@ class super(object): class int: @overload - def __init__(self, x: Union[Text, bytes, SupportsInt] = ...) -> None: ... + def __init__(self, x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> None: ... @overload def __init__(self, x: Union[Text, bytes, bytearray], base: int) -> None: ... + if sys.version_info >= (3, 8): + def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ... @property def real(self) -> int: ... @property @@ -209,7 +219,7 @@ class int: def __index__(self) -> int: ... class float: - def __init__(self, x: Union[SupportsFloat, Text, bytes, bytearray] = ...) -> None: ... + def __init__(self, x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> None: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -271,11 +281,9 @@ class float: class complex: @overload - def __init__(self, re: float = ..., im: float = ...) -> None: ... - @overload - def __init__(self, s: str) -> None: ... + def __init__(self, real: float = ..., imag: float = ...) -> None: ... @overload - def __init__(self, s: SupportsComplex) -> None: ... + def __init__(self, real: Union[str, SupportsComplex, _SupportsIndex]) -> None: ... @property def real(self) -> float: ... @@ -804,12 +812,12 @@ class memoryview(Sized, Container[_mv_container_type]): def __iter__(self) -> Iterator[_mv_container_type]: ... def __len__(self) -> int: ... + @overload + def __setitem__(self, s: slice, o: memoryview) -> None: ... @overload def __setitem__(self, i: int, o: bytes) -> None: ... @overload def __setitem__(self, s: slice, o: Sequence[bytes]) -> None: ... - @overload - def __setitem__(self, s: slice, o: memoryview) -> None: ... def tobytes(self) -> bytes: ... def tolist(self) -> List[int]: ... @@ -987,6 +995,8 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __setitem__(self, k: _KT, v: _VT) -> None: ... def __delitem__(self, v: _KT) -> None: ... def __iter__(self) -> Iterator[_KT]: ... + if sys.version_info >= (3, 8): + def __reversed__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... __hash__: None # type: ignore @@ -1117,8 +1127,6 @@ if sys.version_info < (3,): if sys.version_info >= (3,): def ascii(__o: object) -> str: ... -class _SupportsIndex(Protocol): - def __index__(self) -> int: ... def bin(__number: Union[int, _SupportsIndex]) -> str: ... if sys.version_info >= (3, 7): @@ -1160,20 +1168,15 @@ if sys.version_info >= (3,): def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ... else: @overload - def filter(__function: Callable[[AnyStr], Any], # type: ignore - __iterable: AnyStr) -> AnyStr: ... + def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @overload - def filter(__function: None, # type: ignore - __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... + def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: Callable[[_T], Any], # type: ignore - __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... + def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: None, - __iterable: Iterable[Optional[_T]]) -> List[_T]: ... + def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... @overload - def filter(__function: Callable[[_T], Any], - __iterable: Iterable[_T]) -> List[_T]: ... + def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... @@ -1193,7 +1196,7 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... @overload -def iter(__function: Callable[[], Any], __sentinel: Any) -> Iterator[Any]: ... +def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... def len(__o: Sized) -> int: ... @@ -1383,7 +1386,7 @@ if sys.version_info >= (3,): @overload def round(number: SupportsRound[_T]) -> int: ... @overload - def round(number: SupportsRound[_T], ndigits: None) -> int: ... # type: ignore + def round(number: SupportsRound[_T], ndigits: None) -> int: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... else: @@ -1452,7 +1455,7 @@ else: def __import__(name: Text, globals: Optional[Mapping[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ..., fromlist: Sequence[str] = ..., - level: int = ...) -> ModuleType: ... + level: int = ...) -> Any: ... # Actually the type of Ellipsis is , but since it's # not exposed anywhere under that name, we make it private here. diff --git a/stdlib/2/_collections.pyi b/stdlib/2/_collections.pyi index 9736a49b9366..bee5d67b0918 100644 --- a/stdlib/2/_collections.pyi +++ b/stdlib/2/_collections.pyi @@ -23,18 +23,14 @@ class deque(Generic[_T]): def count(self, x: Any) -> int: ... def extend(self, iterable: Iterator[_T]) -> None: ... def extendleft(self, iterable: Iterator[_T]) -> None: ... - def pop(self) -> _T: - raise IndexError() - def popleft(self) -> _T: - raise IndexError() - def remove(self, value: _T) -> None: - raise IndexError() + def pop(self) -> _T: ... + def popleft(self) -> _T: ... + def remove(self, value: _T) -> None: ... def reverse(self) -> None: ... def rotate(self, n: int = ...) -> None: ... def __contains__(self, o: Any) -> bool: ... def __copy__(self) -> deque[_T]: ... - def __getitem__(self, i: int) -> _T: - raise IndexError() + def __getitem__(self, i: int) -> _T: ... def __iadd__(self, other: deque[_T2]) -> deque[Union[_T, _T2]]: ... def __iter__(self) -> Iterator[_T]: ... def __len__(self) -> int: ... diff --git a/stdlib/2/_hotshot.pyi b/stdlib/2/_hotshot.pyi index f75acf24323a..a4404b0c7f8d 100644 --- a/stdlib/2/_hotshot.pyi +++ b/stdlib/2/_hotshot.pyi @@ -6,29 +6,19 @@ from typing import Any, List, Tuple, Dict, Generic def coverage(a: str) -> Any: ... - -def logreader(a: str) -> LogReaderType: - raise IOError() - raise RuntimeError() - -def profiler(a: str, *args, **kwargs) -> Any: - raise IOError() - +def logreader(a: str) -> LogReaderType: ... +def profiler(a: str, *args, **kwargs) -> Any: ... def resolution() -> Tuple[Any, ...]: ... - class LogReaderType(object): def close(self) -> None: ... - def fileno(self) -> int: - raise ValueError() + def fileno(self) -> int: ... class ProfilerType(object): def addinfo(self, a: str, b: str) -> None: ... def close(self) -> None: ... - def fileno(self) -> int: - raise ValueError() + def fileno(self) -> int: ... def runcall(self, *args, **kwargs) -> Any: ... - def runcode(self, a, b, *args, **kwargs) -> Any: - raise TypeError() + def runcode(self, a, b, *args, **kwargs) -> Any: ... def start(self) -> None: ... def stop(self) -> None: ... diff --git a/stdlib/2/_socket.pyi b/stdlib/2/_socket.pyi index 31ba7638afc6..f6a058acac2f 100644 --- a/stdlib/2/_socket.pyi +++ b/stdlib/2/_socket.pyi @@ -256,9 +256,7 @@ class SocketType(object): def accept(self) -> Tuple[SocketType, Tuple[Any, ...]]: ... def bind(self, address: Tuple[Any, ...]) -> None: ... def close(self) -> None: ... - def connect(self, address: Tuple[Any, ...]) -> None: - raise gaierror - raise timeout + def connect(self, address: Tuple[Any, ...]) -> None: ... def connect_ex(self, address: Tuple[Any, ...]) -> int: ... def dup(self) -> SocketType: ... def fileno(self) -> int: ... @@ -266,13 +264,11 @@ class SocketType(object): def getsockname(self) -> Tuple[Any, ...]: ... def getsockopt(self, level: int, option: int, buffersize: int = ...) -> str: ... def gettimeout(self) -> float: ... - def listen(self, backlog: int) -> None: - raise error + def listen(self, backlog: int) -> None: ... def makefile(self, mode: str = ..., buffersize: int = ...) -> IO[Any]: ... def recv(self, buffersize: int, flags: int = ...) -> str: ... def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ... - def recvfrom(self, buffersize: int, flags: int = ...) -> Tuple[Any, ...]: - raise error + def recvfrom(self, buffersize: int, flags: int = ...) -> Tuple[Any, ...]: ... def recvfrom_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ... def send(self, data: str, flags: int = ...) -> int: ... diff --git a/stdlib/2/_sre.pyi b/stdlib/2/_sre.pyi index 5ab7ed124da4..93300f0f2999 100644 --- a/stdlib/2/_sre.pyi +++ b/stdlib/2/_sre.pyi @@ -8,10 +8,8 @@ MAXREPEAT: long copyright: str class SRE_Match(object): - def start(self, group: int = ...) -> int: - raise IndexError() - def end(self, group: int = ...) -> int: - raise IndexError() + def start(self, group: int = ...) -> int: ... + def end(self, group: int = ...) -> int: ... def expand(self, s: str) -> Any: ... @overload def group(self) -> str: ... @@ -19,8 +17,7 @@ class SRE_Match(object): def group(self, group: int = ...) -> Optional[str]: ... def groupdict(self) -> Dict[int, Optional[str]]: ... def groups(self) -> Tuple[Optional[str], ...]: ... - def span(self) -> Tuple[int, int]: - raise IndexError() + def span(self) -> Tuple[int, int]: ... @property def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented @@ -44,11 +41,14 @@ class SRE_Pattern(object): def sub(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ... def subn(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ... -def compile(pattern: str, flags: int, code: List[int], - groups: int = ..., - groupindex: Mapping[str, int] = ..., - indexgroup: Sequence[int] = ...) -> SRE_Pattern: - raise OverflowError() +def compile( + pattern: str, + flags: int, + code: List[int], + groups: int = ..., + groupindex: Mapping[str, int] = ..., + indexgroup: Sequence[int] = ..., +) -> SRE_Pattern: ... def getcodesize() -> int: ... diff --git a/stdlib/2/_threading_local.pyi b/stdlib/2/_threading_local.pyi index 512bf5874df7..1a7e03de4967 100644 --- a/stdlib/2/_threading_local.pyi +++ b/stdlib/2/_threading_local.pyi @@ -1,7 +1,5 @@ # Source: https://hg.python.org/cpython/file/2.7/Lib/_threading_local.py -from typing import Any, List - -__all__: List[str] +from typing import Any class _localbase(object): ... diff --git a/stdlib/2/functools.pyi b/stdlib/2/functools.pyi index 5d65d23c9d5b..dc812962a028 100644 --- a/stdlib/2/functools.pyi +++ b/stdlib/2/functools.pyi @@ -4,7 +4,6 @@ from abc import ABCMeta, abstractmethod from typing import Any, Callable, Generic, Dict, Iterable, Optional, Sequence, Tuple, TypeVar, overload -from collections import namedtuple _AnyCallable = Callable[..., Any] diff --git a/stdlib/2/heapq.pyi b/stdlib/2/heapq.pyi index 488221c7cf94..0e706c5f6ca3 100644 --- a/stdlib/2/heapq.pyi +++ b/stdlib/2/heapq.pyi @@ -7,12 +7,10 @@ class _Sortable(Protocol): def cmp_lt(x, y) -> bool: ... def heappush(heap: List[_T], item: _T) -> None: ... -def heappop(heap: List[_T]) -> _T: - raise IndexError() # if heap is empty +def heappop(heap: List[_T]) -> _T: ... def heappushpop(heap: List[_T], item: _T) -> _T: ... def heapify(x: List[_T]) -> None: ... -def heapreplace(heap: List[_T], item: _T) -> _T: - raise IndexError() # if heap is empty +def heapreplace(heap: List[_T], item: _T) -> _T: ... def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... def nlargest(n: int, iterable: Iterable[_T], key: Optional[Callable[[_T], _Sortable]] = ...) -> List[_T]: ... diff --git a/stdlib/2/inspect.pyi b/stdlib/2/inspect.pyi index 67be3a41a7c9..c5ed0ca7fa66 100644 --- a/stdlib/2/inspect.pyi +++ b/stdlib/2/inspect.pyi @@ -22,11 +22,12 @@ CO_VARARGS: int CO_VARKEYWORDS: int TPFLAGS_IS_ABSTRACT: int -ModuleInfo = NamedTuple('ModuleInfo', [('name', str), - ('suffix', str), - ('mode', str), - ('module_type', int), - ]) +class ModuleInfo(NamedTuple): + name: str + suffix: str + mode: str + module_type: int + def getmembers( object: object, predicate: Optional[Callable[[Any], bool]] = ... @@ -52,7 +53,7 @@ def isgetsetdescriptor(object: object) -> bool: ... def ismemberdescriptor(object: object) -> bool: ... # Retrieving source code -_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType] +_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ... def getabsfile(object: _SourceObjectType) -> str: ... @@ -70,22 +71,22 @@ def indentsize(line: str) -> int: ... # Classes and functions def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ... -ArgSpec = NamedTuple('ArgSpec', [('args', List[str]), - ('varargs', Optional[str]), - ('keywords', Optional[str]), - ('defaults', Tuple[Any, ...]), - ]) +class ArgSpec(NamedTuple): + args: List[str] + varargs: Optional[str] + keywords: Optional[str] + defaults: Tuple[Any, ...] -ArgInfo = NamedTuple('ArgInfo', [('args', List[str]), - ('varargs', Optional[str]), - ('keywords', Optional[str]), - ('locals', Dict[str, Any]), - ]) +class ArgInfo(NamedTuple): + args: List[str] + varargs: Optional[str] + keywords: Optional[str] + locals: Dict[str, Any] -Arguments = NamedTuple('Arguments', [('args', List[Union[str, List[Any]]]), - ('varargs', Optional[str]), - ('keywords', Optional[str]), - ]) +class Arguments(NamedTuple): + args: List[Union[str, List[Any]]] + varargs: Optional[str] + keywords: Optional[str] def getargs(co: CodeType) -> Arguments: ... def getargspec(func: object) -> ArgSpec: ... @@ -101,16 +102,12 @@ def getcallargs(func, *args, **kwds) -> Dict[str, Any]: ... # The interpreter stack -Traceback = NamedTuple( - 'Traceback', - [ - ('filename', str), - ('lineno', int), - ('function', str), - ('code_context', Optional[List[str]]), - ('index', Optional[int]), - ] -) +class Traceback(NamedTuple): + filename: str + lineno: int + function: str + code_context: Optional[List[str]] + index: Optional[int] # type: ignore _FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], Optional[int]] @@ -123,10 +120,10 @@ def currentframe(depth: int = ...) -> FrameType: ... def stack(context: int = ...) -> List[_FrameInfo]: ... def trace(context: int = ...) -> List[_FrameInfo]: ... -Attribute = NamedTuple('Attribute', [('name', str), - ('kind', str), - ('defining_class', type), - ('object', object), - ]) +class Attribute(NamedTuple): + name: str + kind: str + defining_class: type + object: object def classify_class_attrs(cls: type) -> List[Attribute]: ... diff --git a/stdlib/2/os/__init__.pyi b/stdlib/2/os/__init__.pyi index 63407c289e88..7041e1fbe48e 100644 --- a/stdlib/2/os/__init__.pyi +++ b/stdlib/2/os/__init__.pyi @@ -136,10 +136,17 @@ if sys.version_info >= (3, 6): _PathType = path._PathType -_StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_blocks', int), - ('f_bfree', int), ('f_bavail', int), ('f_files', int), - ('f_ffree', int), ('f_favail', int), ('f_flag', int), - ('f_namemax', int)]) +class _StatVFS(NamedTuple): + f_bsize: int + f_frsize: int + f_blocks: int + f_bfree: int + f_bavail: int + f_files: int + f_ffree: int + f_favail: int + f_flag: int + f_namemax: int def getlogin() -> str: ... def getpid() -> int: ... @@ -349,20 +356,3 @@ if sys.version_info < (3, 0): P_ALL: int WEXITED: int WNOWAIT: int - -if sys.version_info >= (3, 3): - if sys.platform != 'win32': - # Unix only - def sync() -> None: ... - - def truncate(path: Union[_PathType, int], length: int) -> None: ... # Unix only up to version 3.4 - - def fwalk(top: AnyStr = ..., topdown: bool = ..., - onerror: Callable = ..., *, follow_symlinks: bool = ..., - dir_fd: int = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr], int]]: ... - - terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)]) - def get_terminal_size(fd: int = ...) -> terminal_size: ... - -if sys.version_info >= (3, 4): - def cpu_count() -> Optional[int]: ... diff --git a/stdlib/2/os/path.pyi b/stdlib/2/os/path.pyi index c0bf57658ed7..42409c0e8721 100644 --- a/stdlib/2/os/path.pyi +++ b/stdlib/2/os/path.pyi @@ -4,10 +4,7 @@ import os import sys -from typing import ( - overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, - TypeVar, Union, Text, Callable, Optional -) +from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional _T = TypeVar('_T') diff --git a/stdlib/2/os2emxpath.pyi b/stdlib/2/os2emxpath.pyi index c0bf57658ed7..42409c0e8721 100644 --- a/stdlib/2/os2emxpath.pyi +++ b/stdlib/2/os2emxpath.pyi @@ -4,10 +4,7 @@ import os import sys -from typing import ( - overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, - TypeVar, Union, Text, Callable, Optional -) +from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional _T = TypeVar('_T') diff --git a/stdlib/2/posix.pyi b/stdlib/2/posix.pyi index c6ff52ccfdd7..6cfd8520a15f 100644 --- a/stdlib/2/posix.pyi +++ b/stdlib/2/posix.pyi @@ -113,10 +113,8 @@ def fchmod(fd: int, mode: int) -> None: ... def fchown(fd: int, uid: int, gid: int) -> None: ... def fdatasync(fd: int) -> None: ... def fdopen(fd: int, mode: str = ..., bufsize: int = ...) -> IO[str]: ... -def fork() -> int: - raise OSError() -def forkpty() -> Tuple[int, int]: - raise OSError() +def fork() -> int: ... +def forkpty() -> Tuple[int, int]: ... def fpathconf(fd: int, name: str) -> None: ... def fstat(fd: int) -> stat_result: ... def fstatvfs(fd: int) -> statvfs_result: ... @@ -128,8 +126,7 @@ def getegid() -> int: ... def geteuid() -> int: ... def getgid() -> int: ... def getgroups() -> List[int]: ... -def getloadavg() -> Tuple[float, float, float]: - raise OSError() +def getloadavg() -> Tuple[float, float, float]: ... def getlogin() -> str: ... def getpgid(pid: int) -> int: ... def getpgrp() -> int: ... @@ -195,12 +192,10 @@ def uname() -> Tuple[str, str, str, str, str]: ... def unlink(path: unicode) -> None: ... def unsetenv(varname: str) -> None: ... def urandom(n: int) -> str: ... -def utime(path: unicode, times: Optional[Tuple[int, int]]) -> None: - raise OSError +def utime(path: unicode, times: Optional[Tuple[int, int]]) -> None: ... def wait() -> int: ... _r = Tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int] def wait3(options: int) -> Tuple[int, int, _r]: ... def wait4(pid: int, options: int) -> Tuple[int, int, _r]: ... -def waitpid(pid: int, options: int) -> int: - raise OSError() +def waitpid(pid: int, options: int) -> int: ... def write(fd: int, str: str) -> int: ... diff --git a/stdlib/2/resource.pyi b/stdlib/2/resource.pyi index 2a6c6947a81b..3763bc25b91d 100644 --- a/stdlib/2/resource.pyi +++ b/stdlib/2/resource.pyi @@ -19,12 +19,24 @@ RLIMIT_MEMLOCK: int RLIMIT_VMEM: int RLIMIT_AS: int -_RUsage = NamedTuple('_RUsage', [('ru_utime', float), ('ru_stime', float), ('ru_maxrss', int), - ('ru_ixrss', int), ('ru_idrss', int), ('ru_isrss', int), - ('ru_minflt', int), ('ru_majflt', int), ('ru_nswap', int), - ('ru_inblock', int), ('ru_oublock', int), ('ru_msgsnd', int), - ('ru_msgrcv', int), ('ru_nsignals', int), ('ru_nvcsw', int), - ('ru_nivcsw', int)]) +class _RUsage(NamedTuple): + ru_utime: float + ru_stime: float + ru_maxrss: int + ru_ixrss: int + ru_idrss: int + ru_isrss: int + ru_minflt: int + ru_majflt: int + ru_nswap: int + ru_inblock: int + ru_oublock: int + ru_msgsnd: int + ru_msgrcv: int + ru_nsignals: int + ru_nvcsw: int + ru_nivcsw: int + def getrusage(who: int) -> _RUsage: ... def getpagesize() -> int: ... diff --git a/stdlib/2/shlex.pyi b/stdlib/2/shlex.pyi index 5bf6fccdba11..a29b83eb1362 100644 --- a/stdlib/2/shlex.pyi +++ b/stdlib/2/shlex.pyi @@ -7,6 +7,7 @@ _SLT = TypeVar('_SLT', bound=shlex) class shlex: def __init__(self, instream: IO[Any] = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ... def __iter__(self: _SLT) -> _SLT: ... + def next(self) -> str: ... def get_token(self) -> Optional[str]: ... def push_token(self, _str: str) -> None: ... def read_token(self) -> str: ... diff --git a/stdlib/2/signal.pyi b/stdlib/2/signal.pyi index cda4c65ecc8e..24bfbf07789a 100644 --- a/stdlib/2/signal.pyi +++ b/stdlib/2/signal.pyi @@ -63,9 +63,6 @@ def pause() -> None: ... def setitimer(which: int, seconds: float, interval: float = ...) -> Tuple[float, float]: ... def getitimer(which: int) -> Tuple[float, float]: ... def set_wakeup_fd(fd: int) -> int: ... -def siginterrupt(signalnum: int, flag: bool) -> None: - raise RuntimeError() -def signal(signalnum: int, handler: _HANDLER) -> _HANDLER: - raise RuntimeError() -def default_int_handler(signum: int, frame: FrameType) -> None: - raise KeyboardInterrupt() +def siginterrupt(signalnum: int, flag: bool) -> None: ... +def signal(signalnum: int, handler: _HANDLER) -> _HANDLER: ... +def default_int_handler(signum: int, frame: FrameType) -> None: ... diff --git a/stdlib/2/spwd.pyi b/stdlib/2/spwd.pyi index 1d5899031919..756c142a61da 100644 --- a/stdlib/2/spwd.pyi +++ b/stdlib/2/spwd.pyi @@ -1,14 +1,15 @@ from typing import List, NamedTuple -struct_spwd = NamedTuple("struct_spwd", [("sp_nam", str), - ("sp_pwd", str), - ("sp_lstchg", int), - ("sp_min", int), - ("sp_max", int), - ("sp_warn", int), - ("sp_inact", int), - ("sp_expire", int), - ("sp_flag", int)]) +class struct_spwd(NamedTuple): + sp_nam: str + sp_pwd: str + sp_lstchg: int + sp_min: int + sp_max: int + sp_warn: int + sp_inact: int + sp_expire: int + sp_flag: int def getspall() -> List[struct_spwd]: ... def getspnam(name: str) -> struct_spwd: ... diff --git a/stdlib/2/string.pyi b/stdlib/2/string.pyi index 624f092b3365..bf55e922a408 100644 --- a/stdlib/2/string.pyi +++ b/stdlib/2/string.pyi @@ -68,10 +68,7 @@ class Formatter(object): def parse(self, format_string: str) -> Iterable[Tuple[str, str, str, str]]: ... def get_field(self, field_name: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... - def get_value(self, key: Union[int, str], args: Sequence[Any], - kwargs: Mapping[str, Any]) -> Any: - raise IndexError() - raise KeyError() + def get_value(self, key: Union[int, str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def check_unused_args(self, used_args: Sequence[Union[int, str]], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... def format_field(self, value: Any, format_spec: str) -> Any: ... diff --git a/stdlib/2/strop.pyi b/stdlib/2/strop.pyi index e1a098fe503c..578a47758df5 100644 --- a/stdlib/2/strop.pyi +++ b/stdlib/2/strop.pyi @@ -6,67 +6,24 @@ lowercase: str uppercase: str whitespace: str -def atof(a: str) -> float: - raise DeprecationWarning() - -def atoi(a: str, base: int = ...) -> int: - raise DeprecationWarning() - -def atol(a: str, base: int = ...) -> long: - raise DeprecationWarning() - -def capitalize(s: str) -> str: - raise DeprecationWarning() - -def count(s: str, sub: str, start: int = ..., end: int = ...) -> int: - raise DeprecationWarning() - -def expandtabs(string: str, tabsize: int = ...) -> str: - raise DeprecationWarning() - raise OverflowError() - -def find(s: str, sub: str, start: int = ..., end: int = ...) -> int: - raise DeprecationWarning() - -def join(list: Sequence[str], sep: str = ...) -> str: - raise DeprecationWarning() - raise OverflowError() - -def joinfields(list: Sequence[str], sep: str = ...) -> str: - raise DeprecationWarning() - raise OverflowError() - -def lower(s: str) -> str: - raise DeprecationWarning() - -def lstrip(s: str) -> str: - raise DeprecationWarning() - +def atof(a: str) -> float: ... +def atoi(a: str, base: int = ...) -> int: ... +def atol(a: str, base: int = ...) -> long: ... +def capitalize(s: str) -> str: ... +def count(s: str, sub: str, start: int = ..., end: int = ...) -> int: ... +def expandtabs(string: str, tabsize: int = ...) -> str: ... +def find(s: str, sub: str, start: int = ..., end: int = ...) -> int: ... +def join(list: Sequence[str], sep: str = ...) -> str: ... +def joinfields(list: Sequence[str], sep: str = ...) -> str: ... +def lower(s: str) -> str: ... +def lstrip(s: str) -> str: ... def maketrans(frm: str, to: str) -> str: ... - -def replace(s: str, old: str, new: str, maxsplit: int = ...) -> str: - raise DeprecationWarning() - -def rfind(s: str, sub: str, start: int = ..., end: int = ...) -> int: - raise DeprecationWarning() - -def rstrip(s: str) -> str: - raise DeprecationWarning() - -def split(s: str, sep: str, maxsplit: int = ...) -> List[str]: - raise DeprecationWarning() - -def splitfields(s: str, sep: str, maxsplit: int = ...) -> List[str]: - raise DeprecationWarning() - -def strip(s: str) -> str: - raise DeprecationWarning() - -def swapcase(s: str) -> str: - raise DeprecationWarning() - -def translate(s: str, table: str, deletechars: str = ...) -> str: - raise DeprecationWarning() - -def upper(s: str) -> str: - raise DeprecationWarning() +def replace(s: str, old: str, new: str, maxsplit: int = ...) -> str: ... +def rfind(s: str, sub: str, start: int = ..., end: int = ...) -> int: ... +def rstrip(s: str) -> str: ... +def split(s: str, sep: str, maxsplit: int = ...) -> List[str]: ... +def splitfields(s: str, sep: str, maxsplit: int = ...) -> List[str]: ... +def strip(s: str) -> str: ... +def swapcase(s: str) -> str: ... +def translate(s: str, table: str, deletechars: str = ...) -> str: ... +def upper(s: str) -> str: ... diff --git a/stdlib/2/sys.pyi b/stdlib/2/sys.pyi index 2b38c6da0c49..1f5a68fca531 100644 --- a/stdlib/2/sys.pyi +++ b/stdlib/2/sys.pyi @@ -114,13 +114,11 @@ def _getframe(depth: int = ...) -> FrameType: ... def call_tracing(fn: Any, args: Any) -> Any: ... def __displayhook__(value: int) -> None: ... def __excepthook__(type_: type, value: BaseException, traceback: TracebackType) -> None: ... -def exc_clear() -> None: - raise DeprecationWarning() +def exc_clear() -> None: ... def exc_info() -> _OptExcInfo: ... # sys.exit() accepts an optional argument of anything printable -def exit(arg: Any = ...) -> NoReturn: - raise SystemExit() +def exit(arg: Any = ...) -> NoReturn: ... def getcheckinterval() -> int: ... # deprecated def getdefaultencoding() -> str: ... def getdlopenflags() -> int: ... diff --git a/stdlib/2/thread.pyi b/stdlib/2/thread.pyi index eb4e6d6d3e9e..5bc40f4ba8a8 100644 --- a/stdlib/2/thread.pyi +++ b/stdlib/2/thread.pyi @@ -21,10 +21,8 @@ class _localdummy(object): ... def start_new(function: Callable[..., Any], args: Any, kwargs: Any = ...) -> int: ... def start_new_thread(function: Callable[..., Any], args: Any, kwargs: Any = ...) -> int: ... def interrupt_main() -> None: ... -def exit() -> None: - raise SystemExit() -def exit_thread() -> Any: - raise SystemExit() +def exit() -> None: ... +def exit_thread() -> Any: ... def allocate_lock() -> LockType: ... def get_ident() -> int: ... def stack_size(size: int = ...) -> int: ... diff --git a/stdlib/2/toaiff.pyi b/stdlib/2/toaiff.pyi index 77334c7f525e..f3e1b29d50b3 100644 --- a/stdlib/2/toaiff.pyi +++ b/stdlib/2/toaiff.pyi @@ -4,8 +4,6 @@ from pipes import Template from typing import Dict, List - -__all__: List[str] table: Dict[str, Template] t: Template uncompress: Template diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index d45aba1da6b7..e8fb0985c81a 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -462,8 +462,8 @@ def cast(tp: str, obj: Any) -> Any: ... class NamedTuple(Tuple[Any, ...]): _fields: Tuple[str, ...] - def __init__(self, typename: Text, fields: Iterable[Tuple[Text, Any]] = ..., *, - verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... + def __init__(self, typename: Text, fields: Iterable[Tuple[Text, Any]] = ..., + **kwargs: Any) -> None: ... @classmethod def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ... diff --git a/stdlib/2/urlparse.pyi b/stdlib/2/urlparse.pyi index fb5909503290..4f54dde153e4 100644 --- a/stdlib/2/urlparse.pyi +++ b/stdlib/2/urlparse.pyi @@ -1,6 +1,6 @@ # Stubs for urlparse (Python 2) -from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload +from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload, Optional _String = Union[str, unicode] @@ -17,35 +17,31 @@ def clear_cache() -> None: ... class ResultMixin(object): @property - def username(self) -> str: ... + def username(self) -> Optional[str]: ... @property - def password(self) -> str: ... + def password(self) -> Optional[str]: ... @property - def hostname(self) -> str: ... + def hostname(self) -> Optional[str]: ... @property - def port(self) -> int: ... + def port(self) -> Optional[int]: ... -class SplitResult( - NamedTuple( - 'SplitResult', - [ - ('scheme', str), ('netloc', str), ('path', str), ('query', str), ('fragment', str) - ] - ), - ResultMixin -): +class _SplitResult(NamedTuple): + scheme: str + netloc: str + path: str + query: str + fragment: str +class SplitResult(_SplitResult, ResultMixin): def geturl(self) -> str: ... -class ParseResult( - NamedTuple( - 'ParseResult', - [ - ('scheme', str), ('netloc', str), ('path', str), ('params', str), ('query', str), - ('fragment', str) - ] - ), - ResultMixin -): +class _ParseResult(NamedTuple): + scheme: str + netloc: str + path: str + params: str + query: str + fragment: str +class ParseResult(_ParseResult, ResultMixin): def geturl(self) -> str: ... def urlparse(url: _String, scheme: _String = ..., diff --git a/stdlib/2and3/_codecs.pyi b/stdlib/2and3/_codecs.pyi index 32163eb913d0..c9762567dc33 100644 --- a/stdlib/2and3/_codecs.pyi +++ b/stdlib/2and3/_codecs.pyi @@ -43,8 +43,9 @@ def raw_unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[ def readbuffer_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ... def unicode_escape_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ... def unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... -def unicode_internal_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ... -def unicode_internal_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ... +if sys.version_info < (3, 8): + def unicode_internal_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ... + def unicode_internal_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ... def utf_16_be_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... def utf_16_be_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ... def utf_16_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ... diff --git a/stdlib/2and3/_curses.pyi b/stdlib/2and3/_curses.pyi index cf640b53f7a5..4126f36dedbf 100644 --- a/stdlib/2and3/_curses.pyi +++ b/stdlib/2and3/_curses.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, BinaryIO, IO, Optional, Tuple, Union, overload +from typing import Any, BinaryIO, IO, NamedTuple, Optional, Tuple, Union, overload _chtype = Union[str, bytes, int] @@ -452,3 +452,10 @@ class _CursesWindow: def vline(self, ch: _chtype, n: int) -> None: ... @overload def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... + +if sys.version_info >= (3, 8): + class _ncurses_version(NamedTuple): + major: int + minor: int + patch: int + ncurses_version: _ncurses_version diff --git a/stdlib/2and3/_heapq.pyi b/stdlib/2and3/_heapq.pyi index 9ff4a08fee11..2fc4e048bff2 100644 --- a/stdlib/2and3/_heapq.pyi +++ b/stdlib/2and3/_heapq.pyi @@ -6,12 +6,10 @@ import sys _T = TypeVar("_T") def heapify(heap: List[_T]) -> None: ... -def heappop(heap: List[_T]) -> _T: - raise IndexError() # if list is empty +def heappop(heap: List[_T]) -> _T: ... def heappush(heap: List[_T], item: _T) -> None: ... def heappushpop(heap: List[_T], item: _T) -> _T: ... -def heapreplace(heap: List[_T], item: _T) -> _T: - raise IndexError() # if list is empty +def heapreplace(heap: List[_T], item: _T) -> _T: ... if sys.version_info < (3,): def nlargest(n: int, iterable: Iterable[_T]) -> List[_T]: ... def nsmallest(n: int, iterable: Iterable[_T]) -> List[_T]: ... diff --git a/stdlib/2and3/aifc.pyi b/stdlib/2and3/aifc.pyi index a141125a96fc..c2fd608de931 100644 --- a/stdlib/2and3/aifc.pyi +++ b/stdlib/2and3/aifc.pyi @@ -1,4 +1,3 @@ - from typing import Union, IO, Optional, Type, NamedTuple, List, Tuple, Any, Text, overload from typing_extensions import Literal from types import TracebackType @@ -6,8 +5,13 @@ import sys class Error(Exception): ... -_aifc_params = NamedTuple('_aifc_params', [('nchannels', int), ('sampwidth', int), ('framerate', int), - ('nframes', int), ('comptype', bytes), ('compname', bytes)]) +class _aifc_params(NamedTuple): + nchannels: int + sampwidth: int + framerate: int + nframes: int + comptype: bytes + compname: bytes _File = Union[Text, IO[bytes]] _Marker = Tuple[int, int, bytes] diff --git a/stdlib/2and3/bdb.pyi b/stdlib/2and3/bdb.pyi new file mode 100644 index 000000000000..18f46893775d --- /dev/null +++ b/stdlib/2and3/bdb.pyi @@ -0,0 +1,94 @@ + +from typing import Set, Dict, Iterable, Any, Callable, Tuple, Type, SupportsInt, List, Union, TypeVar, Optional, IO +from types import FrameType, TracebackType, CodeType + + +_T = TypeVar("_T") +_TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type +_ExcInfo = Tuple[Type[BaseException], BaseException, FrameType] + +GENERATOR_AND_COROUTINE_FLAGS: int = ... + +class BdbQuit(Exception): ... + +class Bdb: + + skip: Optional[Set[str]] + breaks: Dict[str, List[int]] + fncache: Dict[str, str] + frame_returning: Optional[FrameType] + botframe: Optional[FrameType] + quitting: bool + stopframe: Optional[FrameType] + returnframe: Optional[FrameType] + stoplineno: int + + def __init__(self, skip: Iterable[str] = ...) -> None: ... + def canonic(self, filename: str) -> str: ... + def reset(self) -> None: ... + def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ... + def dispatch_line(self, frame: FrameType) -> _TraceDispatch: ... + def dispatch_call(self, frame: FrameType, arg: None) -> _TraceDispatch: ... + def dispatch_return(self, frame: FrameType, arg: Any) -> _TraceDispatch: ... + def dispatch_exception(self, frame: FrameType, arg: _ExcInfo) -> _TraceDispatch: ... + def is_skipped_module(self, module_name: str) -> bool: ... + def stop_here(self, frame: FrameType) -> bool: ... + def break_here(self, frame: FrameType) -> bool: ... + def do_clear(self, arg: Any) -> None: ... + def break_anywhere(self, frame: FrameType) -> bool: ... + def user_call(self, frame: FrameType, argument_list: None) -> None: ... + def user_line(self, frame: FrameType) -> None: ... + def user_return(self, frame: FrameType, return_value: Any) -> None: ... + def user_exception(self, frame: FrameType, exc_info: _ExcInfo) -> None: ... + def set_until(self, frame: FrameType, lineno: Optional[int] = ...) -> None: ... + def set_step(self) -> None: ... + def set_next(self, frame: FrameType) -> None: ... + def set_return(self, frame: FrameType) -> None: ... + def set_trace(self, frame: Optional[FrameType] = ...) -> None: ... + def set_continue(self) -> None: ... + def set_quit(self) -> None: ... + def set_break(self, filename: str, lineno: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ...) -> None: ... + def clear_break(self, filename: str, lineno: int) -> None: ... + def clear_bpbynumber(self, arg: SupportsInt) -> None: ... + def clear_all_file_breaks(self, filename: str) -> None: ... + def clear_all_breaks(self) -> None: ... + def get_bpbynumber(self, arg: SupportsInt) -> Breakpoint: ... + def get_break(self, filename: str, lineno: int) -> bool: ... + def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ... + def get_file_breaks(self, filename: str) -> List[Breakpoint]: ... + def get_all_breaks(self) -> List[Breakpoint]: ... + def get_stack(self, f: FrameType, t: TracebackType) -> Tuple[List[Tuple[FrameType, int]], int]: ... + def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ... + def run(self, cmd: Union[str, CodeType], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> None: ... + def runeval(self, expr: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> None: ... + def runctx(self, cmd: Union[str, CodeType], globals: Dict[str, Any], locals: Dict[str, Any]) -> None: ... + def runcall(self, func: Callable[[Any], _T], *args: Any, **kwds: Any) -> Optional[_T]: ... + +class Breakpoint: + + next: int = ... + bplist: Dict[Tuple[str, int], List[Breakpoint]] = ... + bpbynumber: List[Optional[Breakpoint]] = ... + + funcname: Optional[str] + func_first_executable_line: Optional[int] + file: str + line: int + temporary: bool + cond: Optional[str] + enabled: bool + ignore: int + hits: int + number: int + + def __init__(self, file: str, line: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ...) -> None: ... + def deleteMe(self) -> None: ... + def enable(self) -> None: ... + def disable(self) -> None: ... + def bpprint(self, out: Optional[IO[str]] = ...) -> None: ... + def bpformat(self) -> str: ... + def __str__(self) -> str: ... + +def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ... +def effective(file: str, line: int, frame: FrameType) -> Union[Tuple[Breakpoint, bool], Tuple[None, None]]: ... +def set_trace() -> None: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 966e150897eb..453cc040aefa 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -11,12 +11,17 @@ from typing import ( ) from abc import abstractmethod, ABCMeta from ast import mod, AST -from types import TracebackType, CodeType, ModuleType +from types import TracebackType, CodeType import sys if sys.version_info >= (3,): from typing import SupportsBytes, SupportsRound +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + _T = TypeVar('_T') _T_co = TypeVar('_T_co', covariant=True) _KT = TypeVar('_KT') @@ -29,6 +34,9 @@ _T4 = TypeVar('_T4') _T5 = TypeVar('_T5') _TT = TypeVar('_TT', bound='type') +class _SupportsIndex(Protocol): + def __index__(self) -> int: ... + class object: __doc__: Optional[str] __dict__: Dict[str, Any] @@ -129,10 +137,12 @@ class super(object): class int: @overload - def __init__(self, x: Union[Text, bytes, SupportsInt] = ...) -> None: ... + def __init__(self, x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> None: ... @overload def __init__(self, x: Union[Text, bytes, bytearray], base: int) -> None: ... + if sys.version_info >= (3, 8): + def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ... @property def real(self) -> int: ... @property @@ -209,7 +219,7 @@ class int: def __index__(self) -> int: ... class float: - def __init__(self, x: Union[SupportsFloat, Text, bytes, bytearray] = ...) -> None: ... + def __init__(self, x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> None: ... def as_integer_ratio(self) -> Tuple[int, int]: ... def hex(self) -> str: ... def is_integer(self) -> bool: ... @@ -271,11 +281,9 @@ class float: class complex: @overload - def __init__(self, re: float = ..., im: float = ...) -> None: ... - @overload - def __init__(self, s: str) -> None: ... + def __init__(self, real: float = ..., imag: float = ...) -> None: ... @overload - def __init__(self, s: SupportsComplex) -> None: ... + def __init__(self, real: Union[str, SupportsComplex, _SupportsIndex]) -> None: ... @property def real(self) -> float: ... @@ -804,12 +812,12 @@ class memoryview(Sized, Container[_mv_container_type]): def __iter__(self) -> Iterator[_mv_container_type]: ... def __len__(self) -> int: ... + @overload + def __setitem__(self, s: slice, o: memoryview) -> None: ... @overload def __setitem__(self, i: int, o: bytes) -> None: ... @overload def __setitem__(self, s: slice, o: Sequence[bytes]) -> None: ... - @overload - def __setitem__(self, s: slice, o: memoryview) -> None: ... def tobytes(self) -> bytes: ... def tolist(self) -> List[int]: ... @@ -987,6 +995,8 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __setitem__(self, k: _KT, v: _VT) -> None: ... def __delitem__(self, v: _KT) -> None: ... def __iter__(self) -> Iterator[_KT]: ... + if sys.version_info >= (3, 8): + def __reversed__(self) -> Iterator[_KT]: ... def __str__(self) -> str: ... __hash__: None # type: ignore @@ -1117,8 +1127,6 @@ if sys.version_info < (3,): if sys.version_info >= (3,): def ascii(__o: object) -> str: ... -class _SupportsIndex(Protocol): - def __index__(self) -> int: ... def bin(__number: Union[int, _SupportsIndex]) -> str: ... if sys.version_info >= (3, 7): @@ -1160,20 +1168,15 @@ if sys.version_info >= (3,): def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ... else: @overload - def filter(__function: Callable[[AnyStr], Any], # type: ignore - __iterable: AnyStr) -> AnyStr: ... + def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore @overload - def filter(__function: None, # type: ignore - __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... + def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: Callable[[_T], Any], # type: ignore - __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... + def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore @overload - def filter(__function: None, - __iterable: Iterable[Optional[_T]]) -> List[_T]: ... + def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ... @overload - def filter(__function: Callable[[_T], Any], - __iterable: Iterable[_T]) -> List[_T]: ... + def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ... def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ... def globals() -> Dict[str, Any]: ... @@ -1193,7 +1196,7 @@ def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ... @overload def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ... @overload -def iter(__function: Callable[[], Any], __sentinel: Any) -> Iterator[Any]: ... +def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ... def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ... def len(__o: Sized) -> int: ... @@ -1383,7 +1386,7 @@ if sys.version_info >= (3,): @overload def round(number: SupportsRound[_T]) -> int: ... @overload - def round(number: SupportsRound[_T], ndigits: None) -> int: ... # type: ignore + def round(number: SupportsRound[_T], ndigits: None) -> int: ... @overload def round(number: SupportsRound[_T], ndigits: int) -> _T: ... else: @@ -1452,7 +1455,7 @@ else: def __import__(name: Text, globals: Optional[Mapping[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ..., fromlist: Sequence[str] = ..., - level: int = ...) -> ModuleType: ... + level: int = ...) -> Any: ... # Actually the type of Ellipsis is , but since it's # not exposed anywhere under that name, we make it private here. diff --git a/stdlib/2and3/cProfile.pyi b/stdlib/2and3/cProfile.pyi index da0eb21dfc0d..c6a11721d6ef 100644 --- a/stdlib/2and3/cProfile.pyi +++ b/stdlib/2and3/cProfile.pyi @@ -22,3 +22,6 @@ class Profile: def run(self: _SelfT, cmd: str) -> _SelfT: ... def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ... def runcall(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ... + if sys.version_info >= (3, 8): + def __enter__(self: _SelfT) -> _SelfT: ... + def __exit__(self, *exc_info: Any) -> None: ... diff --git a/stdlib/2and3/cgi.pyi b/stdlib/2and3/cgi.pyi index 0f580ccfce7f..5d901d93dc1c 100644 --- a/stdlib/2and3/cgi.pyi +++ b/stdlib/2and3/cgi.pyi @@ -5,8 +5,9 @@ _T = TypeVar('_T', bound=FieldStorage) def parse(fp: IO[Any] = ..., environ: Mapping[str, str] = ..., keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ... -def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ... -def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ... +if sys.version_info < (3, 8): + def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ... + def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ... if sys.version_info >= (3, 7): def parse_multipart(fp: IO[Any], pdict: Mapping[str, bytes], encoding: str = ..., errors: str = ...) -> Dict[str, List[Any]]: ... else: @@ -17,11 +18,10 @@ def print_environ(environ: Mapping[str, str] = ...) -> None: ... def print_form(form: Dict[str, Any]) -> None: ... def print_directory() -> None: ... def print_environ_usage() -> None: ... -if sys.version_info >= (3, 0): - def escape(s: str, quote: bool = ...) -> str: ... -else: +if sys.version_info < (3,): def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ... - +elif sys.version_info < (3, 8): + def escape(s: str, quote: bool = ...) -> str: ... class MiniFieldStorage: # The first five "Any" attributes here are always None, but mypy doesn't support that diff --git a/stdlib/2and3/cgitb.pyi b/stdlib/2and3/cgitb.pyi new file mode 100644 index 000000000000..ded055cb485c --- /dev/null +++ b/stdlib/2and3/cgitb.pyi @@ -0,0 +1,33 @@ + +from typing import Dict, Any, List, Tuple, Optional, Callable, Type, Union, IO, AnyStr, TypeVar +from types import FrameType, TracebackType +import sys + + +_T = TypeVar("_T") +_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] +if sys.version_info >= (3, 6): + from os import PathLike + _Path = Union[_T, PathLike[_T]] +else: + _Path = Union[_T] + + +def reset() -> str: ... # undocumented +def small(text: str) -> str: ... # undocumented +def strong(text: str) -> str: ... # undocumented +def grey(text: str) -> str: ... # undocumented +def lookup(name: str, frame: FrameType, locals: Dict[str, Any]) -> Tuple[Optional[str], Any]: ... # undocumented +def scanvars(reader: Callable[[], bytes], frame: FrameType, locals: Dict[str, Any]) -> List[Tuple[str, Optional[str], Any]]: ... # undocumented +def html(einfo: _ExcInfo, context: int = ...) -> str: ... +def text(einfo: _ExcInfo, context: int = ...) -> str: ... + +class Hook: # undocumented + + def __init__(self, display: int = ..., logdir: Optional[_Path[AnyStr]] = ..., context: int = ..., file: Optional[IO[str]] = ..., format: str = ...) -> None: ... + def __call__(self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType]) -> None: ... + def handle(self, info: Optional[_ExcInfo] = ...) -> None: ... + +def handler(info: Optional[_ExcInfo] = ...) -> None: ... + +def enable(display: int = ..., logdir: Optional[_Path[AnyStr]] = ..., context: int = ..., format: str = ...) -> None: ... diff --git a/stdlib/2and3/crypt.pyi b/stdlib/2and3/crypt.pyi index d55fc263e90d..621ce0bd7150 100644 --- a/stdlib/2and3/crypt.pyi +++ b/stdlib/2and3/crypt.pyi @@ -1,6 +1,5 @@ import sys -from typing import List, NamedTuple, Optional, Union - +from typing import List, Optional, Union if sys.version_info >= (3, 3): class _Method: ... diff --git a/stdlib/2and3/csv.pyi b/stdlib/2and3/csv.pyi index 28a35fab9cc0..e8cbf630e9db 100644 --- a/stdlib/2and3/csv.pyi +++ b/stdlib/2and3/csv.pyi @@ -1,6 +1,6 @@ from collections import OrderedDict import sys -from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Type, Union +from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, Union from _csv import (_reader, _writer, @@ -64,7 +64,7 @@ class DictReader(Iterator[_DRMapping]): dialect: _Dialect line_num: int fieldnames: Sequence[str] - def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ..., + def __init__(self, f: Iterable[Text], fieldnames: Sequence[str] = ..., restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ..., *args: Any, **kwds: Any) -> None: ... def __iter__(self) -> DictReader: ... diff --git a/stdlib/2and3/ctypes/__init__.pyi b/stdlib/2and3/ctypes/__init__.pyi index 2c7653f5f40f..d07efd65e8f8 100644 --- a/stdlib/2and3/ctypes/__init__.pyi +++ b/stdlib/2and3/ctypes/__init__.pyi @@ -24,8 +24,15 @@ class CDLL(object): _name: str = ... _handle: int = ... _FuncPtr: Type[_FuncPointer] = ... - def __init__(self, name: str, mode: int = ..., handle: Optional[int] = ..., - use_errno: bool = ..., use_last_error: bool = ...) -> None: ... + def __init__( + self, + name: str, + mode: int = ..., + handle: Optional[int] = ..., + use_errno: bool = ..., + use_last_error: bool = ..., + winmode: Optional[int] = ..., + ) -> None: ... def __getattr__(self, name: str) -> _FuncPointer: ... def __getitem__(self, name: str) -> _FuncPointer: ... if sys.platform == 'win32': diff --git a/stdlib/2and3/datetime.pyi b/stdlib/2and3/datetime.pyi index df3fda4a3ae4..772b8398f2c7 100644 --- a/stdlib/2and3/datetime.pyi +++ b/stdlib/2and3/datetime.pyi @@ -1,9 +1,8 @@ import sys from time import struct_time -from typing import ( - AnyStr, Optional, SupportsAbs, Tuple, Union, overload, - ClassVar, -) +from typing import AnyStr, Optional, SupportsAbs, Tuple, Union, overload, ClassVar, Type, TypeVar + +_S = TypeVar("_S") if sys.version_info >= (3,): _Text = str @@ -38,14 +37,17 @@ class date: def __init__(self, year: int, month: int, day: int) -> None: ... @classmethod - def fromtimestamp(cls, t: float) -> date: ... + def fromtimestamp(cls: Type[_S], t: float) -> _S: ... @classmethod - def today(cls) -> date: ... + def today(cls: Type[_S]) -> _S: ... @classmethod - def fromordinal(cls, n: int) -> date: ... + def fromordinal(cls: Type[_S], n: int) -> _S: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls, date_string: str) -> date: ... + def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... + if sys.version_info >= (3, 8): + @classmethod + def fromisocalendar(cls: Type[_S], year: int, week: int, day: int) -> _S: ... @property def year(self) -> int: ... @@ -68,7 +70,10 @@ class date: def __lt__(self, other: date) -> bool: ... def __ge__(self, other: date) -> bool: ... def __gt__(self, other: date) -> bool: ... - def __add__(self, other: timedelta) -> date: ... + if sys.version_info >= (3, 8): + def __add__(self: _S, other: timedelta) -> _S: ... + else: + def __add__(self, other: timedelta) -> date: ... @overload def __sub__(self, other: timedelta) -> date: ... @overload @@ -112,7 +117,7 @@ class time: def isoformat(self) -> str: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls, time_string: str) -> time: ... + def fromisoformat(cls: Type[_S], time_string: str) -> _S: ... def strftime(self, fmt: _Text) -> str: ... if sys.version_info >= (3,): def __format__(self, fmt: str) -> str: ... @@ -220,17 +225,25 @@ class datetime(date): def fold(self) -> int: ... @classmethod - def fromtimestamp(cls, t: float, tz: Optional[_tzinfo] = ...) -> datetime: ... + def fromtimestamp(cls: Type[_S], t: float, tz: Optional[_tzinfo] = ...) -> _S: ... @classmethod - def utcfromtimestamp(cls, t: float) -> datetime: ... + def utcfromtimestamp(cls: Type[_S], t: float) -> _S: ... @classmethod - def today(cls) -> datetime: ... + def today(cls: Type[_S]) -> _S: ... @classmethod - def fromordinal(cls, n: int) -> datetime: ... - @classmethod - def now(cls, tz: Optional[_tzinfo] = ...) -> datetime: ... + def fromordinal(cls: Type[_S], n: int) -> _S: ... + if sys.version_info >= (3, 8): + @classmethod + def now(cls: Type[_S], tz: Optional[_tzinfo] = ...) -> _S: ... + else: + @overload + @classmethod + def now(cls: Type[_S], tz: None = ...) -> _S: ... + @overload + @classmethod + def now(cls, tz: _tzinfo) -> datetime: ... @classmethod - def utcnow(cls) -> datetime: ... + def utcnow(cls: Type[_S]) -> _S: ... if sys.version_info >= (3, 6): @classmethod def combine(cls, date: _date, time: _time, tzinfo: Optional[_tzinfo] = ...) -> datetime: ... @@ -239,7 +252,7 @@ class datetime(date): def combine(cls, date: _date, time: _time) -> datetime: ... if sys.version_info >= (3, 7): @classmethod - def fromisoformat(cls, date_string: str) -> datetime: ... + def fromisoformat(cls: Type[_S], date_string: str) -> _S: ... def strftime(self, fmt: _Text) -> str: ... if sys.version_info >= (3,): def __format__(self, fmt: str) -> str: ... @@ -261,7 +274,9 @@ class datetime(date): def replace(self, year: int = ..., month: int = ..., day: int = ..., hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: Optional[_tzinfo] = ...) -> datetime: ... - if sys.version_info >= (3, 3): + if sys.version_info >= (3, 8): + def astimezone(self: _S, tz: Optional[_tzinfo] = ...) -> _S: ... + elif sys.version_info >= (3, 3): def astimezone(self, tz: Optional[_tzinfo] = ...) -> datetime: ... else: def astimezone(self, tz: _tzinfo) -> datetime: ... @@ -279,7 +294,10 @@ class datetime(date): def __lt__(self, other: datetime) -> bool: ... # type: ignore def __ge__(self, other: datetime) -> bool: ... # type: ignore def __gt__(self, other: datetime) -> bool: ... # type: ignore - def __add__(self, other: timedelta) -> datetime: ... + if sys.version_info >= (3, 8): + def __add__(self: _S, other: timedelta) -> _S: ... + else: + def __add__(self, other: timedelta) -> datetime: ... @overload # type: ignore def __sub__(self, other: datetime) -> timedelta: ... @overload diff --git a/stdlib/2and3/decimal.pyi b/stdlib/2and3/decimal.pyi index 2018ed8446c6..06193c7a7b89 100644 --- a/stdlib/2and3/decimal.pyi +++ b/stdlib/2and3/decimal.pyi @@ -13,10 +13,10 @@ else: _ComparableNum = Union[Decimal, float] _DecimalT = TypeVar('_DecimalT', bound=Decimal) -DecimalTuple = NamedTuple('DecimalTuple', - [('sign', int), - ('digits', Tuple[int, ...]), - ('exponent', int)]) +class DecimalTuple(NamedTuple): + sign: int + digits: Tuple[int, ...] + exponent: int ROUND_DOWN: str ROUND_HALF_UP: str diff --git a/stdlib/2and3/difflib.pyi b/stdlib/2and3/difflib.pyi index ddcec11dd02b..197c5d03c16d 100644 --- a/stdlib/2and3/difflib.pyi +++ b/stdlib/2and3/difflib.pyi @@ -16,11 +16,10 @@ else: _JunkCallback = Union[Callable[[Text], bool], Callable[[str], bool]] -Match = NamedTuple('Match', [ - ('a', int), - ('b', int), - ('size', int), -]) +class Match(NamedTuple): + a: int + b: int + size: int class SequenceMatcher(Generic[_T]): def __init__(self, isjunk: Optional[Callable[[_T], bool]] = ..., diff --git a/stdlib/2and3/dis.pyi b/stdlib/2and3/dis.pyi index 0ef27f4af49f..22630a5b2178 100644 --- a/stdlib/2and3/dis.pyi +++ b/stdlib/2and3/dis.pyi @@ -21,19 +21,15 @@ _have_code_or_string = Union[_have_code, str, bytes] if sys.version_info >= (3, 4): - Instruction = NamedTuple( - "Instruction", - [ - ('opname', str), - ('opcode', int), - ('arg', Optional[int]), - ('argval', Any), - ('argrepr', str), - ('offset', int), - ('starts_line', Optional[int]), - ('is_jump_target', bool) - ] - ) + class Instruction(NamedTuple): + opname: str + opcode: int + arg: Optional[int] + argval: Any + argrepr: str + offset: int + starts_line: Optional[int] + is_jump_target: bool class Bytecode: codeobj: types.CodeType diff --git a/stdlib/2and3/doctest.pyi b/stdlib/2and3/doctest.pyi index b6df8c5b053d..54a8c8745cf8 100644 --- a/stdlib/2and3/doctest.pyi +++ b/stdlib/2and3/doctest.pyi @@ -4,10 +4,9 @@ import sys import types import unittest -TestResults = NamedTuple('TestResults', [ - ('failed', int), - ('attempted', int), -]) +class TestResults(NamedTuple): + failed: int + attempted: int OPTIONFLAGS_BY_NAME: Dict[str, int] def register_optionflag(name: str) -> int: ... diff --git a/stdlib/2and3/ensurepip/__init__.pyi b/stdlib/2and3/ensurepip/__init__.pyi new file mode 100644 index 000000000000..10634f2baa6d --- /dev/null +++ b/stdlib/2and3/ensurepip/__init__.pyi @@ -0,0 +1,10 @@ + +from typing import Optional +import sys + + +def version() -> str: ... +if sys.version_info >= (3, 0): + def bootstrap(*, root: Optional[str] = ..., upgrade: bool = ..., user: bool = ..., altinstall: bool = ..., default_pip: bool = ..., verbosity: int = ...) -> None: ... +else: + def bootstrap(root: Optional[str] = ..., upgrade: bool = ..., user: bool = ..., altinstall: bool = ..., default_pip: bool = ..., verbosity: int = ...) -> None: ... diff --git a/stdlib/2and3/fileinput.pyi b/stdlib/2and3/fileinput.pyi index 0eb8ca9d8840..e5c20e52c462 100644 --- a/stdlib/2and3/fileinput.pyi +++ b/stdlib/2and3/fileinput.pyi @@ -8,15 +8,24 @@ if sys.version_info >= (3, 6): else: _Path = Union[Text, bytes] - -def input( - files: Union[_Path, Iterable[_Path], None] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[_Path, str], IO[AnyStr]] = ...) -> FileInput[AnyStr]: ... - +if sys.version_info >= (3, 8): + def input( + files: Union[_Path, Iterable[_Path], None] = ..., + inplace: bool = ..., + backup: str = ..., + *, + mode: str = ..., + openhook: Callable[[_Path, str], IO[AnyStr]] = ..., + ) -> FileInput[AnyStr]: ... +else: + def input( + files: Union[_Path, Iterable[_Path], None] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[_Path, str], IO[AnyStr]] = ..., + ) -> FileInput[AnyStr]: ... def close() -> None: ... def nextfile() -> None: ... @@ -28,15 +37,26 @@ def isfirstline() -> bool: ... def isstdin() -> bool: ... class FileInput(Iterable[AnyStr], Generic[AnyStr]): - def __init__( - self, - files: Union[None, _Path, Iterable[_Path]] = ..., - inplace: bool = ..., - backup: str = ..., - bufsize: int = ..., - mode: str = ..., - openhook: Callable[[_Path, str], IO[AnyStr]] = ... - ) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, + files: Union[None, _Path, Iterable[_Path]] = ..., + inplace: bool = ..., + backup: str = ..., + *, + mode: str = ..., + openhook: Callable[[_Path, str], IO[AnyStr]] = ... + ) -> None: ... + else: + def __init__( + self, + files: Union[None, _Path, Iterable[_Path]] = ..., + inplace: bool = ..., + backup: str = ..., + bufsize: int = ..., + mode: str = ..., + openhook: Callable[[_Path, str], IO[AnyStr]] = ... + ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... diff --git a/stdlib/2and3/fractions.pyi b/stdlib/2and3/fractions.pyi index 8bebe5fc89e8..ce3f89f88419 100644 --- a/stdlib/2and3/fractions.pyi +++ b/stdlib/2and3/fractions.pyi @@ -4,7 +4,7 @@ # Note: these stubs are incomplete. The more complex type # signatures are currently omitted. Also see numbers.pyi. -from typing import Optional, TypeVar, Union, overload, Any +from typing import Optional, TypeVar, Union, overload, Any, Tuple from numbers import Real, Integral, Rational from decimal import Decimal import sys @@ -42,6 +42,8 @@ class Fraction(Rational): def from_decimal(cls, dec: Decimal) -> Fraction: ... def limit_denominator(self, max_denominator: int = ...) -> Fraction: ... + if sys.version_info >= (3, 8): + def as_integer_ratio(self) -> Tuple[int, int]: ... @property def numerator(self) -> int: ... @property diff --git a/stdlib/2and3/grp.pyi b/stdlib/2and3/grp.pyi index 605472721b89..5b5855583243 100644 --- a/stdlib/2and3/grp.pyi +++ b/stdlib/2and3/grp.pyi @@ -1,9 +1,10 @@ from typing import List, NamedTuple, Optional -struct_group = NamedTuple("struct_group", [("gr_name", str), - ("gr_passwd", Optional[str]), - ("gr_gid", int), - ("gr_mem", List[str])]) +class struct_group(NamedTuple): + gr_name: str + gr_passwd: Optional[str] + gr_gid: int + gr_mem: List[str] def getgrall() -> List[struct_group]: ... def getgrgid(gid: int) -> struct_group: ... diff --git a/stdlib/2and3/logging/__init__.pyi b/stdlib/2and3/logging/__init__.pyi index 79ee6261b22b..13117947161e 100644 --- a/stdlib/2and3/logging/__init__.pyi +++ b/stdlib/2and3/logging/__init__.pyi @@ -186,7 +186,7 @@ class Formatter: datefmt: Optional[str] = ...) -> None: ... def format(self, record: LogRecord) -> str: ... - def formatTime(self, record: LogRecord, datefmt: str = ...) -> str: ... + def formatTime(self, record: LogRecord, datefmt: Optional[str] = ...) -> str: ... def formatException(self, exc_info: _SysExcInfoType) -> str: ... if sys.version_info >= (3,): def formatMessage(self, record: LogRecord) -> str: ... # undocumented diff --git a/stdlib/2and3/macpath.pyi b/stdlib/2and3/macpath.pyi index c0bf57658ed7..324fc7b31a11 100644 --- a/stdlib/2and3/macpath.pyi +++ b/stdlib/2and3/macpath.pyi @@ -1,180 +1,171 @@ -# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent! # Stubs for os.path # Ron Murawski import os import sys -from typing import ( - overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, - TypeVar, Union, Text, Callable, Optional -) - -_T = TypeVar('_T') - -if sys.version_info >= (3, 6): - from builtins import _PathLike - _PathType = Union[bytes, Text, _PathLike] - _StrPath = Union[Text, _PathLike[Text]] - _BytesPath = Union[bytes, _PathLike[bytes]] -else: - _PathType = Union[bytes, Text] - _StrPath = Text - _BytesPath = bytes - -# ----- os.path variables ----- -supports_unicode_filenames: bool -# aliases (also in os) -curdir: str -pardir: str -sep: str -if sys.platform == 'win32': - altsep: str -else: +from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional + +if sys.version_info < (3, 8): + _T = TypeVar('_T') + + if sys.version_info >= (3, 6): + from builtins import _PathLike + _PathType = Union[bytes, Text, _PathLike] + _StrPath = Union[Text, _PathLike[Text]] + _BytesPath = Union[bytes, _PathLike[bytes]] + else: + _PathType = Union[bytes, Text] + _StrPath = Text + _BytesPath = bytes + + # ----- os.path variables ----- + supports_unicode_filenames: bool + # aliases (also in os) + curdir: str + pardir: str + sep: str altsep: Optional[str] -extsep: str -pathsep: str -defpath: str -devnull: str - -# ----- os.path function stubs ----- -if sys.version_info >= (3, 6): - # Overloads are necessary to work around python/mypy#3644. - @overload - def abspath(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def abspath(path: AnyStr) -> AnyStr: ... - @overload - def basename(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def basename(path: AnyStr) -> AnyStr: ... - @overload - def dirname(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def dirname(path: AnyStr) -> AnyStr: ... - @overload - def expanduser(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def expanduser(path: AnyStr) -> AnyStr: ... - @overload - def expandvars(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def expandvars(path: AnyStr) -> AnyStr: ... - @overload - def normcase(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def normcase(path: AnyStr) -> AnyStr: ... - @overload - def normpath(path: _PathLike[AnyStr]) -> AnyStr: ... - @overload - def normpath(path: AnyStr) -> AnyStr: ... - if sys.platform == 'win32': + extsep: str + pathsep: str + defpath: str + devnull: str + + # ----- os.path function stubs ----- + if sys.version_info >= (3, 6): + # Overloads are necessary to work around python/mypy#3644. @overload - def realpath(path: _PathLike[AnyStr]) -> AnyStr: ... + def abspath(path: _PathLike[AnyStr]) -> AnyStr: ... @overload - def realpath(path: AnyStr) -> AnyStr: ... - else: + def abspath(path: AnyStr) -> AnyStr: ... + @overload + def basename(path: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def basename(path: AnyStr) -> AnyStr: ... + @overload + def dirname(path: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def dirname(path: AnyStr) -> AnyStr: ... @overload - def realpath(filename: _PathLike[AnyStr]) -> AnyStr: ... + def expanduser(path: _PathLike[AnyStr]) -> AnyStr: ... @overload - def realpath(filename: AnyStr) -> AnyStr: ... + def expanduser(path: AnyStr) -> AnyStr: ... + @overload + def expandvars(path: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def expandvars(path: AnyStr) -> AnyStr: ... + @overload + def normcase(path: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def normcase(path: AnyStr) -> AnyStr: ... + @overload + def normpath(path: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def normpath(path: AnyStr) -> AnyStr: ... + if sys.platform == 'win32': + @overload + def realpath(path: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def realpath(path: AnyStr) -> AnyStr: ... + else: + @overload + def realpath(filename: _PathLike[AnyStr]) -> AnyStr: ... + @overload + def realpath(filename: AnyStr) -> AnyStr: ... -else: - def abspath(path: AnyStr) -> AnyStr: ... - def basename(path: AnyStr) -> AnyStr: ... - def dirname(path: AnyStr) -> AnyStr: ... - def expanduser(path: AnyStr) -> AnyStr: ... - def expandvars(path: AnyStr) -> AnyStr: ... - def normcase(path: AnyStr) -> AnyStr: ... - def normpath(path: AnyStr) -> AnyStr: ... - if sys.platform == 'win32': - def realpath(path: AnyStr) -> AnyStr: ... else: - def realpath(filename: AnyStr) -> AnyStr: ... - -if sys.version_info >= (3, 6): - # In reality it returns str for sequences of _StrPath and bytes for sequences - # of _BytesPath, but mypy does not accept such a signature. - def commonpath(paths: Sequence[_PathType]) -> Any: ... -elif sys.version_info >= (3, 5): - def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ... - -# NOTE: Empty lists results in '' (str) regardless of contained type. -# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes -# So, fall back to Any -def commonprefix(list: Sequence[_PathType]) -> Any: ... - -if sys.version_info >= (3, 3): - def exists(path: Union[_PathType, int]) -> bool: ... -else: - def exists(path: _PathType) -> bool: ... -def lexists(path: _PathType) -> bool: ... - -# These return float if os.stat_float_times() == True, -# but int is a subclass of float. -def getatime(path: _PathType) -> float: ... -def getmtime(path: _PathType) -> float: ... -def getctime(path: _PathType) -> float: ... - -def getsize(path: _PathType) -> int: ... -def isabs(path: _PathType) -> bool: ... -def isfile(path: _PathType) -> bool: ... -def isdir(path: _PathType) -> bool: ... -def islink(path: _PathType) -> bool: ... -def ismount(path: _PathType) -> bool: ... - -if sys.version_info < (3, 0): - # Make sure signatures are disjunct, and allow combinations of bytes and unicode. - # (Since Python 2 allows that, too) - # Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in - # a type error. - @overload - def join(__p1: bytes, *p: bytes) -> bytes: ... - @overload - def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ... - @overload - def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ... - @overload - def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ... - @overload - def join(__p1: Text, *p: _PathType) -> Text: ... -elif sys.version_info >= (3, 6): - # Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway. - @overload - def join(path: _StrPath, *paths: _StrPath) -> Text: ... - @overload - def join(path: _BytesPath, *paths: _BytesPath) -> bytes: ... -else: - def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... - -@overload -def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ... -@overload -def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ... - -def samefile(path1: _PathType, path2: _PathType) -> bool: ... -def sameopenfile(fp1: int, fp2: int) -> bool: ... -def samestat(stat1: os.stat_result, stat2: os.stat_result) -> bool: ... + def abspath(path: AnyStr) -> AnyStr: ... + def basename(path: AnyStr) -> AnyStr: ... + def dirname(path: AnyStr) -> AnyStr: ... + def expanduser(path: AnyStr) -> AnyStr: ... + def expandvars(path: AnyStr) -> AnyStr: ... + def normcase(path: AnyStr) -> AnyStr: ... + def normpath(path: AnyStr) -> AnyStr: ... + if sys.platform == 'win32': + def realpath(path: AnyStr) -> AnyStr: ... + else: + def realpath(filename: AnyStr) -> AnyStr: ... + + if sys.version_info >= (3, 6): + # In reality it returns str for sequences of _StrPath and bytes for sequences + # of _BytesPath, but mypy does not accept such a signature. + def commonpath(paths: Sequence[_PathType]) -> Any: ... + elif sys.version_info >= (3, 5): + def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ... + + # NOTE: Empty lists results in '' (str) regardless of contained type. + # Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes + # So, fall back to Any + def commonprefix(list: Sequence[_PathType]) -> Any: ... + + if sys.version_info >= (3, 3): + def exists(path: Union[_PathType, int]) -> bool: ... + else: + def exists(path: _PathType) -> bool: ... + def lexists(path: _PathType) -> bool: ... + + # These return float if os.stat_float_times() == True, + # but int is a subclass of float. + def getatime(path: _PathType) -> float: ... + def getmtime(path: _PathType) -> float: ... + def getctime(path: _PathType) -> float: ... + + def getsize(path: _PathType) -> int: ... + def isabs(path: _PathType) -> bool: ... + def isfile(path: _PathType) -> bool: ... + def isdir(path: _PathType) -> bool: ... + def islink(path: _PathType) -> bool: ... + def ismount(path: _PathType) -> bool: ... + + if sys.version_info < (3, 0): + # Make sure signatures are disjunct, and allow combinations of bytes and unicode. + # (Since Python 2 allows that, too) + # Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in + # a type error. + @overload + def join(__p1: bytes, *p: bytes) -> bytes: ... + @overload + def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ... + @overload + def join(__p1: Text, *p: _PathType) -> Text: ... + elif sys.version_info >= (3, 6): + # Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway. + @overload + def join(path: _StrPath, *paths: _StrPath) -> Text: ... + @overload + def join(path: _BytesPath, *paths: _BytesPath) -> bytes: ... + else: + def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ... -if sys.version_info >= (3, 6): - @overload - def split(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... - @overload - def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... @overload - def splitdrive(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ... @overload - def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... - @overload - def splitext(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... - @overload - def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -else: - def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... - def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... - def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ... + + def samefile(path1: _PathType, path2: _PathType) -> bool: ... + def sameopenfile(fp1: int, fp2: int) -> bool: ... + def samestat(stat1: os.stat_result, stat2: os.stat_result) -> bool: ... -if sys.platform == 'win32': - def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated + if sys.version_info >= (3, 6): + @overload + def split(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + @overload + def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + @overload + def splitdrive(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + @overload + def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + @overload + def splitext(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... + @overload + def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + else: + def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... + def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -if sys.version_info < (3,): - def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... + if sys.version_info < (3,): + def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ... diff --git a/stdlib/2and3/math.pyi b/stdlib/2and3/math.pyi index b3b8579280cf..aa8b191ae0a4 100644 --- a/stdlib/2and3/math.pyi +++ b/stdlib/2and3/math.pyi @@ -1,7 +1,7 @@ # Stubs for math # See: http://docs.python.org/2/library/math.html -from typing import Tuple, Iterable, SupportsFloat, SupportsInt +from typing import Tuple, Iterable, SupportsFloat, SupportsInt, overload import sys @@ -28,6 +28,8 @@ def copysign(x: SupportsFloat, y: SupportsFloat) -> float: ... def cos(x: SupportsFloat) -> float: ... def cosh(x: SupportsFloat) -> float: ... def degrees(x: SupportsFloat) -> float: ... +if sys.version_info >= (3, 8): + def dist(__p: Iterable[SupportsFloat], __q: Iterable[SupportsFloat]) -> float: ... def erf(x: SupportsFloat) -> float: ... def erfc(x: SupportsFloat) -> float: ... def exp(x: SupportsFloat) -> float: ... @@ -44,13 +46,18 @@ def fsum(iterable: Iterable[float]) -> float: ... def gamma(x: SupportsFloat) -> float: ... if sys.version_info >= (3, 5): def gcd(a: int, b: int) -> int: ... -def hypot(x: SupportsFloat, y: SupportsFloat) -> float: ... +if sys.version_info >= (3, 8): + def hypot(*coordinates: SupportsFloat) -> float: ... +else: + def hypot(__x: SupportsFloat, __y: SupportsFloat) -> float: ... if sys.version_info >= (3, 5): def isclose(a: SupportsFloat, b: SupportsFloat, rel_tol: SupportsFloat = ..., abs_tol: SupportsFloat = ...) -> bool: ... def isinf(x: SupportsFloat) -> bool: ... if sys.version_info >= (3,): def isfinite(x: SupportsFloat) -> bool: ... def isnan(x: SupportsFloat) -> bool: ... +if sys.version_info >= (3, 8): + def isqrt(__n: int) -> int: ... def ldexp(x: SupportsFloat, i: int) -> float: ... def lgamma(x: SupportsFloat) -> float: ... def log(x: SupportsFloat, base: SupportsFloat = ...) -> float: ... @@ -60,6 +67,11 @@ if sys.version_info >= (3, 3): def log2(x: SupportsFloat) -> float: ... def modf(x: SupportsFloat) -> Tuple[float, float]: ... def pow(x: SupportsFloat, y: SupportsFloat) -> float: ... +if sys.version_info >= (3, 8): + @overload + def prod(__iterable: Iterable[int], *, start: int = ...) -> int: ... # type: ignore + @overload + def prod(__iterable: Iterable[SupportsFloat], *, start: SupportsFloat = ...) -> float: ... def radians(x: SupportsFloat) -> float: ... if sys.version_info >= (3, 7): def remainder(x: SupportsFloat, y: SupportsFloat) -> float: ... diff --git a/stdlib/2and3/mmap.pyi b/stdlib/2and3/mmap.pyi index b8d040e9cf30..aff41b9b1b45 100644 --- a/stdlib/2and3/mmap.pyi +++ b/stdlib/2and3/mmap.pyi @@ -35,7 +35,10 @@ class _mmap(Generic[AnyStr]): def close(self) -> None: ... def find(self, sub: AnyStr, start: int = ..., end: int = ...) -> int: ... - def flush(self, offset: int = ..., size: int = ...) -> int: ... + if sys.version_info >= (3, 8): + def flush(self, offset: int = ..., size: int = ...) -> None: ... + else: + def flush(self, offset: int = ..., size: int = ...) -> int: ... def move(self, dest: int, src: int, count: int) -> None: ... def read(self, n: int = ...) -> AnyStr: ... def read_byte(self) -> AnyStr: ... @@ -51,6 +54,8 @@ class _mmap(Generic[AnyStr]): if sys.version_info >= (3,): class mmap(_mmap[bytes], ContextManager[mmap], Iterable[bytes], Sized): closed: bool + if sys.version_info >= (3, 8): + def madvise(self, option: int, start: int = ..., length: int = ...) -> None: ... def rfind(self, sub: bytes, start: int = ..., stop: int = ...) -> int: ... @overload def __getitem__(self, index: int) -> int: ... @@ -71,3 +76,27 @@ else: def __getslice__(self, i: Optional[int], j: Optional[int]) -> bytes: ... def __delitem__(self, index: Union[int, slice]) -> None: ... def __setitem__(self, index: Union[int, slice], object: bytes) -> None: ... + +if sys.version_info >= (3, 8): + MADV_NORMAL: int + MADV_RANDOM: int + MADV_SEQUENTIAL: int + MADV_WILLNEED: int + MADV_DONTNEED: int + MADV_REMOVE: int + MADV_DONTFORK: int + MADV_DOFORK: int + MADV_HWPOISON: int + MADV_MERGEABLE: int + MADV_UNMERGEABLE: int + MADV_SOFT_OFFLINE: int + MADV_HUGEPAGE: int + MADV_NOHUGEPAGE: int + MADV_DONTDUMP: int + MADV_DODUMP: int + MADV_FREE: int + MADV_NOSYNC: int + MADV_AUTOSYNC: int + MADV_NOCORE: int + MADV_CORE: int + MADV_PROTECT: int diff --git a/stdlib/2and3/ntpath.pyi b/stdlib/2and3/ntpath.pyi index c0bf57658ed7..42409c0e8721 100644 --- a/stdlib/2and3/ntpath.pyi +++ b/stdlib/2and3/ntpath.pyi @@ -4,10 +4,7 @@ import os import sys -from typing import ( - overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, - TypeVar, Union, Text, Callable, Optional -) +from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional _T = TypeVar('_T') diff --git a/stdlib/2and3/pickle.pyi b/stdlib/2and3/pickle.pyi index e0222324cb20..ec9353f6b751 100644 --- a/stdlib/2and3/pickle.pyi +++ b/stdlib/2and3/pickle.pyi @@ -48,7 +48,8 @@ class Pickler: def dump(self, obj: Any) -> None: ... def clear_memo(self) -> None: ... def persistent_id(self, obj: Any) -> Any: ... - + if sys.version_info >= (3, 8): + def reducer_override(self, obj: Any) -> Any: ... class Unpickler: if sys.version_info >= (3, 0): diff --git a/stdlib/2and3/pkgutil.pyi b/stdlib/2and3/pkgutil.pyi index c7bad4221839..138a0f8b52d7 100644 --- a/stdlib/2and3/pkgutil.pyi +++ b/stdlib/2and3/pkgutil.pyi @@ -9,7 +9,10 @@ else: Loader = Any if sys.version_info >= (3, 6): - ModuleInfo = NamedTuple('ModuleInfo', [('module_finder', Any), ('name', str), ('ispkg', bool)]) + class ModuleInfo(NamedTuple): + module_finder: Any + name: str + ispkg: bool _YMFNI = Generator[ModuleInfo, None, None] else: _YMFNI = Generator[Tuple[Any, str, bool], None, None] @@ -24,7 +27,7 @@ class ImpLoader: def __init__(self, fullname: str, file: IO[str], filename: str, etc: Tuple[str, str, int]) -> None: ... -def find_loader(fullname: str) -> Loader: ... +def find_loader(fullname: str) -> Optional[Loader]: ... def get_importer(path_item: str) -> Any: ... # TODO precise type def get_loader(module_or_name: str) -> Loader: ... def iter_importers(fullname: str = ...) -> Generator[Any, None, None]: ... # TODO precise type diff --git a/stdlib/2and3/plistlib.pyi b/stdlib/2and3/plistlib.pyi index 532be815ebd9..5b840980d819 100644 --- a/stdlib/2and3/plistlib.pyi +++ b/stdlib/2and3/plistlib.pyi @@ -55,3 +55,11 @@ if sys.version_info < (3, 7): class Data: data: bytes def __init__(self, data: bytes) -> None: ... + +if sys.version_info >= (3, 8): + class UID: + data: int + def __init__(self, data: int) -> None: ... + def __index__(self) -> int: ... + def __reduce__(self) -> Any: ... + def __hash__(self) -> int: ... diff --git a/stdlib/2and3/posixpath.pyi b/stdlib/2and3/posixpath.pyi index c0bf57658ed7..42409c0e8721 100644 --- a/stdlib/2and3/posixpath.pyi +++ b/stdlib/2and3/posixpath.pyi @@ -4,10 +4,7 @@ import os import sys -from typing import ( - overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, - TypeVar, Union, Text, Callable, Optional -) +from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional _T = TypeVar('_T') diff --git a/stdlib/2and3/pprint.pyi b/stdlib/2and3/pprint.pyi index 90a87ab0f09c..cd9eb237bbfb 100644 --- a/stdlib/2and3/pprint.pyi +++ b/stdlib/2and3/pprint.pyi @@ -4,21 +4,21 @@ # Based on http://docs.python.org/3/library/pprint.html import sys -from typing import Any, Dict, Tuple, IO +from typing import Any, Dict, Tuple, IO, Optional if sys.version_info >= (3, 4): def pformat(o: object, indent: int = ..., width: int = ..., - depth: int = ..., compact: bool = ...) -> str: ... + depth: Optional[int] = ..., compact: bool = ...) -> str: ... else: def pformat(o: object, indent: int = ..., width: int = ..., - depth: int = ...) -> str: ... + depth: Optional[int] = ...) -> str: ... if sys.version_info >= (3, 4): def pprint(o: object, stream: IO[str] = ..., indent: int = ..., width: int = ..., - depth: int = ..., compact: bool = ...) -> None: ... + depth: Optional[int] = ..., compact: bool = ...) -> None: ... else: def pprint(o: object, stream: IO[str] = ..., indent: int = ..., width: int = ..., - depth: int = ...) -> None: ... + depth: Optional[int] = ...) -> None: ... def isreadable(o: object) -> bool: ... def isrecursive(o: object) -> bool: ... @@ -26,10 +26,10 @@ def saferepr(o: object) -> str: ... class PrettyPrinter: if sys.version_info >= (3, 4): - def __init__(self, indent: int = ..., width: int = ..., depth: int = ..., + def __init__(self, indent: int = ..., width: int = ..., depth: Optional[int] = ..., stream: IO[str] = ..., compact: bool = ...) -> None: ... else: - def __init__(self, indent: int = ..., width: int = ..., depth: int = ..., + def __init__(self, indent: int = ..., width: int = ..., depth: Optional[int] = ..., stream: IO[str] = ...) -> None: ... def pformat(self, o: object) -> str: ... diff --git a/stdlib/2and3/sched.pyi b/stdlib/2and3/sched.pyi index 5d5cf33d23f3..6a820c836ae9 100644 --- a/stdlib/2and3/sched.pyi +++ b/stdlib/2and3/sched.pyi @@ -1,13 +1,12 @@ import sys from typing import Any, Callable, Dict, List, NamedTuple, Optional, Text, Tuple -Event = NamedTuple('Event', [ - ('time', float), - ('priority', Any), - ('action', Callable[..., Any]), - ('argument', Tuple[Any, ...]), - ('kwargs', Dict[Text, Any]), -]) +class Event(NamedTuple): + time: float + priority: Any + action: Callable[..., Any] + argument: Tuple[Any, ...] + kwargs: Dict[Text, Any] class scheduler: if sys.version_info >= (3, 3): diff --git a/stdlib/2and3/select.pyi b/stdlib/2and3/select.pyi index 3fc05450bc40..6387f52c9562 100644 --- a/stdlib/2and3/select.pyi +++ b/stdlib/2and3/select.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Iterable, List, Optional, Protocol, Sequence, Tuple, Union +from typing import Any, Iterable, List, Optional, Protocol, Tuple, Union class _HasFileno(Protocol): def fileno(self) -> int: ... @@ -76,7 +76,7 @@ class poll: def unregister(self, fd: _FileDescriptor) -> None: ... def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ... -def select(rlist: Sequence[Any], wlist: Sequence[Any], xlist: Sequence[Any], +def select(rlist: Iterable[Any], wlist: Iterable[Any], xlist: Iterable[Any], timeout: Optional[float] = ...) -> Tuple[List[Any], List[Any], List[Any]]: ... diff --git a/stdlib/2and3/shutil.pyi b/stdlib/2and3/shutil.pyi index 98761d046f76..b4c6cc129ec1 100644 --- a/stdlib/2and3/shutil.pyi +++ b/stdlib/2and3/shutil.pyi @@ -72,7 +72,17 @@ else: def ignore_patterns(*patterns: _Path) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... -if sys.version_info >= (3,): +if sys.version_info >= (3, 8): + def copytree( + src: _Path, + dst: _Path, + symlinks: bool = ..., + ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[_Path, List[str]], Iterable[str]]] = ..., + copy_function: Callable[[str, str], None] = ..., + ignore_dangling_symlinks: bool = ..., + dirs_exist_ok: bool = ..., + ) -> _PathReturn: ... +elif sys.version_info >= (3,): def copytree(src: _Path, dst: _Path, symlinks: bool = ..., ignore: Union[None, Callable[[str, List[str]], Iterable[str]], @@ -104,9 +114,10 @@ else: def move(src: _Path, dst: _Path) -> _PathReturn: ... if sys.version_info >= (3,): - _ntuple_diskusage = NamedTuple('usage', [('total', int), - ('used', int), - ('free', int)]) + class _ntuple_diskusage(NamedTuple): + total: int + used: int + free: int def disk_usage(path: _Path) -> _ntuple_diskusage: ... def chown(path: _Path, user: Optional[str] = ..., group: Optional[str] = ...) -> None: ... diff --git a/stdlib/2and3/sndhdr.pyi b/stdlib/2and3/sndhdr.pyi index aecd70b46843..7b742c0a902d 100644 --- a/stdlib/2and3/sndhdr.pyi +++ b/stdlib/2and3/sndhdr.pyi @@ -5,13 +5,12 @@ import sys from typing import Any, NamedTuple, Optional, Tuple, Union if sys.version_info >= (3, 5): - SndHeaders = NamedTuple('SndHeaders', [ - ('filetype', str), - ('framerate', int), - ('nchannels', int), - ('nframes', int), - ('sampwidth', Union[int, str]), - ]) + class SndHeaders(NamedTuple): + filetype: str + framerate: int + nchannels: int + nframes: int + sampwidth: Union[int, str] _SndHeaders = SndHeaders else: _SndHeaders = Tuple[str, int, int, int, Union[int, str]] diff --git a/stdlib/2and3/socket.pyi b/stdlib/2and3/socket.pyi index 1a42632187a1..3a5a9de227f0 100644 --- a/stdlib/2and3/socket.pyi +++ b/stdlib/2and3/socket.pyi @@ -585,6 +585,16 @@ class socket: def create_connection(address: Tuple[Optional[str], int], timeout: Optional[float] = ..., source_address: Tuple[Union[bytearray, bytes, Text], int] = ...) -> socket: ... +if sys.version_info >= (3, 8): + def has_dualstack_ipv6() -> bool: ... + def create_server( + address: Tuple[str, int], + *, + family: AddressFamily = ..., + backlog: Optional[int] = ..., + reuse_port: bool = ..., + dualstack_ipv6: bool = ..., + ) -> socket: ... # the 5th tuple item is an address # TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers diff --git a/stdlib/2and3/sqlite3/dbapi2.pyi b/stdlib/2and3/sqlite3/dbapi2.pyi index e338ebbe322b..1acaf2ff630e 100644 --- a/stdlib/2and3/sqlite3/dbapi2.pyi +++ b/stdlib/2and3/sqlite3/dbapi2.pyi @@ -102,10 +102,11 @@ def enable_shared_cache(do_enable: int) -> None: ... def register_adapter(type: Type[_T], callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ... def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ... -class Cache(object): - def __init__(self, *args, **kwargs) -> None: ... - def display(self, *args, **kwargs) -> None: ... - def get(self, *args, **kwargs) -> None: ... +if sys.version_info < (3, 8): + class Cache(object): + def __init__(self, *args, **kwargs) -> None: ... + def display(self, *args, **kwargs) -> None: ... + def get(self, *args, **kwargs) -> None: ... class Connection(object): DataError: Any @@ -283,7 +284,8 @@ class Row(object): def __lt__(self, other): ... def __ne__(self, other): ... -class Statement(object): - def __init__(self, *args, **kwargs): ... +if sys.version_info < (3, 8): + class Statement(object): + def __init__(self, *args, **kwargs): ... class Warning(Exception): ... diff --git a/stdlib/2and3/ssl.pyi b/stdlib/2and3/ssl.pyi index 3e358f356004..3dd685ff0ac3 100644 --- a/stdlib/2and3/ssl.pyi +++ b/stdlib/2and3/ssl.pyi @@ -87,12 +87,13 @@ def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ..., ca_certs: Optional[str] = ...) -> str: ... def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ... def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ... -DefaultVerifyPaths = NamedTuple('DefaultVerifyPaths', - [('cafile', str), ('capath', str), - ('openssl_cafile_env', str), - ('openssl_cafile', str), - ('openssl_capath_env', str), - ('openssl_capath', str)]) +class DefaultVerifyPaths(NamedTuple): + cafile: str + capath: str + openssl_cafile_env: str + openssl_cafile: str + openssl_capath_env: str + openssl_capath: str def get_default_verify_paths() -> DefaultVerifyPaths: ... if sys.platform == 'win32': @@ -173,16 +174,19 @@ ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: int ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: int ALERT_DESCRIPTION_USER_CANCELLED: int +class _ASN1Object(NamedTuple): + nid: int + shortname: str + longname: str + oid: str if sys.version_info < (3,): - class _ASN1Object(NamedTuple('_ASN1Object', [('nid', int), ('shortname', str), ('longname', str), ('oid', str)])): ... class Purpose(_ASN1Object): SERVER_AUTH: ClassVar[Purpose] CLIENT_AUTH: ClassVar[Purpose] else: - class _ASN1Object(NamedTuple('_ASN1Object', [('nid', int), ('shortname', str), ('longname', str), ('oid', str)])): ... class Purpose(_ASN1Object, enum.Enum): - SERVER_AUTH = ... - CLIENT_AUTH = ... + SERVER_AUTH: _ASN1Object + CLIENT_AUTH: _ASN1Object class SSLSocket(socket.socket): context: SSLContext @@ -207,22 +211,24 @@ class SSLSocket(socket.socket): def unwrap(self) -> socket.socket: ... def version(self) -> Optional[str]: ... def pending(self) -> int: ... - + if sys.version_info >= (3, 8): + def verify_client_post_handshake(self) -> None: ... if sys.version_info >= (3, 7): class TLSVersion(enum.IntEnum): - MINIMUM_SUPPORTED = ... - MAXIMUM_SUPPORTED = ... - SSLv3 = ... - TLSv1 = ... - TLSv1_1 = ... - TLSv1_2 = ... - TLSv1_3 = ... - + MINIMUM_SUPPORTED: int + MAXIMUM_SUPPORTED: int + SSLv3: int + TLSv1: int + TLSv1_1: int + TLSv1_2: int + TLSv1_3: int class SSLContext: check_hostname: bool options: int + if sys.version_info >= (3, 8): + post_handshake_auth: bool @property def protocol(self) -> int: ... verify_flags: int @@ -287,6 +293,8 @@ if sys.version_info >= (3, 5): def do_handshake(self) -> None: ... def unwrap(self) -> None: ... def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ... + if sys.version_info >= (3, 8): + def verify_client_post_handshake(self) -> None: ... class MemoryBIO: pending: int diff --git a/stdlib/2and3/sunau.pyi b/stdlib/2and3/sunau.pyi index 6577c316c46e..b957f58086c5 100644 --- a/stdlib/2and3/sunau.pyi +++ b/stdlib/2and3/sunau.pyi @@ -25,14 +25,13 @@ AUDIO_UNKNOWN_SIZE: int if sys.version_info < (3, 0): _sunau_params = Tuple[int, int, int, int, str, str] else: - _sunau_params = NamedTuple('_sunau_params', [ - ('nchannels', int), - ('sampwidth', int), - ('framerate', int), - ('nframes', int), - ('comptype', str), - ('compname', str), - ]) + class _sunau_params(NamedTuple): + nchannels: int + sampwidth: int + framerate: int + nframes: int + comptype: str + compname: str class Au_read: def __init__(self, f: _File) -> None: ... diff --git a/stdlib/2and3/threading.pyi b/stdlib/2and3/threading.pyi index c8ed09611ec6..ca1b0fd200a8 100644 --- a/stdlib/2and3/threading.pyi +++ b/stdlib/2and3/threading.pyi @@ -29,6 +29,9 @@ def enumerate() -> List[Thread]: ... if sys.version_info >= (3, 4): def main_thread() -> Thread: ... +if sys.version_info >= (3, 8): + from _thread import get_native_id as get_native_id + def settrace(func: _TF) -> None: ... def setprofile(func: Optional[_PF]) -> None: ... def stack_size(size: int = ...) -> int: ... @@ -67,6 +70,9 @@ class Thread: def join(self, timeout: Optional[float] = ...) -> None: ... def getName(self) -> str: ... def setName(self, name: str) -> None: ... + if sys.version_info >= (3, 8): + @property + def native_id(self) -> Optional[int]: ... # only available on some platforms def is_alive(self) -> bool: ... def isAlive(self) -> bool: ... def isDaemon(self) -> bool: ... @@ -160,6 +166,9 @@ class Event: def clear(self) -> None: ... def wait(self, timeout: Optional[float] = ...) -> bool: ... +if sys.version_info >= (3, 8): + from _thread import _ExceptHookArgs as ExceptHookArgs, ExceptHookArgs as _ExceptHookArgs # don't ask + excepthook: Callable[[_ExceptHookArgs], Any] class Timer(Thread): if sys.version_info >= (3,): diff --git a/stdlib/2and3/time.pyi b/stdlib/2and3/time.pyi index b04e6164b652..0c2370ad62a4 100644 --- a/stdlib/2and3/time.pyi +++ b/stdlib/2and3/time.pyi @@ -21,24 +21,30 @@ if sys.version_info >= (3, 7) and sys.platform != 'win32': CLOCK_UPTIME: int # FreeBSD, OpenBSD if sys.version_info >= (3, 3) and sys.platform != 'win32': - CLOCK_HIGHRES: int = ... # Solaris only - CLOCK_MONOTONIC: int = ... # Unix only - CLOCK_MONOTONIC_RAW: int = ... # Linux 2.6.28 or later - CLOCK_PROCESS_CPUTIME_ID: int = ... # Unix only - CLOCK_REALTIME: int = ... # Unix only - CLOCK_THREAD_CPUTIME_ID: int = ... # Unix only + CLOCK_HIGHRES: int # Solaris only + CLOCK_MONOTONIC: int # Unix only + CLOCK_MONOTONIC_RAW: int # Linux 2.6.28 or later + CLOCK_PROCESS_CPUTIME_ID: int # Unix only + CLOCK_REALTIME: int # Unix only + CLOCK_THREAD_CPUTIME_ID: int # Unix only +if sys.version_info >= (3, 8) and sys.platform == "darwin": + CLOCK_UPTIME_RAW: int if sys.version_info >= (3, 3): - class struct_time( - NamedTuple( - '_struct_time', - [('tm_year', int), ('tm_mon', int), ('tm_mday', int), - ('tm_hour', int), ('tm_min', int), ('tm_sec', int), - ('tm_wday', int), ('tm_yday', int), ('tm_isdst', int), - ('tm_zone', str), ('tm_gmtoff', int)] - ) - ): + class _struct_time(NamedTuple): + tm_year: int + tm_mon: int + tm_mday: int + tm_hour: int + tm_min: int + tm_sec: int + tm_wday: int + tm_yday: int + tm_isdst: int + tm_zone: str + tm_gmtoff: int + class struct_time(_struct_time): def __init__( self, o: Union[ @@ -58,19 +64,23 @@ if sys.version_info >= (3, 3): _arg: Any = ..., ) -> struct_time: ... else: - class struct_time( - NamedTuple( - '_struct_time', - [('tm_year', int), ('tm_mon', int), ('tm_mday', int), - ('tm_hour', int), ('tm_min', int), ('tm_sec', int), - ('tm_wday', int), ('tm_yday', int), ('tm_isdst', int)] - ) - ): + class _struct_time(NamedTuple): + tm_year: int + tm_mon: int + tm_mday: int + tm_hour: int + tm_min: int + tm_sec: int + tm_wday: int + tm_yday: int + tm_isdst: int + class struct_time(_struct_time): def __init__(self, o: _TimeTuple, _arg: Any = ...) -> None: ... def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ... def asctime(t: Union[_TimeTuple, struct_time] = ...) -> str: ... -def clock() -> float: ... +if sys.version_info < (3, 8): + def clock() -> float: ... def ctime(secs: Optional[float] = ...) -> str: ... def gmtime(secs: Optional[float] = ...) -> struct_time: ... def localtime(secs: Optional[float] = ...) -> struct_time: ... diff --git a/stdlib/2and3/unicodedata.pyi b/stdlib/2and3/unicodedata.pyi index bf4f30b1ddf9..ddd10136158d 100644 --- a/stdlib/2and3/unicodedata.pyi +++ b/stdlib/2and3/unicodedata.pyi @@ -1,4 +1,4 @@ -# Stubs for unicodedata (Python 2.7 and 3.4) +import sys from typing import Any, Text, TypeVar, Union ucd_3_2_0: UCD @@ -14,6 +14,8 @@ def decimal(__chr: Text, __default: _default = ...) -> Union[int, _default]: ... def decomposition(__chr: Text) -> Text: ... def digit(__chr: Text, __default: _default = ...) -> Union[int, _default]: ... def east_asian_width(__chr: Text) -> Text: ... +if sys.version_info >= (3, 8): + def is_normalized(__form: str, __unistr: str) -> bool: ... def lookup(__name: Union[Text, bytes]) -> Text: ... def mirrored(__chr: Text) -> int: ... def name(__chr: Text, __default: _default = ...) -> Union[Text, _default]: ... diff --git a/stdlib/2and3/warnings.pyi b/stdlib/2and3/warnings.pyi index d9ecec74f71e..138b71341d1d 100644 --- a/stdlib/2and3/warnings.pyi +++ b/stdlib/2and3/warnings.pyi @@ -29,13 +29,13 @@ def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ... def resetwarnings() -> None: ... -_Record = NamedTuple('_Record', - [('message', str), - ('category', Type[Warning]), - ('filename', str), - ('lineno', int), - ('file', Optional[TextIO]), - ('line', Optional[str])]) +class _Record(NamedTuple): + message: str + category: Type[Warning] + filename: str + lineno: int + file: Optional[TextIO] + line: Optional[str] class catch_warnings: def __init__(self, *, record: bool = ..., diff --git a/stdlib/2and3/wave.pyi b/stdlib/2and3/wave.pyi index 951142aa34bd..52bc9b156d26 100644 --- a/stdlib/2and3/wave.pyi +++ b/stdlib/2and3/wave.pyi @@ -14,14 +14,13 @@ WAVE_FORMAT_PCM: int if sys.version_info < (3, 0): _wave_params = Tuple[int, int, int, int, str, str] else: - _wave_params = NamedTuple('_wave_params', [ - ('nchannels', int), - ('sampwidth', int), - ('framerate', int), - ('nframes', int), - ('comptype', str), - ('compname', str), - ]) + class _wave_params(NamedTuple): + nchannels: int + sampwidth: int + framerate: int + nframes: int + comptype: str + compname: str class Wave_read: def __init__(self, f: _File) -> None: ... diff --git a/stdlib/2and3/xml/etree/ElementTree.pyi b/stdlib/2and3/xml/etree/ElementTree.pyi index 0318bd8c2274..025b47493266 100644 --- a/stdlib/2and3/xml/etree/ElementTree.pyi +++ b/stdlib/2and3/xml/etree/ElementTree.pyi @@ -1,6 +1,26 @@ # Stubs for xml.etree.ElementTree -from typing import Any, Callable, Dict, Generator, IO, ItemsView, Iterable, Iterator, KeysView, List, MutableSequence, Optional, overload, Sequence, Text, Tuple, TypeVar, Union +from typing import ( + Any, + Callable, + Dict, + Generator, + IO, + ItemsView, + Iterable, + Iterator, + KeysView, + List, + MutableSequence, + Optional, + Protocol, + Sequence, + Text, + Tuple, + TypeVar, + Union, + overload, +) import io import sys @@ -43,6 +63,41 @@ else: # _fixtext function in the source). Client code knows best: _str_result_type = Any +_file_or_filename = Union[str, bytes, int, IO[Any]] + +if sys.version_info >= (3, 8): + class _Writeable(Protocol): + def write(self, __s: str) -> Any: ... + + @overload + def canonicalize( + xml_data: Optional[_parser_input_type] = ..., + *, + out: None = ..., + from_file: Optional[_file_or_filename] = ..., + with_comments: bool = ..., + strip_text: bool = ..., + rewrite_prefixes: bool = ..., + qname_aware_tags: Optional[Iterable[str]] = ..., + qname_aware_attrs: Optional[Iterable[str]] = ..., + exclude_attrs: Optional[Iterable[str]] = ..., + exclude_tags: Optional[Iterable[str]] = ..., + ) -> str: ... + @overload + def canonicalize( + xml_data: Optional[_parser_input_type] = ..., + *, + out: _Writeable, + from_file: Optional[_file_or_filename] = ..., + with_comments: bool = ..., + strip_text: bool = ..., + rewrite_prefixes: bool = ..., + qname_aware_tags: Optional[Iterable[str]] = ..., + qname_aware_attrs: Optional[Iterable[str]] = ..., + exclude_attrs: Optional[Iterable[str]] = ..., + exclude_tags: Optional[Iterable[str]] = ..., + ) -> None: ... + class Element(MutableSequence[Element]): tag: _str_result_type attrib: Dict[_str_result_type, _str_result_type] @@ -100,9 +155,6 @@ class QName: text: str def __init__(self, text_or_uri: _str_argument_type, tag: Optional[_str_argument_type] = ...) -> None: ... - -_file_or_filename = Union[str, bytes, int, IO[Any]] - class ElementTree: def __init__(self, element: Optional[Element] = ..., file: Optional[_file_or_filename] = ...) -> None: ... def getroot(self) -> Element: ... @@ -176,13 +228,32 @@ class TreeBuilder: def start(self, tag: _parser_input_type, attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ... def end(self, tag: _parser_input_type) -> Element: ... +if sys.version_info >= (3, 8): + class C14NWriterTarget: + def __init__( + self, + write: Callable[[str], Any], + *, + with_comments: bool = ..., + strip_text: bool = ..., + rewrite_prefixes: bool = ..., + qname_aware_tags: Optional[Iterable[str]] = ..., + qname_aware_attrs: Optional[Iterable[str]] = ..., + exclude_attrs: Optional[Iterable[str]] = ..., + exclude_tags: Optional[Iterable[str]] = ..., + ) -> None: ... + + class XMLParser: parser: Any target: TreeBuilder # TODO-what is entity used for??? entity: Any version: str - def __init__(self, html: int = ..., target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ... - def doctype(self, name: str, pubid: str, system: str) -> None: ... + if sys.version_info >= (3, 8): + def __init__(self, *, target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ... + else: + def __init__(self, html: int = ..., target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ... + def doctype(self, name: str, pubid: str, system: str) -> None: ... def close(self) -> Element: ... def feed(self, data: _parser_input_type) -> None: ... diff --git a/stdlib/3.7/contextvars.pyi b/stdlib/3.7/contextvars.pyi index ab2ae9e5fabf..a90c2a8b5f65 100644 --- a/stdlib/3.7/contextvars.pyi +++ b/stdlib/3.7/contextvars.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, Union +from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar _T = TypeVar('_T') diff --git a/stdlib/3/_ast.pyi b/stdlib/3/_ast.pyi index df2bf9a28633..8dfdfbafec64 100644 --- a/stdlib/3/_ast.pyi +++ b/stdlib/3/_ast.pyi @@ -3,6 +3,9 @@ import typing from typing import Any, Optional, ClassVar PyCF_ONLY_AST: int +if sys.version_info >= (3, 8): + PyCF_TYPE_COMMENTS: int + PyCF_ALLOW_TOP_LEVEL_AWAIT: int _identifier = str @@ -386,6 +389,8 @@ class ExceptHandler(excepthandler): class arguments(AST): + if sys.version_info >= (3, 8): + posonlyargs: typing.List[arg] args: typing.List[arg] vararg: Optional[arg] kwonlyargs: typing.List[arg] diff --git a/stdlib/3/_imp.pyi b/stdlib/3/_imp.pyi index 1992e3bda119..f3c3945baba9 100644 --- a/stdlib/3/_imp.pyi +++ b/stdlib/3/_imp.pyi @@ -1,6 +1,5 @@ # Stubs for _imp (Python 3.6) -import sys import types from typing import Any, List diff --git a/stdlib/3/_importlib_modulespec.pyi b/stdlib/3/_importlib_modulespec.pyi index 51cb48983dd3..026dab8d01a3 100644 --- a/stdlib/3/_importlib_modulespec.pyi +++ b/stdlib/3/_importlib_modulespec.pyi @@ -8,7 +8,6 @@ # _Loader is the PEP-451-defined interface for a loader type/object. from abc import ABCMeta -import sys from typing import Any, Dict, List, Optional, Protocol class _Loader(Protocol): diff --git a/stdlib/3/_operator.pyi b/stdlib/3/_operator.pyi index bd162ab9f207..e968fb7daa1e 100644 --- a/stdlib/3/_operator.pyi +++ b/stdlib/3/_operator.pyi @@ -1,6 +1,5 @@ # Stubs for _operator (Python 3.5) -import sys from typing import AnyStr # In reality the import is the other way around, but this way we can keep the operator stub in 2and3 diff --git a/stdlib/3/_thread.pyi b/stdlib/3/_thread.pyi index 41f02b04210f..051edefbb63f 100644 --- a/stdlib/3/_thread.pyi +++ b/stdlib/3/_thread.pyi @@ -1,7 +1,9 @@ # Stubs for _thread +import sys +from threading import Thread from types import TracebackType -from typing import Any, Callable, Dict, NoReturn, Optional, Tuple, Type +from typing import Any, Callable, Dict, NamedTuple, NoReturn, Optional, Tuple, Type error = RuntimeError @@ -29,3 +31,14 @@ def get_ident() -> int: ... def stack_size(size: int = ...) -> int: ... TIMEOUT_MAX: int + +if sys.version_info >= (3, 8): + def get_native_id() -> int: ... # only available on some platforms + + class ExceptHookArgs(NamedTuple): + exc_type: Type[BaseException] + exc_value: Optional[BaseException] + exc_traceback: Optional[TracebackType] + thread: Optional[Thread] + def _ExceptHookArgs(args) -> ExceptHookArgs: ... + _excepthook: Callable[[ExceptHookArgs], Any] diff --git a/stdlib/3/_threading_local.pyi b/stdlib/3/_threading_local.pyi index 638c93f8b05a..426496b11405 100644 --- a/stdlib/3/_threading_local.pyi +++ b/stdlib/3/_threading_local.pyi @@ -1,8 +1,7 @@ # Source: https://github.com/python/cpython/blob/master/Lib/_threading_local.py -from typing import Any, Dict, List, Tuple +from typing import Any, Dict, Tuple from weakref import ReferenceType -__all__: List[str] localdict = Dict[Any, Any] class _localimpl: diff --git a/stdlib/3/_tracemalloc.pyi b/stdlib/3/_tracemalloc.pyi index a46db2419f20..e8a7168a3331 100644 --- a/stdlib/3/_tracemalloc.pyi +++ b/stdlib/3/_tracemalloc.pyi @@ -6,21 +6,11 @@ from typing import Any, Tuple def _get_object_traceback(*args, **kwargs) -> Any: ... - -def _get_traces() -> Any: - raise MemoryError() - +def _get_traces() -> Any: ... def clear_traces() -> None: ... - def get_traceback_limit() -> int: ... - def get_traced_memory() -> Tuple[Any, ...]: ... - def get_tracemalloc_memory() -> Any: ... - def is_tracing() -> bool: ... - -def start(*args, **kwargs) -> None: - raise ValueError() - +def start(*args, **kwargs) -> None: ... def stop() -> None: ... diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi index 8e89b2486d94..c517aa6e2ae9 100644 --- a/stdlib/3/ast.pyi +++ b/stdlib/3/ast.pyi @@ -3,7 +3,7 @@ import sys # from _ast below when loaded in an unorthodox way by the Dropbox # internal Bazel integration. import typing as _typing -from typing import overload, Any, Iterator, Optional, Union, TypeVar +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, @@ -16,27 +16,36 @@ if sys.version_info >= (3, 8): else: from typing_extensions import Literal -class NodeVisitor(): +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]: ... -_T = TypeVar('_T', bound=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: int = ...) -> Module: ... - + 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: int = ...) -> AST: ... + 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: ... @@ -48,4 +57,5 @@ 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: ... +def get_source_segment(source: str, node: AST, *, padded: bool = ...) -> Optional[str]: ... def walk(node: AST) -> Iterator[AST]: ... diff --git a/stdlib/3/asyncio/__init__.pyi b/stdlib/3/asyncio/__init__.pyi index 885dfce099d3..43e3be9e2d1e 100644 --- a/stdlib/3/asyncio/__init__.pyi +++ b/stdlib/3/asyncio/__init__.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Type +from typing import Type from asyncio.coroutines import ( coroutine as coroutine, @@ -18,8 +18,6 @@ from asyncio.streams import ( StreamReaderProtocol as StreamReaderProtocol, open_connection as open_connection, start_server as start_server, - IncompleteReadError as IncompleteReadError, - LimitOverrunError as LimitOverrunError, ) from asyncio.subprocess import ( create_subprocess_exec as create_subprocess_exec, @@ -35,9 +33,6 @@ from asyncio.transports import ( ) from asyncio.futures import ( Future as Future, - CancelledError as CancelledError, - TimeoutError as TimeoutError, - InvalidStateError as InvalidStateError, wrap_future as wrap_future, ) from asyncio.tasks import ( @@ -122,4 +117,25 @@ DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy] # TODO: AbstractChildWatcher (UNIX only) -__all__: List[str] +if sys.version_info >= (3, 8): + from asyncio.exceptions import ( + CancelledError as CancelledError, + IncompleteReadError as IncompleteReadError, + InvalidStateError as InvalidStateError, + LimitOverrunError as LimitOverrunError, + SendfileNotAvailableError as SendfileNotAvailableError, + TimeoutError as TimeoutError, + ) +else: + from asyncio.events import ( + SendfileNotAvailableError as SendfileNotAvailableError + ) + from asyncio.futures import ( + CancelledError as CancelledError, + TimeoutError as TimeoutError, + InvalidStateError as InvalidStateError, + ) + from asyncio.streams import ( + IncompleteReadError as IncompleteReadError, + LimitOverrunError as LimitOverrunError, + ) diff --git a/stdlib/3/asyncio/base_events.pyi b/stdlib/3/asyncio/base_events.pyi index 8a959a9ee0dc..8210ebded19a 100644 --- a/stdlib/3/asyncio/base_events.pyi +++ b/stdlib/3/asyncio/base_events.pyi @@ -44,7 +44,12 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta): # Future methods def create_future(self) -> Future[Any]: ... # Tasks methods - def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... + if sys.version_info >= (3, 8): + def create_task( + self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ..., + ) -> Task[_T]: ... + else: + def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ... def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ... # Methods for interacting with threads diff --git a/stdlib/3/asyncio/constants.pyi b/stdlib/3/asyncio/constants.pyi new file mode 100644 index 000000000000..f15ea4fe2bab --- /dev/null +++ b/stdlib/3/asyncio/constants.pyi @@ -0,0 +1,13 @@ + +import enum + +LOG_THRESHOLD_FOR_CONNLOST_WRITES: int +ACCEPT_RETRY_DELAY: int +DEBUG_STACK_DEPTH: int +SSL_HANDSHAKE_TIMEOUT: float +SENDFILE_FALLBACK_READBUFFER_SIZE: int + +class _SendfileMode(enum.Enum): + UNSUPPORTED: int = ... + TRY_NATIVE: int = ... + FALLBACK: int = ... diff --git a/stdlib/3/asyncio/coroutines.pyi b/stdlib/3/asyncio/coroutines.pyi index 981ccd5a0018..f75dfe5f63e9 100644 --- a/stdlib/3/asyncio/coroutines.pyi +++ b/stdlib/3/asyncio/coroutines.pyi @@ -1,6 +1,4 @@ -from typing import Any, Callable, Generator, List, TypeVar - -__all__: List[str] +from typing import Any, Callable, TypeVar _F = TypeVar('_F', bound=Callable[..., Any]) diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 66f7c9f9e134..977bef092dee 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -10,8 +10,6 @@ from asyncio.protocols import BaseProtocol from asyncio.tasks import Task from asyncio.transports import BaseTransport -__all__: List[str] - _T = TypeVar('_T') _Context = Dict[str, Any] _ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any] @@ -82,8 +80,14 @@ class AbstractEventLoop(metaclass=ABCMeta): @abstractmethod def create_future(self) -> Future[Any]: ... # Tasks methods - @abstractmethod - def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... + if sys.version_info >= (3, 8): + @abstractmethod + def create_task( + self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ..., + ) -> Task[_T]: ... + else: + @abstractmethod + def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ... @abstractmethod def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ... @abstractmethod @@ -303,3 +307,6 @@ def _get_running_loop() -> AbstractEventLoop: ... if sys.version_info >= (3, 7): def get_running_loop() -> AbstractEventLoop: ... + +if sys.version_info < (3, 8): + class SendfileNotAvailableError(RuntimeError): ... diff --git a/stdlib/3/asyncio/exceptions.pyi b/stdlib/3/asyncio/exceptions.pyi new file mode 100644 index 000000000000..ecec9560a850 --- /dev/null +++ b/stdlib/3/asyncio/exceptions.pyi @@ -0,0 +1,15 @@ +import sys +from typing import Optional + +if sys.version_info >= (3, 8): + class CancelledError(BaseException): ... + class TimeoutError(Exception): ... + class InvalidStateError(Exception): ... + class SendfileNotAvailableError(RuntimeError): ... + class IncompleteReadError(EOFError): + expected: Optional[int] + partial: bytes + def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... + class LimitOverrunError(Exception): + consumed: int + def __init__(self, message: str, consumed: int) -> None: ... diff --git a/stdlib/3/asyncio/futures.pyi b/stdlib/3/asyncio/futures.pyi index 37bd02c30fcd..bd333d7c824f 100644 --- a/stdlib/3/asyncio/futures.pyi +++ b/stdlib/3/asyncio/futures.pyi @@ -1,23 +1,22 @@ import sys -from typing import Any, Union, Callable, TypeVar, Type, List, Generic, Iterable, Generator, Awaitable, Optional, Tuple +from typing import Any, Union, Callable, TypeVar, Type, List, Iterable, Generator, Awaitable, Optional, Tuple from .events import AbstractEventLoop from concurrent.futures import ( - CancelledError as CancelledError, - TimeoutError as TimeoutError, Future as _ConcurrentFuture, Error, ) +if sys.version_info < (3, 8): + from concurrent.futures import CancelledError as CancelledError + from concurrent.futures import TimeoutError as TimeoutError + class InvalidStateError(Error): ... + if sys.version_info >= (3, 7): from contextvars import Context -__all__: List[str] - _T = TypeVar('_T') _S = TypeVar('_S') -class InvalidStateError(Error): ... - class _TracebackLogger: exc: BaseException tb: List[str] diff --git a/stdlib/3/asyncio/locks.pyi b/stdlib/3/asyncio/locks.pyi index 56b8a672718a..bc78d4b0de2a 100644 --- a/stdlib/3/asyncio/locks.pyi +++ b/stdlib/3/asyncio/locks.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Generator, Iterable, Iterator, List, Type, TypeVar, Union, Optional, Awaitable +from typing import Any, Callable, Generator, Type, TypeVar, Union, Optional, Awaitable from .coroutines import coroutine from .events import AbstractEventLoop @@ -7,8 +7,6 @@ from types import TracebackType _T = TypeVar('_T') -__all__: List[str] - class _ContextManager: def __init__(self, lock: Union[Lock, Semaphore]) -> None: ... def __enter__(self) -> object: ... diff --git a/stdlib/3/asyncio/proactor_events.pyi b/stdlib/3/asyncio/proactor_events.pyi new file mode 100644 index 000000000000..bed374734f02 --- /dev/null +++ b/stdlib/3/asyncio/proactor_events.pyi @@ -0,0 +1,61 @@ + +from typing import Any, Mapping, Optional, Generator +from . import base_events, transports, events, streams, futures, constants +from asyncio import coroutine +from socket import socket +import sys +if sys.version_info >= (3, 8): + from typing import Literal +else: + from typing_extensions import Literal + +class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): + + def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... + def __repr__(self) -> str: ... + def __del__(self) -> None: ... + def get_write_buffer_size(self) -> int: ... + +class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): + + def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... + +class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): + + def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... + +class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): + + def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... + +class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ... + +class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): + + _sendfile_compatible: constants._SendfileMode = ... + + def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... + def _set_extra(self, sock: socket) -> None: ... + def can_write_eof(self) -> Literal[True]: ... + def write_eof(self) -> None: ... + +class BaseProactorEventLoop(base_events.BaseEventLoop): + + def __init__(self, proactor: Any) -> None: ... + # The methods below don't actually exist directly, ProactorEventLoops do not implement them. However, they are + # needed to satisfy mypy + if sys.version_info >= (3, 7): + async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ..., + sock: Optional[socket] = ..., server_hostname: str = ..., + ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ... + async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ..., + backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ..., + start_serving: bool = ...) -> events.AbstractServer: ... + else: + @coroutine + def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, + ssl: events._SSLContext = ..., sock: Optional[socket] = ..., + server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ... + @coroutine + def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, + sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ... diff --git a/stdlib/3/asyncio/protocols.pyi b/stdlib/3/asyncio/protocols.pyi index 40592382d7e2..e80f238d2d27 100644 --- a/stdlib/3/asyncio/protocols.pyi +++ b/stdlib/3/asyncio/protocols.pyi @@ -1,8 +1,5 @@ from asyncio import transports -from typing import List, Optional, Text, Tuple, Union - -__all__: List[str] - +from typing import Optional, Text, Tuple, Union class BaseProtocol: def connection_made(self, transport: transports.BaseTransport) -> None: ... diff --git a/stdlib/3/asyncio/queues.pyi b/stdlib/3/asyncio/queues.pyi index 243a74d54201..c908b764c9ef 100644 --- a/stdlib/3/asyncio/queues.pyi +++ b/stdlib/3/asyncio/queues.pyi @@ -1,11 +1,6 @@ -import sys from asyncio.events import AbstractEventLoop from .coroutines import coroutine -from .futures import Future -from typing import Any, Generator, Generic, List, TypeVar, Optional - -__all__: List[str] - +from typing import Any, Generator, Generic, TypeVar, Optional class QueueEmpty(Exception): ... class QueueFull(Exception): ... diff --git a/stdlib/3/asyncio/selector_events.pyi b/stdlib/3/asyncio/selector_events.pyi new file mode 100644 index 000000000000..42381de74005 --- /dev/null +++ b/stdlib/3/asyncio/selector_events.pyi @@ -0,0 +1,26 @@ + +from typing import Optional, Any, Generator +from . import base_events, events +from socket import socket +from asyncio import coroutine +import selectors +import sys + +class BaseSelectorEventLoop(base_events.BaseEventLoop): + + def __init__(self, selector: selectors.BaseSelector = ...) -> None: ... + if sys.version_info >= (3, 7): + async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ..., + sock: Optional[socket] = ..., server_hostname: str = ..., + ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ... + async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ..., + backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ..., + start_serving: bool = ...) -> events.AbstractServer: ... + else: + @coroutine + def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, + ssl: events._SSLContext = ..., sock: Optional[socket] = ..., + server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ... + @coroutine + def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, + sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ... diff --git a/stdlib/3/asyncio/streams.pyi b/stdlib/3/asyncio/streams.pyi index 68271c0fe2a1..c3c8569ca5e2 100644 --- a/stdlib/3/asyncio/streams.pyi +++ b/stdlib/3/asyncio/streams.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, Union +from typing import Any, Awaitable, Callable, Generator, Iterable, Optional, Tuple, Union from . import coroutines from . import events @@ -8,17 +8,15 @@ from . import transports _ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]] +if sys.version_info < (3, 8): + class IncompleteReadError(EOFError): + expected: Optional[int] + partial: bytes + def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... -__all__: List[str] - -class IncompleteReadError(EOFError): - expected: Optional[int] - partial: bytes - def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... - -class LimitOverrunError(Exception): - consumed: int - def __init__(self, message: str, consumed: int) -> None: ... + class LimitOverrunError(Exception): + consumed: int + def __init__(self, message: str, consumed: int) -> None: ... @coroutines.coroutine def open_connection( diff --git a/stdlib/3/asyncio/subprocess.pyi b/stdlib/3/asyncio/subprocess.pyi index 46ed30212ab3..64a489f0f43f 100644 --- a/stdlib/3/asyncio/subprocess.pyi +++ b/stdlib/3/asyncio/subprocess.pyi @@ -3,9 +3,7 @@ from asyncio import protocols from asyncio import streams from asyncio import transports from asyncio.coroutines import coroutine -from typing import Any, Generator, List, Optional, Text, Tuple, Union, IO - -__all__: List[str] +from typing import Any, Generator, Optional, Text, Tuple, Union, IO PIPE: int STDOUT: int diff --git a/stdlib/3/asyncio/tasks.pyi b/stdlib/3/asyncio/tasks.pyi index 05b590eb0430..65c28ebe68e5 100644 --- a/stdlib/3/asyncio/tasks.pyi +++ b/stdlib/3/asyncio/tasks.pyi @@ -1,8 +1,8 @@ import concurrent.futures import sys -from typing import (Any, TypeVar, Set, Dict, List, TextIO, Union, Tuple, Generic, Callable, - Coroutine, Generator, Iterable, Awaitable, overload, Sequence, Iterator, - Optional) +from typing import ( + Any, TypeVar, Set, List, TextIO, Union, Tuple, Generic, Generator, Iterable, Awaitable, overload, Iterator, Optional, +) from types import FrameType from .events import AbstractEventLoop from .futures import Future @@ -12,8 +12,6 @@ if sys.version_info >= (3, 8): else: from typing_extensions import Literal -__all__: List[str] - _T = TypeVar('_T') _T1 = TypeVar('_T1') _T2 = TypeVar('_T2') @@ -100,6 +98,9 @@ class Task(Future[_T], Generic[_T]): def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ... def __repr__(self) -> str: ... + if sys.version_info >= (3, 8): + def get_name(self) -> str: ... + def set_name(self, value: object) -> None: ... def get_stack(self, *, limit: int = ...) -> List[FrameType]: ... def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ... def cancel(self) -> bool: ... @@ -108,5 +109,10 @@ class Task(Future[_T], Generic[_T]): if sys.version_info >= (3, 7): def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ... - def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ... + if sys.version_info >= (3, 8): + def create_task( + coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, name: Optional[str] = ..., + ) -> Task[Any]: ... + else: + def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ... def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ... diff --git a/stdlib/3/asyncio/transports.pyi b/stdlib/3/asyncio/transports.pyi index ea6ab4adb67b..df80beb4eda9 100644 --- a/stdlib/3/asyncio/transports.pyi +++ b/stdlib/3/asyncio/transports.pyi @@ -1,8 +1,7 @@ import sys -from typing import Dict, Any, TypeVar, Mapping, List, Optional, Tuple +from typing import Any, Mapping, List, Optional, Tuple from asyncio.protocols import BaseProtocol - -__all__: List[str] +from asyncio.events import AbstractEventLoop class BaseTransport: def __init__(self, extra: Mapping[Any, Any] = ...) -> None: ... @@ -43,3 +42,7 @@ class SubprocessTransport(BaseTransport): def send_signal(self, signal: int) -> int: ... def terminate(self) -> None: ... def kill(self) -> None: ... + +class _FlowControlMixin(Transport): + def __init__(self, extra: Optional[Mapping[Any, Any]] = ..., loop: Optional[AbstractEventLoop] = ...) -> None: ... + def get_write_buffer_limits(self) -> Tuple[int, int]: ... diff --git a/stdlib/3/asyncio/windows_events.pyi b/stdlib/3/asyncio/windows_events.pyi new file mode 100644 index 000000000000..1933f52d4ada --- /dev/null +++ b/stdlib/3/asyncio/windows_events.pyi @@ -0,0 +1,58 @@ + +from typing import Callable, Tuple, List, IO, Any, Optional +import socket +from . import proactor_events, events, futures, windows_utils, selector_events, streams + +NULL: int +INFINITE: int +ERROR_CONNECTION_REFUSED: int +ERROR_CONNECTION_ABORTED: int +CONNECT_PIPE_INIT_DELAY: float +CONNECT_PIPE_MAX_DELAY: float + +class PipeServer: + + def __init__(self, address: str) -> None: ... + def __del__(self) -> None: ... + def closed(self) -> bool: ... + def close(self) -> None: ... + +class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): ... + +class ProactorEventLoop(proactor_events.BaseProactorEventLoop): + + def __init__(self, proactor: Optional[IocpProactor] = ...) -> None: ... + async def create_pipe_connection(self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str) -> Tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ... + async def start_serving_pipe(self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str) -> List[PipeServer]: ... + +class IocpProactor: + + def __init__(self, concurrency: int = ...) -> None: ... + def __repr__(self) -> str: ... + def __del__(self) -> None: ... + def set_loop(self, loop: events.AbstractEventLoop) -> None: ... + def select(self, timeout: Optional[int] = ...) -> List[futures.Future[Any]]: ... + def recv(self, conn: socket.socket, nbytes: int, flags: int = ...) -> futures.Future[bytes]: ... + def recv_into(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ... + def send(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ... + def accept(self, listener: socket.socket) -> futures.Future[Any]: ... + def connect(self, conn: socket.socket, address: bytes) -> futures.Future[Any]: ... + def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ... + def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ... + async def connect_pipe(self, address: bytes) -> windows_utils.PipeHandle: ... + def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int = ...) -> bool: ... + def close(self) -> None: ... + +SelectorEventLoop = _WindowsSelectorEventLoop + +class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): + _loop_factory: events.AbstractEventLoop = ... + def get_child_watcher(self) -> Any: ... + def set_child_watcher(self, watcher: Any) -> None: ... + +class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): + _loop_factory: events.AbstractEventLoop = ... + def get_child_watcher(self) -> Any: ... + def set_child_watcher(self, watcher: Any) -> None: ... + +DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy diff --git a/stdlib/3/asyncio/windows_utils.pyi b/stdlib/3/asyncio/windows_utils.pyi new file mode 100644 index 000000000000..5ba6bfbb2a0c --- /dev/null +++ b/stdlib/3/asyncio/windows_utils.pyi @@ -0,0 +1,21 @@ + +from typing import Tuple, Callable, Optional +from types import TracebackType + +BUFSIZE: int = ... +PIPE: int = ... +STDOUT: int = ... + +def pipe(*, duplex: bool = ..., overlapped: Tuple[bool, bool] = ..., bufsize: int = ...) -> Tuple[int, int]: ... + +class PipeHandle: + + def __init__(self, handle: int) -> None: ... + def __repr__(self) -> str: ... + def __del__(self) -> None: ... + def __enter__(self) -> PipeHandle: ... + def __exit__(self, t: Optional[type], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... + @property + def handle(self) -> int: ... + def fileno(self) -> int: ... + def close(self, *, CloseHandle: Callable[[int], None] = ...) -> None: ... diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index 46d3644dc60a..400c3dc3dc36 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -220,18 +220,15 @@ class deque(MutableSequence[_T], Generic[_T]): @overload def __getitem__(self, index: int) -> _T: ... @overload - def __getitem__(self, s: slice) -> MutableSequence[_T]: - raise TypeError + def __getitem__(self, s: slice) -> MutableSequence[_T]: ... @overload def __setitem__(self, i: int, x: _T) -> None: ... @overload - def __setitem__(self, s: slice, o: Iterable[_T]) -> None: - raise TypeError + def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... @overload def __delitem__(self, i: int) -> None: ... @overload - def __delitem__(self, s: slice) -> None: - raise TypeError + def __delitem__(self, s: slice) -> None: ... def __contains__(self, o: object) -> bool: ... def __reversed__(self) -> Iterator[_T]: ... diff --git a/stdlib/3/configparser.pyi b/stdlib/3/configparser.pyi index 8b87e06453b9..24f817997ff7 100644 --- a/stdlib/3/configparser.pyi +++ b/stdlib/3/configparser.pyi @@ -115,7 +115,7 @@ class RawConfigParser(_parser): @overload # type: ignore def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> str: ... - @overload # type: ignore + @overload def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T) -> Union[str, _T]: ... @overload diff --git a/stdlib/3/email/__init__.pyi b/stdlib/3/email/__init__.pyi index ec7c25bd4b69..a69f188d4f7b 100644 --- a/stdlib/3/email/__init__.pyi +++ b/stdlib/3/email/__init__.pyi @@ -1,7 +1,6 @@ # Stubs for email (Python 3.4) -from typing import Callable, Optional, IO -import sys +from typing import Callable, IO from email.message import Message from email.policy import Policy diff --git a/stdlib/3/email/feedparser.pyi b/stdlib/3/email/feedparser.pyi index 48d940b3987d..facfd438c500 100644 --- a/stdlib/3/email/feedparser.pyi +++ b/stdlib/3/email/feedparser.pyi @@ -1,7 +1,6 @@ # Stubs for email.feedparser (Python 3.4) from typing import Callable -import sys from email.message import Message from email.policy import Policy diff --git a/stdlib/3/email/message.pyi b/stdlib/3/email/message.pyi index 88aef3efef06..36b2fdc65200 100644 --- a/stdlib/3/email/message.pyi +++ b/stdlib/3/email/message.pyi @@ -3,7 +3,6 @@ from typing import ( List, Optional, Union, Tuple, TypeVar, Generator, Sequence, Iterator, Any ) -import sys from email.charset import Charset from email.errors import MessageDefect from email.header import Header @@ -16,7 +15,7 @@ _PayloadType = Union[List[Message], str, bytes] _CharsetType = Union[Charset, str, None] _ParamsType = Union[str, None, Tuple[str, Optional[str], str]] _ParamType = Union[str, Tuple[Optional[str], Optional[str], str]] -_HeaderType = Union[str, Header] +_HeaderType = Any class Message: preamble: Optional[str] @@ -34,7 +33,7 @@ class Message: def get_charset(self) -> _CharsetType: ... def __len__(self) -> int: ... def __contains__(self, name: str) -> bool: ... - def __getitem__(self, name: str) -> Optional[_HeaderType]: ... + def __getitem__(self, name: str) -> _HeaderType: ... def __setitem__(self, name: str, val: _HeaderType) -> None: ... def __delitem__(self, name: str) -> None: ... def keys(self) -> List[str]: ... diff --git a/stdlib/3/email/parser.pyi b/stdlib/3/email/parser.pyi index 180e382ee8e4..89ca2774b34a 100644 --- a/stdlib/3/email/parser.pyi +++ b/stdlib/3/email/parser.pyi @@ -3,7 +3,7 @@ import email.feedparser from email.message import Message from email.policy import Policy -from typing import BinaryIO, Callable, Optional, TextIO +from typing import BinaryIO, Callable, TextIO FeedParser = email.feedparser.FeedParser BytesFeedParser = email.feedparser.BytesFeedParser diff --git a/stdlib/3/email/policy.pyi b/stdlib/3/email/policy.pyi index 581cf58913f5..5f3b8977af9d 100644 --- a/stdlib/3/email/policy.pyi +++ b/stdlib/3/email/policy.pyi @@ -2,7 +2,6 @@ from abc import abstractmethod from typing import Any, List, Optional, Tuple, Union, Callable -import sys from email.message import Message from email.errors import MessageDefect from email.header import Header diff --git a/stdlib/3/encodings/__init__.pyi b/stdlib/3/encodings/__init__.pyi index 2ae6c0a9351d..0c050530725a 100644 --- a/stdlib/3/encodings/__init__.pyi +++ b/stdlib/3/encodings/__init__.pyi @@ -1,6 +1,3 @@ import codecs -import typing - -def search_function(encoding: str) -> codecs.CodecInfo: - ... +def search_function(encoding: str) -> codecs.CodecInfo: ... diff --git a/stdlib/3/enum.pyi b/stdlib/3/enum.pyi index 703c7cfa8be3..be22d386dbc7 100644 --- a/stdlib/3/enum.pyi +++ b/stdlib/3/enum.pyi @@ -66,9 +66,7 @@ if sys.version_info >= (3, 6): def __xor__(self: _T, other: _T) -> _T: ... def __invert__(self: _T) -> _T: ... - # The `type: ignore` comment is needed because mypy considers the type - # signatures of several methods defined in int and Flag to be incompatible. - class IntFlag(int, Flag): # type: ignore + class IntFlag(int, Flag): def __or__(self: _T, other: Union[int, _T]) -> _T: ... def __and__(self: _T, other: Union[int, _T]) -> _T: ... def __xor__(self: _T, other: Union[int, _T]) -> _T: ... diff --git a/stdlib/3/functools.pyi b/stdlib/3/functools.pyi index ce89e7173154..78a3466eaa45 100644 --- a/stdlib/3/functools.pyi +++ b/stdlib/3/functools.pyi @@ -5,6 +5,7 @@ _AnyCallable = Callable[..., Any] _T = TypeVar("_T") _S = TypeVar("_S") + @overload def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ... @@ -12,13 +13,11 @@ def reduce(function: Callable[[_T, _S], _T], def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ... - -class _CacheInfo(NamedTuple('CacheInfo', [ - ('hits', int), - ('misses', int), - ('maxsize', int), - ('currsize', int) -])): ... +class _CacheInfo(NamedTuple): + hits: int + misses: int + maxsize: int + currsize: int class _lru_cache_wrapper(Generic[_T]): __wrapped__: Callable[..., _T] @@ -26,10 +25,13 @@ class _lru_cache_wrapper(Generic[_T]): def cache_info(self) -> _CacheInfo: ... def cache_clear(self) -> None: ... -class lru_cache(): - def __init__(self, maxsize: Optional[int] = ..., typed: bool = ...) -> None: ... - def __call__(self, f: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ... - +if sys.version_info >= (3, 8): + @overload + def lru_cache(maxsize: Optional[int] = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ... + @overload + def lru_cache(maxsize: Callable[..., _T], typed: bool = ...) -> _lru_cache_wrapper[_T]: ... +else: + def lru_cache(maxsize: Optional[int] = ..., typed: bool = ...) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ... WRAPPER_ASSIGNMENTS: Sequence[str] WRAPPER_UPDATES: Sequence[str] diff --git a/stdlib/3/gc.pyi b/stdlib/3/gc.pyi index d4bb109840dd..b85e8f5880e4 100644 --- a/stdlib/3/gc.pyi +++ b/stdlib/3/gc.pyi @@ -1,6 +1,7 @@ # Stubs for gc -from typing import Any, Dict, List, Tuple +import sys +from typing import Any, Dict, List, Optional, Tuple DEBUG_COLLECTABLE: int @@ -16,7 +17,10 @@ def disable() -> None: ... def enable() -> None: ... def get_count() -> Tuple[int, int, int]: ... def get_debug() -> int: ... -def get_objects() -> List[Any]: ... +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]]: ... diff --git a/stdlib/3/gettext.pyi b/stdlib/3/gettext.pyi index 4b5398a46f20..ad1ba3c82a53 100644 --- a/stdlib/3/gettext.pyi +++ b/stdlib/3/gettext.pyi @@ -14,6 +14,8 @@ class NullTranslations: def lgettext(self, message: str) -> str: ... def ngettext(self, singular: str, plural: str, n: int) -> str: ... def lngettext(self, singular: str, plural: str, n: int) -> str: ... + def pgettext(self, context: str, message: str) -> str: ... + def npgettext(self, context: str, msgid1: str, msgid2: str, n: int) -> str: ... def info(self) -> Any: ... def charset(self) -> Any: ... def output_charset(self) -> Any: ... @@ -52,5 +54,9 @@ def gettext(message: str) -> str: ... def lgettext(message: str) -> str: ... def ngettext(singular: str, plural: str, n: int) -> str: ... def lngettext(singular: str, plural: str, n: int) -> str: ... +def pgettext(context: str, message: str) -> str: ... +def dpgettext(domain: str, context: str, message: str) -> str: ... +def npgettext(context: str, msgid1: str, msgid2: str, n: int) -> str: ... +def dnpgettext(domain: str, context: str, msgid1: str, msgid2: str, n: int) -> str: ... Catalog = translation diff --git a/stdlib/3/gzip.pyi b/stdlib/3/gzip.pyi index 6f1bf7adc329..ce8152c34f09 100644 --- a/stdlib/3/gzip.pyi +++ b/stdlib/3/gzip.pyi @@ -1,6 +1,7 @@ from typing import Any, IO, Optional from os.path import _PathType import _compression +import sys import zlib def open(filename, mode: str = ..., compresslevel: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ...) -> IO[Any]: ... @@ -45,5 +46,8 @@ class _GzipReader(_compression.DecompressReader): def __init__(self, fp: IO[bytes]) -> None: ... def read(self, size: int = ...) -> bytes: ... -def compress(data, compresslevel: int = ...) -> bytes: ... +if sys.version_info >= (3, 8): + def compress(data, compresslevel: int = ..., *, mtime: Optional[float] = ...) -> bytes: ... +else: + def compress(data, compresslevel: int = ...) -> bytes: ... def decompress(data: bytes) -> bytes: ... diff --git a/stdlib/3/heapq.pyi b/stdlib/3/heapq.pyi index 0764da5183a5..8f703c58105c 100644 --- a/stdlib/3/heapq.pyi +++ b/stdlib/3/heapq.pyi @@ -2,7 +2,6 @@ # Based on http://docs.python.org/3.2/library/heapq.html -import sys from typing import TypeVar, List, Iterable, Any, Callable, Optional _T = TypeVar('_T') diff --git a/stdlib/3/html/parser.pyi b/stdlib/3/html/parser.pyi index 55b99ea3407f..4c037845a3b0 100644 --- a/stdlib/3/html/parser.pyi +++ b/stdlib/3/html/parser.pyi @@ -1,6 +1,5 @@ from typing import List, Optional, Tuple from _markupbase import ParserBase -import sys class HTMLParser(ParserBase): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... @@ -14,7 +13,7 @@ class HTMLParser(ParserBase): attrs: List[Tuple[str, Optional[str]]]) -> None: ... def handle_endtag(self, tag: str) -> None: ... def handle_startendtag(self, tag: str, - attrs: List[Tuple[str, str]]) -> None: ... + attrs: List[Tuple[str, Optional[str]]]) -> None: ... def handle_data(self, data: str) -> None: ... def handle_entityref(self, name: str) -> None: ... def handle_charref(self, name: str) -> None: ... diff --git a/stdlib/3/http/client.pyi b/stdlib/3/http/client.pyi index ee57f16a8f29..633634d68c5e 100644 --- a/stdlib/3/http/client.pyi +++ b/stdlib/3/http/client.pyi @@ -112,14 +112,18 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): # urllib.request uses it for a parameter. class _HTTPConnectionProtocol(Protocol): if sys.version_info >= (3, 7): - def __call__(self, host: str, port: Optional[int] = ..., - timeout: float = ..., - source_address: Optional[Tuple[str, int]] = ..., - blocksize: int = ...): ... + def __call__( + self, + host: str, + port: Optional[int] = ..., + timeout: float = ..., + source_address: Optional[Tuple[str, int]] = ..., + blocksize: int = ..., + ) -> HTTPConnection: ... else: - def __call__(self, host: str, port: Optional[int] = ..., - timeout: float = ..., - source_address: Optional[Tuple[str, int]] = ...): ... + def __call__( + self, host: str, port: Optional[int] = ..., timeout: float = ..., source_address: Optional[Tuple[str, int]] = ..., + ) -> HTTPConnection: ... class HTTPConnection: timeout: float diff --git a/stdlib/3/http/cookies.pyi b/stdlib/3/http/cookies.pyi index dfd6df88cba1..886d3c71adb9 100644 --- a/stdlib/3/http/cookies.pyi +++ b/stdlib/3/http/cookies.pyi @@ -1,6 +1,6 @@ # Stubs for http.cookies (Python 3.5) -from typing import Generic, Dict, List, Mapping, MutableMapping, Optional, TypeVar, Union, Any +from typing import Generic, Dict, List, Mapping, Optional, TypeVar, Union, Any _DataType = Union[str, Mapping[str, Union[str, Morsel[Any]]]] _T = TypeVar('_T') diff --git a/stdlib/3/importlib/__init__.pyi b/stdlib/3/importlib/__init__.pyi index d46f7e19d555..e44f424164af 100644 --- a/stdlib/3/importlib/__init__.pyi +++ b/stdlib/3/importlib/__init__.pyi @@ -1,5 +1,4 @@ from importlib.abc import Loader -import sys import types from typing import Any, Mapping, Optional, Sequence diff --git a/stdlib/3/importlib/machinery.pyi b/stdlib/3/importlib/machinery.pyi index 036a91fe487e..746c5026c759 100644 --- a/stdlib/3/importlib/machinery.pyi +++ b/stdlib/3/importlib/machinery.pyi @@ -1,7 +1,6 @@ import importlib.abc -import sys import types -from typing import Any, Callable, List, Optional, Sequence, Tuple, Union +from typing import Any, Callable, List, Optional, Sequence, Tuple # ModuleSpec is exported from this module, but for circular import # reasons exists in its own stub file (with Loader and ModuleType). diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index 099041551d94..6c1afd5e4274 100644 --- a/stdlib/3/inspect.pyi +++ b/stdlib/3/inspect.pyi @@ -37,11 +37,11 @@ if sys.version_info >= (3, 6): TPFLAGS_IS_ABSTRACT: int if sys.version_info < (3, 6): - ModuleInfo = NamedTuple('ModuleInfo', [('name', str), - ('suffix', str), - ('mode', str), - ('module_type', int), - ]) + class ModuleInfo(NamedTuple): + name: str + suffix: str + mode: str + module_type: int def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ... def getmembers(object: object, @@ -170,37 +170,36 @@ class BoundArguments: # _ClassTreeItem = Union[List[_ClassTreeItem], Tuple[type, Tuple[type, ...]]] def getclasstree(classes: List[type], unique: bool = ...) -> Any: ... -ArgSpec = NamedTuple('ArgSpec', [('args', List[str]), - ('varargs', str), - ('keywords', str), - ('defaults', Tuple[Any, ...]), - ]) +class ArgSpec(NamedTuple): + args: List[str] + varargs: str + keywords: str + defaults: Tuple[Any, ...] -Arguments = NamedTuple('Arguments', [('args', List[str]), - ('varargs', Optional[str]), - ('varkw', Optional[str]), - ]) +class Arguments(NamedTuple): + args: List[str] + varargs: Optional[str] + varkw: Optional[str] def getargs(co: CodeType) -> Arguments: ... def getargspec(func: object) -> ArgSpec: ... -FullArgSpec = NamedTuple('FullArgSpec', [('args', List[str]), - ('varargs', Optional[str]), - ('varkw', Optional[str]), - ('defaults', Tuple[Any, ...]), - ('kwonlyargs', List[str]), - ('kwonlydefaults', Dict[str, Any]), - ('annotations', Dict[str, Any]), - ]) +class FullArgSpec(NamedTuple): + args: List[str] + varargs: Optional[str] + varkw: Optional[str] + defaults: Optional[Tuple[Any, ...]] + kwonlyargs: List[str] + kwonlydefaults: Optional[Dict[str, Any]] + annotations: Dict[str, Any] def getfullargspec(func: object) -> FullArgSpec: ... -# TODO make the field types more specific here -ArgInfo = NamedTuple('ArgInfo', [('args', List[str]), - ('varargs', Optional[str]), - ('keywords', Optional[str]), - ('locals', Dict[str, Any]), - ]) +class ArgInfo(NamedTuple): + args: List[str] + varargs: Optional[str] + keywords: Optional[str] + locals: Dict[str, Any] def getargvalues(frame: FrameType) -> ArgInfo: ... def formatannotation(annotation: object, base_module: Optional[str] = ...) -> str: ... @@ -234,12 +233,11 @@ def getcallargs(func: Callable[..., Any], *args: Any, **kwds: Any) -> Dict[str, Any]: ... - -ClosureVars = NamedTuple('ClosureVars', [('nonlocals', Mapping[str, Any]), - ('globals', Mapping[str, Any]), - ('builtins', Mapping[str, Any]), - ('unbound', AbstractSet[str]), - ]) +class ClosureVars(NamedTuple): + nonlocals: Mapping[str, Any] + globals: Mapping[str, Any] + builtins: Mapping[str, Any] + unbound: AbstractSet[str] def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ... def unwrap(func: Callable[..., Any], @@ -251,25 +249,20 @@ def unwrap(func: Callable[..., Any], # The interpreter stack # -Traceback = NamedTuple( - 'Traceback', - [ - ('filename', str), - ('lineno', int), - ('function', str), - ('code_context', Optional[List[str]]), - ('index', Optional[int]), - ] -) - -# Python 3.5+ (functions returning it used to return regular tuples) -FrameInfo = NamedTuple('FrameInfo', [('frame', FrameType), - ('filename', str), - ('lineno', int), - ('function', str), - ('code_context', Optional[List[str]]), - ('index', Optional[int]), - ]) +class Traceback(NamedTuple): + filename: str + lineno: int + function: str + code_context: Optional[List[str]] + index: Optional[int] # type: ignore + +class FrameInfo(NamedTuple): + frame: FrameType + filename: str + lineno: int + function: str + code_context: Optional[List[str]] + index: Optional[int] # type: ignore def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ... def getouterframes(frame: Any, context: int = ...) -> List[FrameInfo]: ... @@ -311,10 +304,10 @@ def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> Dict[str, Any]: . # TODO can we be more specific than "object"? def getcoroutinelocals(coroutine: object) -> Dict[str, Any]: ... -Attribute = NamedTuple('Attribute', [('name', str), - ('kind', str), - ('defining_class', type), - ('object', object), - ]) +class Attribute(NamedTuple): + name: str + kind: str + defining_class: type + object: object def classify_class_attrs(cls: type) -> List[Attribute]: ... diff --git a/stdlib/3/io.pyi b/stdlib/3/io.pyi index 351d5be86d2c..d3cc6948b499 100644 --- a/stdlib/3/io.pyi +++ b/stdlib/3/io.pyi @@ -4,7 +4,6 @@ from typing import ( import builtins import codecs from mmap import mmap -import sys from types import TracebackType from typing import TypeVar diff --git a/stdlib/3/ipaddress.pyi b/stdlib/3/ipaddress.pyi index 3d507f41b911..6b6a45d1d48a 100644 --- a/stdlib/3/ipaddress.pyi +++ b/stdlib/3/ipaddress.pyi @@ -1,5 +1,5 @@ from typing import (Any, Container, Generic, Iterable, Iterator, Optional, - overload, SupportsInt, Tuple, TypeVar) + overload, SupportsInt, Text, Tuple, TypeVar) # Undocumented length constants IPV4LENGTH: int @@ -21,11 +21,11 @@ class _IPAddressBase: def __lt__(self: _T, other: _T) -> bool: ... def __ne__(self, other: Any) -> bool: ... @property - def compressed(self) -> str: ... + def compressed(self) -> Text: ... @property - def exploded(self) -> str: ... + def exploded(self) -> Text: ... @property - def reverse_pointer(self) -> str: ... + def reverse_pointer(self) -> Text: ... @property def version(self) -> int: ... @@ -90,11 +90,11 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): 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) -> str: ... + def with_hostmask(self) -> Text: ... @property - def with_netmask(self) -> str: ... + def with_netmask(self) -> Text: ... @property - def with_prefixlen(self) -> str: ... + def with_prefixlen(self) -> Text: ... @property def hostmask(self) -> _A: ... @@ -105,11 +105,11 @@ class _BaseInterface(_BaseAddress, Generic[_A, _N]): @property def ip(self) -> _A: ... @property - def with_hostmask(self) -> str: ... + def with_hostmask(self) -> Text: ... @property - def with_netmask(self) -> str: ... + def with_netmask(self) -> Text: ... @property - def with_prefixlen(self) -> str: ... + def with_prefixlen(self) -> Text: ... class IPv4Address(_BaseAddress): ... class IPv4Network(_BaseNetwork[IPv4Address]): ... diff --git a/stdlib/3/json/decoder.pyi b/stdlib/3/json/decoder.pyi index 1acb84af8b0e..d57a6a9fc8da 100644 --- a/stdlib/3/json/decoder.pyi +++ b/stdlib/3/json/decoder.pyi @@ -1,4 +1,3 @@ -import sys from typing import Any, Callable, Dict, List, Optional, Tuple class JSONDecodeError(ValueError): diff --git a/stdlib/3/msvcrt.pyi b/stdlib/3/msvcrt.pyi index bcab64cd9a0a..6688c37cd80e 100644 --- a/stdlib/3/msvcrt.pyi +++ b/stdlib/3/msvcrt.pyi @@ -2,7 +2,5 @@ # NOTE: These are incomplete! -from typing import overload, BinaryIO, TextIO - def get_osfhandle(file: int) -> int: ... def open_osfhandle(handle: int, flags: int) -> int: ... diff --git a/stdlib/3/multiprocessing/__init__.pyi b/stdlib/3/multiprocessing/__init__.pyi index e2513f3bd75e..b9910b1182d9 100644 --- a/stdlib/3/multiprocessing/__init__.pyi +++ b/stdlib/3/multiprocessing/__init__.pyi @@ -1,23 +1,27 @@ # Stubs for multiprocessing -from typing import ( - Any, Callable, ContextManager, Iterable, Mapping, Optional, Dict, List, - Union, Sequence, Tuple, Type, overload -) +import sys +from typing import Any, Callable, Iterable, Mapping, Optional, List, Union, Sequence, Tuple, Type, overload from ctypes import _CData from logging import Logger from multiprocessing import connection, pool, spawn, synchronize from multiprocessing.context import ( + AuthenticationError as AuthenticationError, BaseContext, - ProcessError as ProcessError, BufferTooShort as BufferTooShort, TimeoutError as TimeoutError, AuthenticationError as AuthenticationError) + BufferTooShort as BufferTooShort, + Process as Process, + ProcessError as ProcessError, + TimeoutError as TimeoutError, +) from multiprocessing.managers import SyncManager -from multiprocessing.process import current_process as current_process +from multiprocessing.process import active_children as active_children, current_process as current_process from multiprocessing.queues import Queue as Queue, SimpleQueue as SimpleQueue, JoinableQueue as JoinableQueue from multiprocessing.spawn import freeze_support as freeze_support from multiprocessing.spawn import set_executable as set_executable -import sys +if sys.version_info >= (3, 8): + from multiprocessing.process import parent_process as parent_process # N.B. The functions below are generated at runtime by partially applying # multiprocessing.context.BaseContext's methods, so the two signatures should @@ -42,31 +46,6 @@ def Pool(processes: Optional[int] = ..., initargs: Iterable[Any] = ..., maxtasksperchild: Optional[int] = ...) -> pool.Pool: ... -class Process(): - name: str - daemon: bool - pid: Optional[int] - exitcode: Optional[int] - authkey: bytes - sentinel: int - # TODO: set type of group to None - def __init__(self, - group: Any = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., - args: Iterable[Any] = ..., - kwargs: Mapping[Any, Any] = ..., - *, - daemon: Optional[bool] = ...) -> None: ... - def start(self) -> None: ... - def run(self) -> None: ... - def terminate(self) -> None: ... - if sys.version_info >= (3, 7): - def kill(self) -> None: ... - def close(self) -> None: ... - def is_alive(self) -> bool: ... - def join(self, timeout: Optional[float] = ...) -> None: ... - class Array(): value: Any = ... @@ -93,7 +72,6 @@ class Value(): def release(self) -> bool: ... # ----- multiprocessing function stubs ----- -def active_children() -> List[Process]: ... def allow_connection_pickling() -> None: ... def cpu_count() -> int: ... def get_logger() -> Logger: ... diff --git a/stdlib/3/multiprocessing/context.pyi b/stdlib/3/multiprocessing/context.pyi index 2cdeb07d14cc..caf4d123d0c5 100644 --- a/stdlib/3/multiprocessing/context.pyi +++ b/stdlib/3/multiprocessing/context.pyi @@ -4,11 +4,9 @@ from logging import Logger import multiprocessing from multiprocessing import synchronize from multiprocessing import queues +from multiprocessing.process import BaseProcess import sys -from typing import ( - Any, Callable, Iterable, Optional, List, Mapping, Sequence, Tuple, Type, - Union, -) +from typing import Any, Callable, Iterable, Optional, List, Mapping, Sequence, Type, Union _LockLike = Union[synchronize.Lock, synchronize.RLock] @@ -30,9 +28,12 @@ class BaseContext(object): # multiprocessing.*, so the signatures should be identical (modulo self). @staticmethod - def current_process() -> multiprocessing.Process: ... + def current_process() -> BaseProcess: ... + if sys.version_info >= (3, 8): + @staticmethod + def parent_process() -> Optional[BaseProcess]: ... @staticmethod - def active_children() -> List[multiprocessing.Process]: ... + def active_children() -> List[BaseProcess]: ... def cpu_count(self) -> int: ... # TODO: change return to SyncManager once a stub exists in multiprocessing.managers def Manager(self) -> Any: ... @@ -62,16 +63,6 @@ class BaseContext(object): initargs: Iterable[Any] = ..., maxtasksperchild: Optional[int] = ... ) -> multiprocessing.pool.Pool: ... - def Process( - self, - group: Any = ..., - target: Optional[Callable[..., Any]] = ..., - name: Optional[str] = ..., - args: Iterable[Any] = ..., - kwargs: Mapping[Any, Any] = ..., - *, - daemon: Optional[bool] = ... - ) -> multiprocessing.Process: ... # TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out # how to handle the ctype # TODO: change return to RawValue once a stub exists in multiprocessing.sharedctypes @@ -107,46 +98,42 @@ class BaseContext(object): def set_forkserver_preload(self, module_names: List[str]) -> None: ... def get_context(self, method: Optional[str] = ...) -> BaseContext: ... def get_start_method(self, allow_none: bool = ...) -> str: ... - def set_start_method(self, method: Optional[str] = ...) -> None: ... + def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ... @property def reducer(self) -> str: ... @reducer.setter def reducer(self, reduction: str) -> None: ... def _check_available(self) -> None: ... -class Process(object): +class Process(BaseProcess): _start_method: Optional[str] @staticmethod - # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - def _Popen(process_obj: Any) -> DefaultContext: ... + def _Popen(process_obj: BaseProcess) -> DefaultContext: ... -class DefaultContext(object): +class DefaultContext(BaseContext): Process: Type[multiprocessing.Process] def __init__(self, context: BaseContext) -> None: ... def get_context(self, method: Optional[str] = ...) -> BaseContext: ... - def set_start_method(self, method: str, force: bool = ...) -> None: ... + def set_start_method(self, method: Optional[str], force: bool = ...) -> None: ... def get_start_method(self, allow_none: bool = ...) -> str: ... def get_all_start_methods(self) -> List[str]: ... if sys.platform != 'win32': - # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class ForkProcess(Any): # type: ignore + class ForkProcess(BaseProcess): _start_method: str @staticmethod - def _Popen(process_obj: Any) -> Any: ... + def _Popen(process_obj: BaseProcess) -> Any: ... - # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class SpawnProcess(Any): # type: ignore + class SpawnProcess(BaseProcess): _start_method: str @staticmethod - def _Popen(process_obj: Any) -> SpawnProcess: ... + def _Popen(process_obj: BaseProcess) -> SpawnProcess: ... - # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class ForkServerProcess(Any): # type: ignore + class ForkServerProcess(BaseProcess): _start_method: str @staticmethod - def _Popen(process_obj: Any) -> Any: ... + def _Popen(process_obj: BaseProcess) -> Any: ... class ForkContext(BaseContext): _name: str @@ -160,20 +147,16 @@ if sys.platform != 'win32': _name: str Process: Type[ForkServerProcess] else: - # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class SpawnProcess(Any): # type: ignore + class SpawnProcess(BaseProcess): _start_method: str @staticmethod - # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - def _Popen(process_obj: Process) -> Any: ... + def _Popen(process_obj: BaseProcess) -> Any: ... class SpawnContext(BaseContext): _name: str Process: Type[SpawnProcess] def _force_start_method(method: str) -> None: ... -# TODO: type should be BaseProcess once a stub in multiprocessing.process exists def get_spawning_popen() -> Optional[Any]: ... -# TODO: type should be BaseProcess once a stub in multiprocessing.process exists def set_spawning_popen(popen: Any) -> None: ... def assert_spawning(obj: Any) -> None: ... diff --git a/stdlib/3/multiprocessing/dummy/__init__.pyi b/stdlib/3/multiprocessing/dummy/__init__.pyi index 2a995cda633a..0572356e52ba 100644 --- a/stdlib/3/multiprocessing/dummy/__init__.pyi +++ b/stdlib/3/multiprocessing/dummy/__init__.pyi @@ -1,13 +1,9 @@ -from typing import Any, Optional, List, Type +from typing import Any, Optional, List import array -import sys import threading import weakref -from .connection import Pipe -from threading import Lock, RLock, Semaphore, BoundedSemaphore -from threading import Event, Condition, Barrier from queue import Queue JoinableQueue = Queue diff --git a/stdlib/3/multiprocessing/dummy/connection.pyi b/stdlib/3/multiprocessing/dummy/connection.pyi index 537750e19f3b..d465a5b4f434 100644 --- a/stdlib/3/multiprocessing/dummy/connection.pyi +++ b/stdlib/3/multiprocessing/dummy/connection.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple, Type, TypeVar +from typing import Any, List, Optional, Tuple, TypeVar from queue import Queue diff --git a/stdlib/3/multiprocessing/managers.pyi b/stdlib/3/multiprocessing/managers.pyi index 7522d0ae437f..151ade02efad 100644 --- a/stdlib/3/multiprocessing/managers.pyi +++ b/stdlib/3/multiprocessing/managers.pyi @@ -3,11 +3,16 @@ # NOTE: These are incomplete! import queue +import sys import threading from typing import ( Any, Callable, ContextManager, Dict, Iterable, Generic, List, Mapping, Optional, Sequence, Tuple, TypeVar, Union, ) +from .context import BaseContext + +if sys.version_info >= (3, 8): + from .shared_memory import ShareableList, SharedMemory, _SLT _T = TypeVar('_T') _KT = TypeVar('_KT') @@ -24,18 +29,32 @@ class ValueProxy(BaseProxy, Generic[_T]): def set(self, value: _T) -> None: ... value: _T +# Returned by BaseManager.get_server() +class Server: + address: Any + def serve_forever(self) -> None: ... + class BaseManager(ContextManager[BaseManager]): - address: Union[str, Tuple[str, int]] + def __init__( + self, + address: Optional[Any] = ..., + authkey: Optional[bytes] = ..., + serializer: str = ..., + ctx: Optional[BaseContext] = ..., + ) -> None: ... + def get_server(self) -> Server: ... def connect(self) -> None: ... + def start(self, initializer: Optional[Callable[..., Any]] = ..., initargs: Iterable[Any] = ...) -> None: ... + def shutdown(self) -> None: ... # only available after start() was called + def join(self, timeout: Optional[float] = ...) -> None: ... # undocumented + @property + def address(self) -> Any: ... @classmethod def register(cls, typeid: str, callable: Optional[Callable[..., Any]] = ..., proxytype: Any = ..., exposed: Optional[Sequence[str]] = ..., method_to_typeid: Optional[Mapping[str, str]] = ..., create_method: bool = ...) -> None: ... - def shutdown(self) -> None: ... - def start(self, initializer: Optional[Callable[..., Any]] = ..., - initargs: Iterable[Any] = ...) -> None: ... class SyncManager(BaseManager, ContextManager[SyncManager]): def BoundedSemaphore(self, value: Any = ...) -> threading.BoundedSemaphore: ... @@ -52,3 +71,10 @@ class SyncManager(BaseManager, ContextManager[SyncManager]): def list(self, sequence: Sequence[_T] = ...) -> List[_T]: ... class RemoteError(Exception): ... + +if sys.version_info >= (3, 8): + class SharedMemoryServer(Server): ... + class SharedMemoryManager(BaseManager): + def get_server(self) -> SharedMemoryServer: ... + def SharedMemory(self, size: int) -> SharedMemory: ... + def ShareableList(self, sequence: Optional[Iterable[_SLT]]) -> ShareableList[_SLT]: ... diff --git a/stdlib/3/multiprocessing/pool.pyi b/stdlib/3/multiprocessing/pool.pyi index 3782a3f1dc4b..5d37644306e7 100644 --- a/stdlib/3/multiprocessing/pool.pyi +++ b/stdlib/3/multiprocessing/pool.pyi @@ -1,8 +1,4 @@ -from typing import ( - Any, Callable, ContextManager, Iterable, Mapping, Optional, List, - Type, TypeVar, Generic, Iterator -) -from types import TracebackType +from typing import Any, Callable, ContextManager, Iterable, Mapping, Optional, List, TypeVar, Generic, Iterator _PT = TypeVar('_PT', bound=Pool) _S = TypeVar('_S') @@ -50,7 +46,7 @@ class Pool(ContextManager[Pool]): iterable: Iterable[_S] = ..., chunksize: Optional[int] = ..., callback: Optional[Callable[[_T], None]] = ..., - error_callback: Optional[Callable[[BaseException], None]] = ...) -> MapResult[List[_T]]: ... + error_callback: Optional[Callable[[BaseException], None]] = ...) -> MapResult[_T]: ... def imap(self, func: Callable[[_S], _T], iterable: Iterable[_S] = ..., diff --git a/stdlib/3/multiprocessing/process.pyi b/stdlib/3/multiprocessing/process.pyi index df8ea9300a37..a979ee7b283d 100644 --- a/stdlib/3/multiprocessing/process.pyi +++ b/stdlib/3/multiprocessing/process.pyi @@ -1,5 +1,38 @@ -from typing import List -from multiprocessing import Process +import sys +from typing import Any, Callable, List, Mapping, Optional, Tuple -def current_process() -> Process: ... -def active_children() -> List[Process]: ... +class BaseProcess: + name: str + daemon: bool + authkey: bytes + def __init__( + self, + group: None = ..., + target: Optional[Callable[..., Any]] = ..., + name: Optional[str] = ..., + args: Tuple[Any, ...] = ..., + kwargs: Mapping[str, Any] = ..., + *, + daemon: Optional[bool] = ..., + ) -> None: ... + def run(self) -> None: ... + def start(self) -> None: ... + def terminate(self) -> None: ... + if sys.version_info >= (3, 7): + def kill(self) -> None: ... + def close(self) -> None: ... + def join(self, timeout: Optional[float] = ...) -> None: ... + def is_alive(self) -> bool: ... + @property + def exitcode(self) -> Optional[int]: ... + @property + def ident(self) -> Optional[int]: ... + @property + def pid(self) -> Optional[int]: ... + @property + def sentinel(self) -> int: ... + +def current_process() -> BaseProcess: ... +def active_children() -> List[BaseProcess]: ... +if sys.version_info >= (3, 8): + def parent_process() -> Optional[BaseProcess]: ... diff --git a/stdlib/3/multiprocessing/shared_memory.pyi b/stdlib/3/multiprocessing/shared_memory.pyi new file mode 100644 index 000000000000..6a16a09a60ef --- /dev/null +++ b/stdlib/3/multiprocessing/shared_memory.pyi @@ -0,0 +1,29 @@ +import sys +from typing import Generic, Iterable, Optional, Tuple, TypeVar + +_S = TypeVar("_S") +_SLT = TypeVar("_SLT", int, float, bool, str, bytes, None) + +if sys.version_info >= (3, 8): + class SharedMemory: + def __init__(self, name: Optional[str] = ..., create: bool = ..., size: int = ...) -> None: ... + @property + def buf(self) -> memoryview: ... + @property + def name(self) -> str: ... + @property + def size(self) -> int: ... + def close(self) -> None: ... + def unlink(self) -> None: ... + + class ShareableList(Generic[_SLT]): + shm: SharedMemory + def __init__(self, sequence: Optional[Iterable[_SLT]] = ..., *, name: Optional[str] = ...) -> None: ... + def __getitem__(self, position: int) -> _SLT: ... + def __setitem__(self, position: int, value: _SLT) -> None: ... + def __reduce__(self: _S) -> Tuple[_S, Tuple[_SLT, ...]]: ... + def __len__(self) -> int: ... + @property + def format(self) -> str: ... + def count(self, value: _SLT) -> int: ... + def index(self, value: _SLT) -> int: ... diff --git a/stdlib/3/nntplib.pyi b/stdlib/3/nntplib.pyi index 00abdd994ba5..78b078cb104f 100644 --- a/stdlib/3/nntplib.pyi +++ b/stdlib/3/nntplib.pyi @@ -20,17 +20,15 @@ class NNTPDataError(NNTPError): ... NNTP_PORT: int NNTP_SSL_PORT: int -GroupInfo = NamedTuple('GroupInfo', [ - ('group', str), - ('last', str), - ('first', str), - ('flag', str), -]) -ArticleInfo = NamedTuple('ArticleInfo', [ - ('number', int), - ('message_id', str), - ('lines', List[bytes]), -]) +class GroupInfo(NamedTuple): + group: str + last: str + first: str + flag: str +class ArticleInfo(NamedTuple): + number: int + message_id: str + lines: List[bytes] def decode_header(header_str: str) -> str: ... diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index 085000a0922f..b17a55736cd1 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -5,7 +5,7 @@ from io import TextIOWrapper as _TextIOWrapper from posix import listdir as listdir, times_result import sys from typing import ( - Mapping, MutableMapping, Dict, List, Any, Tuple, IO, Iterable, Iterator, NoReturn, overload, Union, AnyStr, + Mapping, MutableMapping, Dict, List, Any, Tuple, Iterable, Iterator, NoReturn, overload, Union, AnyStr, Optional, Generic, Set, Callable, Text, Sequence, NamedTuple, TypeVar, ContextManager ) @@ -210,6 +210,8 @@ class stat_result: st_atime_ns: int # time of most recent access, in nanoseconds st_mtime_ns: int # time of most recent content modification in nanoseconds st_ctime_ns: int # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) in nanoseconds + if sys.version_info >= (3, 8) and sys.platform == "win32": + st_reparse_tag: int def __getitem__(self, i: int) -> int: ... @@ -391,7 +393,9 @@ if sys.platform != 'win32': def readv(fd: int, buffers: Sequence[bytearray]) -> int: ... def writev(fd: int, buffers: Sequence[bytes]) -> int: ... -terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)]) +class terminal_size(NamedTuple): + columns: int + lines: int def get_terminal_size(fd: int = ...) -> terminal_size: ... def get_inheritable(fd: int) -> bool: ... @@ -631,3 +635,31 @@ else: if sys.version_info >= (3, 7): def register_at_fork(func: Callable[..., object], when: str) -> None: ... + +if sys.version_info >= (3, 8): + if sys.platform == "win32": + class _AddedDllDirectory: + path: Optional[str] + def close(self) -> None: ... + def __enter__(self: _T) -> _T: ... + def __exit__(self, *args: Any) -> None: ... + def add_dll_directory(path: str) -> _AddedDllDirectory: ... + if sys.platform == "linux": + MFD_CLOEXEC: int + MFD_ALLOW_SEALING: int + MFD_HUGETLB: int + MFD_HUGE_SHIFT: int + MFD_HUGE_MASK: int + MFD_HUGE_64KB: int + MFD_HUGE_512KB: int + MFD_HUGE_1MB: int + MFD_HUGE_2MB: int + MFD_HUGE_8MB: int + MFD_HUGE_16MB: int + MFD_HUGE_32MB: int + MFD_HUGE_256MB: int + MFD_HUGE_512MB: int + MFD_HUGE_1GB: int + MFD_HUGE_2GB: int + MFD_HUGE_16GB: int + def memfd_create(name: str, flags: int = ...) -> int: ... diff --git a/stdlib/3/os/path.pyi b/stdlib/3/os/path.pyi index c0bf57658ed7..42409c0e8721 100644 --- a/stdlib/3/os/path.pyi +++ b/stdlib/3/os/path.pyi @@ -4,10 +4,7 @@ import os import sys -from typing import ( - overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO, - TypeVar, Union, Text, Callable, Optional -) +from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional _T = TypeVar('_T') diff --git a/stdlib/3/pathlib.pyi b/stdlib/3/pathlib.pyi index ff6bedd1c043..fb925e60121b 100644 --- a/stdlib/3/pathlib.pyi +++ b/stdlib/3/pathlib.pyi @@ -127,6 +127,8 @@ class Path(PurePath): def write_bytes(self, data: bytes) -> int: ... def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ... + if sys.version_info >= (3, 8): + def link_to(self, target: Union[str, bytes, os.PathLike[str]]) -> None: ... class PosixPath(Path, PurePosixPath): ... diff --git a/stdlib/3/platform.pyi b/stdlib/3/platform.pyi index 728e259fe92c..858bb5930862 100644 --- a/stdlib/3/platform.pyi +++ b/stdlib/3/platform.pyi @@ -1,7 +1,6 @@ # Stubs for platform (Python 3.5) from os import devnull as DEV_NULL -from os import popen from typing import Tuple, NamedTuple def libc_ver(executable: str = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ... @@ -13,7 +12,13 @@ def java_ver(release: str = ..., vendor: str = ..., vminfo: Tuple[str, str, str] def system_alias(system: str, release: str, version: str) -> Tuple[str, str, str]: ... def architecture(executable: str = ..., bits: str = ..., linkage: str = ...) -> Tuple[str, str]: ... -uname_result = NamedTuple('uname_result', [('system', str), ('node', str), ('release', str), ('version', str), ('machine', str), ('processor', str)]) +class uname_result(NamedTuple): + system: str + node: str + release: str + version: str + machine: str + processor: str def uname() -> uname_result: ... def system() -> str: ... diff --git a/stdlib/3/posix.pyi b/stdlib/3/posix.pyi index 83537cfbc650..c6092ead447c 100644 --- a/stdlib/3/posix.pyi +++ b/stdlib/3/posix.pyi @@ -3,41 +3,36 @@ # NOTE: These are incomplete! import sys -from typing import List, NamedTuple, Optional, overload, Tuple +from typing import List, NamedTuple, Optional, overload from os import stat_result as stat_result if sys.version_info >= (3, 6): from builtins import _PathLike # See comment in builtins -uname_result = NamedTuple('uname_result', [ - ('sysname', str), - ('nodename', str), - ('release', str), - ('version', str), - ('machine', str), -]) - -times_result = NamedTuple('times_result', [ - ('user', float), - ('system', float), - ('children_user', float), - ('children_system', float), - ('elapsed', float), -]) - -waitid_result = NamedTuple('waitid_result', [ - ('si_pid', int), - ('si_uid', int), - ('si_signo', int), - ('si_status', int), - ('si_code', int), -]) - -sched_param = NamedTuple('sched_param', [ - ('sched_priority', int), -]) - +class uname_result(NamedTuple): + sysname: str + nodename: str + release: str + version: str + machine: str + +class times_result(NamedTuple): + user: float + system: float + children_user: float + children_system: float + elapsed: float + +class waitid_result(NamedTuple): + si_pid: int + si_uid: int + si_signo: int + si_status: int + si_code: int + +class sched_param(NamedTuple): + sched_priority: int EX_CANTCREAT: int EX_CONFIG: int diff --git a/stdlib/3/resource.pyi b/stdlib/3/resource.pyi index 0d2e30bb367c..b4a6829f300f 100644 --- a/stdlib/3/resource.pyi +++ b/stdlib/3/resource.pyi @@ -25,12 +25,23 @@ RUSAGE_CHILDREN: int RUSAGE_SELF: int RUSAGE_THREAD: int -_RUsage = NamedTuple('_RUsage', [('ru_utime', float), ('ru_stime', float), ('ru_maxrss', int), - ('ru_ixrss', int), ('ru_idrss', int), ('ru_isrss', int), - ('ru_minflt', int), ('ru_majflt', int), ('ru_nswap', int), - ('ru_inblock', int), ('ru_oublock', int), ('ru_msgsnd', int), - ('ru_msgrcv', int), ('ru_nsignals', int), ('ru_nvcsw', int), - ('ru_nivcsw', int)]) +class _RUsage(NamedTuple): + ru_utime: float + ru_stime: float + ru_maxrss: int + ru_ixrss: int + ru_idrss: int + ru_isrss: int + ru_minflt: int + ru_majflt: int + ru_nswap: int + ru_inblock: int + ru_oublock: int + ru_msgsnd: int + ru_msgrcv: int + ru_nsignals: int + ru_nvcsw: int + ru_nivcsw: int def getpagesize() -> int: ... def getrlimit(resource: int) -> Tuple[int, int]: ... diff --git a/stdlib/3/selectors.pyi b/stdlib/3/selectors.pyi index 6dd864795fc7..99e311daa33a 100644 --- a/stdlib/3/selectors.pyi +++ b/stdlib/3/selectors.pyi @@ -12,18 +12,14 @@ _FileObject = Union[int, _HasFileno] _FileDescriptor = int _EventMask = int - EVENT_READ: _EventMask EVENT_WRITE: _EventMask - -SelectorKey = NamedTuple('SelectorKey', [ - ('fileobj', _FileObject), - ('fd', _FileDescriptor), - ('events', _EventMask), - ('data', Any) -]) - +class SelectorKey(NamedTuple): + fileobj: _FileObject + fd: _FileDescriptor + events: _EventMask + data: Any class BaseSelector(metaclass=ABCMeta): @abstractmethod diff --git a/stdlib/3/shlex.pyi b/stdlib/3/shlex.pyi index fb398ea0628d..2afc6d714ea8 100644 --- a/stdlib/3/shlex.pyi +++ b/stdlib/3/shlex.pyi @@ -1,14 +1,9 @@ -# Stubs for shlex - -# Based on http://docs.python.org/3.2/library/shlex.html - from typing import List, Tuple, Any, TextIO, Union, Optional, Iterable, TypeVar import sys -def split(s: str, comments: bool = ..., - posix: bool = ...) -> List[str]: ... - -# Added in 3.3, use (undocumented) pipes.quote in previous versions. +def split(s: str, comments: bool = ..., posix: bool = ...) -> List[str]: ... +if sys.version_info >= (3, 8): + def join(split_command: Iterable[str]) -> str: ... def quote(s: str) -> str: ... _SLT = TypeVar('_SLT', bound=shlex) diff --git a/stdlib/3/signal.pyi b/stdlib/3/signal.pyi index 670567b83650..dd457d8cc4ec 100644 --- a/stdlib/3/signal.pyi +++ b/stdlib/3/signal.pyi @@ -132,42 +132,17 @@ class struct_siginfo(Tuple[int, int, int, int, int, int, int]): def si_band(self) -> int: ... def alarm(time: int) -> int: ... - -def default_int_handler(signum: int, frame: FrameType) -> None: - raise KeyboardInterrupt() - +def default_int_handler(signum: int, frame: FrameType) -> None: ... def getitimer(which: int) -> Tuple[float, float]: ... - -def getsignal(signalnum: _SIGNUM) -> _HANDLER: - raise ValueError() - +def getsignal(signalnum: _SIGNUM) -> _HANDLER: ... def pause() -> None: ... - -def pthread_kill(thread_id: int, signum: int) -> None: - raise OSError() - -def pthread_sigmask(how: int, mask: Iterable[int]) -> Set[_SIGNUM]: - raise OSError() - +def pthread_kill(thread_id: int, signum: int) -> None: ... +def pthread_sigmask(how: int, mask: Iterable[int]) -> Set[_SIGNUM]: ... def set_wakeup_fd(fd: int) -> int: ... - def setitimer(which: int, seconds: float, interval: float = ...) -> Tuple[float, float]: ... - -def siginterrupt(signalnum: int, flag: bool) -> None: - raise OSError() - -def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: - raise OSError() - -def sigpending() -> Any: - raise OSError() - -def sigtimedwait(sigset: Iterable[int], timeout: float) -> Optional[struct_siginfo]: - raise OSError() - raise ValueError() - -def sigwait(sigset: Iterable[int]) -> _SIGNUM: - raise OSError() - -def sigwaitinfo(sigset: Iterable[int]) -> struct_siginfo: - raise OSError() +def siginterrupt(signalnum: int, flag: bool) -> None: ... +def signal(signalnum: _SIGNUM, handler: _HANDLER) -> _HANDLER: ... +def sigpending() -> Any: ... +def sigtimedwait(sigset: Iterable[int], timeout: float) -> Optional[struct_siginfo]: ... +def sigwait(sigset: Iterable[int]) -> _SIGNUM: ... +def sigwaitinfo(sigset: Iterable[int]) -> struct_siginfo: ... diff --git a/stdlib/3/smtplib.pyi b/stdlib/3/smtplib.pyi index d13439b385d5..60e3a35b83ba 100644 --- a/stdlib/3/smtplib.pyi +++ b/stdlib/3/smtplib.pyi @@ -2,10 +2,7 @@ from email.message import Message as _Message from socket import socket from ssl import SSLContext from types import TracebackType -from typing import ( - Any, AnyStr, Dict, Generic, List, Optional, Sequence, Tuple, Union, - Pattern, Type, Callable, Protocol, overload) -import sys +from typing import Any, Dict, List, Optional, Sequence, Tuple, Union, Pattern, Type, Protocol, overload _Reply = Tuple[int, bytes] _SendErrs = Dict[str, _Reply] @@ -20,6 +17,7 @@ bCRLF: bytes OLDSTYLE_AUTH: Pattern[str] class SMTPException(OSError): ... +class SMTPNotSupportedError(SMTPException): ... class SMTPServerDisconnected(SMTPException): ... class SMTPResponseException(SMTPException): @@ -56,12 +54,13 @@ class _AuthObject(Protocol): class SMTP: debuglevel: int = ... + sock: Optional[socket] = ... # Type of file should match what socket.makefile() returns - file: Any = ... + file: Optional[Any] = ... helo_resp: Optional[bytes] = ... ehlo_msg: str = ... ehlo_resp: Optional[bytes] = ... - does_esmtp: int = ... + does_esmtp: bool = ... default_port: int = ... timeout: float esmtp_features: Dict[str, str] @@ -76,7 +75,6 @@ class SMTP: exc_value: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... def set_debuglevel(self, debuglevel: int) -> None: ... - sock: Optional[socket] def connect(self, host: str = ..., port: int = ..., source_address: Optional[_SourceAddress] = ...) -> _Reply: ... def send(self, s: Union[bytes, str]) -> None: ... @@ -119,6 +117,7 @@ class SMTP: def quit(self) -> _Reply: ... class SMTP_SSL(SMTP): + default_port: int = ... keyfile: Optional[str] certfile: Optional[str] context: SSLContext diff --git a/stdlib/3/spwd.pyi b/stdlib/3/spwd.pyi index 0e55d74215ef..1fb972f6d990 100644 --- a/stdlib/3/spwd.pyi +++ b/stdlib/3/spwd.pyi @@ -1,14 +1,15 @@ from typing import List, NamedTuple -struct_spwd = NamedTuple("struct_spwd", [("sp_namp", str), - ("sp_pwdp", str), - ("sp_lstchg", int), - ("sp_min", int), - ("sp_max", int), - ("sp_warn", int), - ("sp_inact", int), - ("sp_expire", int), - ("sp_flag", int)]) +class struct_spwd(NamedTuple): + sp_namp: str + sp_pwdp: str + sp_lstchg: int + sp_min: int + sp_max: int + sp_warn: int + sp_inact: int + sp_expire: int + sp_flag: int def getspall() -> List[struct_spwd]: ... def getspnam(name: str) -> struct_spwd: ... diff --git a/stdlib/3/stat.pyi b/stdlib/3/stat.pyi index c45a06863e2f..b8cff23ceef7 100644 --- a/stdlib/3/stat.pyi +++ b/stdlib/3/stat.pyi @@ -3,7 +3,6 @@ # Based on http://docs.python.org/3.2/library/stat.html import sys -import typing def S_ISDIR(mode: int) -> bool: ... def S_ISCHR(mode: int) -> bool: ... @@ -18,58 +17,81 @@ def S_IFMT(mode: int) -> int: ... def filemode(mode: int) -> str: ... -ST_MODE = 0 -ST_INO = 0 -ST_DEV = 0 -ST_NLINK = 0 -ST_UID = 0 -ST_GID = 0 -ST_SIZE = 0 -ST_ATIME = 0 -ST_MTIME = 0 -ST_CTIME = 0 +ST_MODE: int +ST_INO: int +ST_DEV: int +ST_NLINK: int +ST_UID: int +ST_GID: int +ST_SIZE: int +ST_ATIME: int +ST_MTIME: int +ST_CTIME: int -S_IFSOCK = 0 -S_IFLNK = 0 -S_IFREG = 0 -S_IFBLK = 0 -S_IFDIR = 0 -S_IFCHR = 0 -S_IFIFO = 0 -S_ISUID = 0 -S_ISGID = 0 -S_ISVTX = 0 +S_IFSOCK: int +S_IFLNK: int +S_IFREG: int +S_IFBLK: int +S_IFDIR: int +S_IFCHR: int +S_IFIFO: int +S_ISUID: int +S_ISGID: int +S_ISVTX: int -S_IRWXU = 0 -S_IRUSR = 0 -S_IWUSR = 0 -S_IXUSR = 0 +S_IRWXU: int +S_IRUSR: int +S_IWUSR: int +S_IXUSR: int -S_IRWXG = 0 -S_IRGRP = 0 -S_IWGRP = 0 -S_IXGRP = 0 +S_IRWXG: int +S_IRGRP: int +S_IWGRP: int +S_IXGRP: int -S_IRWXO = 0 -S_IROTH = 0 -S_IWOTH = 0 -S_IXOTH = 0 +S_IRWXO: int +S_IROTH: int +S_IWOTH: int +S_IXOTH: int -S_ENFMT = 0 -S_IREAD = 0 -S_IWRITE = 0 -S_IEXEC = 0 +S_ENFMT: int +S_IREAD: int +S_IWRITE: int +S_IEXEC: int -UF_NODUMP = 0 -UF_IMMUTABLE = 0 -UF_APPEND = 0 -UF_OPAQUE = 0 -UF_NOUNLINK = 0 +UF_NODUMP: int +UF_IMMUTABLE: int +UF_APPEND: int +UF_OPAQUE: int +UF_NOUNLINK: int if sys.platform == 'darwin': - UF_COMPRESSED = 0 # OS X 10.6+ only - UF_HIDDEN = 0 # OX X 10.5+ only -SF_ARCHIVED = 0 -SF_IMMUTABLE = 0 -SF_APPEND = 0 -SF_NOUNLINK = 0 -SF_SNAPSHOT = 0 + UF_COMPRESSED: int # OS X 10.6+ only + UF_HIDDEN: int # OX X 10.5+ only +SF_ARCHIVED: int +SF_IMMUTABLE: int +SF_APPEND: int +SF_NOUNLINK: int +SF_SNAPSHOT: int + +FILE_ATTRIBUTE_ARCHIVE: int +FILE_ATTRIBUTE_COMPRESSED: int +FILE_ATTRIBUTE_DEVICE: int +FILE_ATTRIBUTE_DIRECTORY: int +FILE_ATTRIBUTE_ENCRYPTED: int +FILE_ATTRIBUTE_HIDDEN: int +FILE_ATTRIBUTE_INTEGRITY_STREAM: int +FILE_ATTRIBUTE_NORMAL: int +FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: int +FILE_ATTRIBUTE_NO_SCRUB_DATA: int +FILE_ATTRIBUTE_OFFLINE: int +FILE_ATTRIBUTE_READONLY: int +FILE_ATTRIBUTE_REPARSE_POINT: int +FILE_ATTRIBUTE_SPARSE_FILE: int +FILE_ATTRIBUTE_SYSTEM: int +FILE_ATTRIBUTE_TEMPORARY: int +FILE_ATTRIBUTE_VIRTUAL: int + +if sys.platform == "win32" and sys.version_info >= (3, 8): + IO_REPARSE_TAG_SYMLINK: int + IO_REPARSE_TAG_MOUNT_POINT: int + IO_REPARSE_TAG_APPEXECLINK: int diff --git a/stdlib/3/statistics.pyi b/stdlib/3/statistics.pyi index d9116e58730b..3181044e083e 100644 --- a/stdlib/3/statistics.pyi +++ b/stdlib/3/statistics.pyi @@ -3,13 +3,17 @@ from decimal import Decimal from fractions import Fraction import sys -from typing import Iterable, Optional, TypeVar +from typing import Any, Iterable, List, Optional, SupportsFloat, Type, TypeVar, Union +_T = TypeVar("_T") # Most functions in this module accept homogeneous collections of one of these types _Number = TypeVar('_Number', float, Decimal, Fraction) class StatisticsError(ValueError): ... +if sys.version_info >= (3, 8): + def fmean(data: Iterable[SupportsFloat]) -> float: ... + def geometric_mean(data: Iterable[SupportsFloat]) -> float: ... def mean(data: Iterable[_Number]) -> _Number: ... if sys.version_info >= (3, 6): def harmonic_mean(data: Iterable[_Number]) -> _Number: ... @@ -18,7 +22,43 @@ def median_low(data: Iterable[_Number]) -> _Number: ... def median_high(data: Iterable[_Number]) -> _Number: ... def median_grouped(data: Iterable[_Number]) -> _Number: ... def mode(data: Iterable[_Number]) -> _Number: ... +if sys.version_info >= (3, 8): + def multimode(data: Iterable[_T]) -> List[_T]: ... def pstdev(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... def pvariance(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... +if sys.version_info >= (3, 8): + def quantiles(data: Iterable[_Number], *, n: int = ..., method: str = ...) -> List[_Number]: ... def stdev(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ... def variance(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ... + +if sys.version_info >= (3, 8): + class NormalDist: + def __init__(self, mu: float = ..., sigma: float = ...) -> None: ... + @property + def mean(self) -> float: ... + @property + def median(self) -> float: ... + @property + def mode(self) -> float: ... + @property + def stdev(self) -> float: ... + @property + def variance(self) -> float: ... + @classmethod + def from_samples(cls: Type[_T], data: Iterable[SupportsFloat]) -> _T: ... + def samples(self, n: int, *, seed: Optional[Any]) -> List[float]: ... + def pdf(self, x: float) -> float: ... + def cdf(self, x: float) -> float: ... + def inv_cdf(self, p: float) -> float: ... + def overlap(self, other: NormalDist) -> float: ... + def quantiles(self, n: int = ...) -> List[float]: ... + def __add__(self, x2: Union[float, NormalDist]) -> NormalDist: ... + def __sub__(self, x2: Union[float, NormalDist]) -> NormalDist: ... + def __mul__(self, x2: float) -> NormalDist: ... + def __truediv__(self, x2: float) -> NormalDist: ... + def __pos__(self) -> NormalDist: ... + def __neg__(self) -> NormalDist: ... + __radd__ = __add__ + def __rsub__(self, x2: Union[float, NormalDist]) -> NormalDist: ... + __rmul__ = __mul__ + def __hash__(self) -> int: ... diff --git a/stdlib/3/string.pyi b/stdlib/3/string.pyi index 92fc03611db6..db437d95aed6 100644 --- a/stdlib/3/string.pyi +++ b/stdlib/3/string.pyi @@ -2,7 +2,7 @@ # Based on http://docs.python.org/3.2/library/string.html -from typing import Mapping, Sequence, Any, Optional, Union, List, Tuple, Iterable +from typing import Mapping, Sequence, Any, Optional, Union, Tuple, Iterable ascii_letters: str ascii_lowercase: str @@ -32,10 +32,7 @@ class Formatter: def parse(self, format_string: str) -> Iterable[Tuple[str, Optional[str], Optional[str], Optional[str]]]: ... def get_field(self, field_name: str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... - def get_value(self, key: Union[int, str], args: Sequence[Any], - kwargs: Mapping[str, Any]) -> Any: - raise IndexError() - raise KeyError() + def get_value(self, key: Union[int, str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def check_unused_args(self, used_args: Sequence[Union[int, str]], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... def format_field(self, value: Any, format_spec: str) -> Any: ... diff --git a/stdlib/3/subprocess.pyi b/stdlib/3/subprocess.pyi index 8bc2e807e571..e3a97bd91f6f 100644 --- a/stdlib/3/subprocess.pyi +++ b/stdlib/3/subprocess.pyi @@ -2,11 +2,7 @@ # Based on http://docs.python.org/3.6/library/subprocess.html import sys -from typing import ( - Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union, List, Type, Text, - Generic, TypeVar, AnyStr, - overload, -) +from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union, Type, Text, Generic, TypeVar, AnyStr, overload from types import TracebackType if sys.version_info >= (3, 8): diff --git a/stdlib/3/sys.pyi b/stdlib/3/sys.pyi index 48644328d056..7f16b07d07f5 100644 --- a/stdlib/3/sys.pyi +++ b/stdlib/3/sys.pyi @@ -54,8 +54,6 @@ stderr: TextIO __stdin__: TextIO __stdout__: TextIO __stderr__: TextIO -# deprecated and removed in Python 3.3: -subversion: Tuple[str, str, str] tracebacklimit: int version: str api_version: int @@ -135,8 +133,7 @@ def excepthook(type_: Type[BaseException], value: BaseException, traceback: TracebackType) -> None: ... def exc_info() -> _OptExcInfo: ... # sys.exit() accepts an optional argument of anything printable -def exit(arg: object = ...) -> NoReturn: - raise SystemExit() +def exit(arg: object = ...) -> NoReturn: ... def getcheckinterval() -> int: ... # deprecated def getdefaultencoding() -> str: ... if sys.platform != 'win32': @@ -199,3 +196,13 @@ def setswitchinterval(interval: float) -> None: ... def settscdump(on_flag: bool) -> None: ... def gettotalrefcount() -> int: ... # Debug builds only + +if sys.version_info >= (3, 8): + # not exported by sys + class UnraisableHookArgs: + exc_type: Type[BaseException] + exc_value: Optional[BaseException] + exc_traceback: Optional[TracebackType] + err_msg: Optional[str] + object: Optional[object] + unraisablehook: Callable[[UnraisableHookArgs], Any] diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index c63839470c55..157ad296c985 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -1,5 +1,6 @@ +import sys from types import TracebackType -from typing import Any, Optional, Dict, Callable, Type +from typing import Any, Optional, Dict, Callable, Tuple, Type, Union from tkinter.constants import * # noqa: F403 TclError: Any @@ -389,6 +390,8 @@ class Canvas(Widget, XView, YView): def tag_lower(self, *args): ... lower: Any def move(self, *args): ... + if sys.version_info >= (3, 8): + def moveto(self, tagOrId: Union[int, str], x: str = ..., y: str = ...) -> None: ... def postscript(self, cnf=..., **kw): ... def tag_raise(self, *args): ... lift: Any @@ -615,6 +618,9 @@ class PhotoImage(Image): def get(self, x, y): ... def put(self, data, to: Optional[Any] = ...): ... def write(self, filename, format: Optional[Any] = ..., from_coords: Optional[Any] = ...): ... + if sys.version_info >= (3, 8): + def transparency_get(self, x: int, y: int) -> bool: ... + def transparency_set(self, x: int, y: int, boolean: bool) -> None: ... class BitmapImage(Image): def __init__(self, name: Optional[Any] = ..., cnf=..., master: Optional[Any] = ..., **kw): ... @@ -635,10 +641,15 @@ class Spinbox(Widget, XView): def scan(self, *args): ... def scan_mark(self, x): ... def scan_dragto(self, x): ... - def selection(self, *args): ... + def selection(self, *args: Any) -> Tuple[int, ...]: ... def selection_adjust(self, index): ... def selection_clear(self): ... def selection_element(self, element: Optional[Any] = ...): ... + if sys.version_info >= (3, 8): + def selection_from(self, index: int) -> None: ... + def selection_present(self) -> None: ... + def selection_range(self, start: int, end: int) -> None: ... + def selection_to(self, index: int) -> None: ... class LabelFrame(Widget): def __init__(self, master: Optional[Any] = ..., cnf=..., **kw): ... diff --git a/stdlib/3/tkinter/ttk.pyi b/stdlib/3/tkinter/ttk.pyi index 0362f17cb74c..755fb25214dd 100644 --- a/stdlib/3/tkinter/ttk.pyi +++ b/stdlib/3/tkinter/ttk.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any, Optional +from typing import Any, List, Optional import tkinter def tclobjs_to_py(adict): ... @@ -136,7 +136,10 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def parent(self, item): ... def prev(self, item): ... def see(self, item): ... - def selection(self, selop: Optional[Any] = ..., items: Optional[Any] = ...): ... + if sys.version_info >= (3, 8): + def selection(self) -> List[Any]: ... + else: + def selection(self, selop: Optional[Any] = ..., items: Optional[Any] = ...) -> List[Any]: ... def selection_set(self, items): ... def selection_add(self, items): ... def selection_remove(self, items): ... diff --git a/stdlib/3/tokenize.pyi b/stdlib/3/tokenize.pyi index b3c5fd9641b6..4a29590158cd 100644 --- a/stdlib/3/tokenize.pyi +++ b/stdlib/3/tokenize.pyi @@ -10,13 +10,12 @@ if sys.version_info < (3, 7): _Position = Tuple[int, int] -_TokenInfo = NamedTuple('TokenInfo', [ - ('type', int), - ('string', str), - ('start', _Position), - ('end', _Position), - ('line', str) -]) +class _TokenInfo(NamedTuple): + type: int + string: str + start: _Position + end: _Position + line: str class TokenInfo(_TokenInfo): @property @@ -41,7 +40,7 @@ class Untokenizer: def untokenize(iterable: Iterable[_Token]) -> Any: ... def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ... def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... -def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... +def generate_tokens(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... # undocumented if sys.version_info >= (3, 6): from os import PathLike diff --git a/stdlib/3/types.pyi b/stdlib/3/types.pyi index 61f87832ad9e..b8f7d925afc8 100644 --- a/stdlib/3/types.pyi +++ b/stdlib/3/types.pyi @@ -40,6 +40,8 @@ LambdaType = FunctionType class CodeType: """Create a code object. Not for the faint of heart.""" co_argcount: int + if sys.version_info >= (3, 8): + co_posonlyargcount: int co_kwonlyargcount: int co_nlocals: int co_stacksize: int @@ -54,24 +56,66 @@ class CodeType: co_lnotab: bytes co_freevars: Tuple[str, ...] co_cellvars: Tuple[str, ...] - def __init__( - self, - argcount: int, - kwonlyargcount: int, - nlocals: int, - stacksize: int, - flags: int, - codestring: bytes, - constants: Tuple[Any, ...], - names: Tuple[str, ...], - varnames: Tuple[str, ...], - filename: str, - name: str, - firstlineno: int, - lnotab: bytes, - freevars: Tuple[str, ...] = ..., - cellvars: Tuple[str, ...] = ..., - ) -> None: ... + if sys.version_info >= (3, 8): + def __init__( + self, + argcount: int, + posonlyargcount: int, + kwonlyargcount: int, + nlocals: int, + stacksize: int, + flags: int, + codestring: bytes, + constants: Tuple[Any, ...], + names: Tuple[str, ...], + varnames: Tuple[str, ...], + filename: str, + name: str, + firstlineno: int, + lnotab: bytes, + freevars: Tuple[str, ...] = ..., + cellvars: Tuple[str, ...] = ..., + ) -> None: ... + else: + def __init__( + self, + argcount: int, + kwonlyargcount: int, + nlocals: int, + stacksize: int, + flags: int, + codestring: bytes, + constants: Tuple[Any, ...], + names: Tuple[str, ...], + varnames: Tuple[str, ...], + filename: str, + name: str, + firstlineno: int, + lnotab: bytes, + freevars: Tuple[str, ...] = ..., + cellvars: Tuple[str, ...] = ..., + ) -> None: ... + if sys.version_info >= (3, 8): + def replace( + self, + *, + co_argcount: int = ..., + co_posonlyargcount: int = ..., + co_kwonlyargcount: int = ..., + co_nlocals: int = ..., + co_stacksize: int = ..., + co_flags: int = ..., + co_firstlineno: int = ..., + co_code: bytes = ..., + co_consts: Tuple[Any, ...] = ..., + co_names: Tuple[str, ...] = ..., + co_varnames: Tuple[str, ...] = ..., + co_freevars: Tuple[str, ...] = ..., + co_cellvars: Tuple[str, ...] = ..., + co_filename: str = ..., + co_name: str = ..., + co_lnotab: bytes = ..., + ) -> CodeType: ... class MappingProxyType(Mapping[_KT, _VT], Generic[_KT, _VT]): def __init__(self, mapping: Mapping[_KT, _VT]) -> None: ... diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index fb279c01f46b..bc39caeaff9b 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -99,6 +99,12 @@ class SupportsBytes(Protocol, metaclass=ABCMeta): @abstractmethod def __bytes__(self) -> bytes: ... +if sys.version_info >= (3, 8): + @runtime_checkable + class SupportsIndex(Protocol, metaclass=ABCMeta): + @abstractmethod + def __index__(self) -> int: ... + @runtime_checkable class SupportsAbs(Protocol[_T_co]): @abstractmethod @@ -339,6 +345,8 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, def __rand__(self, o: Iterable[_T]) -> Set[_T]: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... + if sys.version_info >= (3, 8): + def __reversed__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... def __or__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... def __ror__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ... def __sub__(self, o: Iterable[Any]) -> Set[Tuple[_KT_co, _VT_co]]: ... @@ -351,6 +359,8 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): def __rand__(self, o: Iterable[_T]) -> Set[_T]: ... def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_KT_co]: ... + if sys.version_info >= (3, 8): + def __reversed__(self) -> Iterator[_KT_co]: ... def __or__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... def __ror__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ... def __sub__(self, o: Iterable[Any]) -> Set[_KT_co]: ... @@ -361,6 +371,8 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]): class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): def __contains__(self, o: object) -> bool: ... def __iter__(self) -> Iterator[_VT_co]: ... + if sys.version_info >= (3, 8): + def __reversed__(self) -> Iterator[_VT_co]: ... @runtime_checkable class ContextManager(Protocol[_T_co]): @@ -584,6 +596,9 @@ class Pattern(Generic[AnyStr]): def get_type_hints( obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ..., ) -> Dict[str, Any]: ... +if sys.version_info >= (3, 8): + def get_origin(tp: Any) -> Optional[Any]: ... + def get_args(tp: Any) -> Tuple[Any, ...]: ... @overload def cast(tp: Type[_T], obj: Any) -> _T: ... @@ -599,13 +614,16 @@ class NamedTuple(Tuple[Any, ...]): _fields: Tuple[str, ...] _source: str - def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]] = ..., *, - verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ... + def __init__(self, typename: str, fields: Iterable[Tuple[str, Any]] = ..., + **kwargs: Any) -> None: ... @classmethod def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ... - def _asdict(self) -> collections.OrderedDict[str, Any]: ... + if sys.version_info >= (3, 8): + def _asdict(self) -> Dict[str, Any]: ... + else: + def _asdict(self) -> collections.OrderedDict[str, Any]: ... def _replace(self: _T, **kwargs: Any) -> _T: ... # Internal mypy fallback type for all typed dicts (does not exist at runtime) diff --git a/stdlib/3/unittest/__init__.pyi b/stdlib/3/unittest/__init__.pyi index 3ed602c8b6f5..01f0dbb16dfc 100644 --- a/stdlib/3/unittest/__init__.pyi +++ b/stdlib/3/unittest/__init__.pyi @@ -3,6 +3,7 @@ from typing import Iterable, List, Optional, Type, Union from types import ModuleType +from unittest.async_case import * from unittest.case import * from unittest.loader import * from unittest.result import * diff --git a/stdlib/3/unittest/async_case.pyi b/stdlib/3/unittest/async_case.pyi new file mode 100644 index 000000000000..23e1c005c7a1 --- /dev/null +++ b/stdlib/3/unittest/async_case.pyi @@ -0,0 +1,9 @@ +import sys +from typing import Any, Awaitable, Callable +from .case import TestCase + +if sys.version_info >= (3, 8): + class IsolatedAsyncioTestCase(TestCase): + async def asyncSetUp(self) -> None: ... + async def asyncTearDown(self) -> None: ... + def addAsyncCleanup(self, __func: Callable[..., Awaitable[Any]], *args: Any, **kwargs: Any) -> None: ... diff --git a/stdlib/3/unittest/case.pyi b/stdlib/3/unittest/case.pyi index 2e9e523c3ae1..fff5388e44eb 100644 --- a/stdlib/3/unittest/case.pyi +++ b/stdlib/3/unittest/case.pyi @@ -1,16 +1,19 @@ +import logging +import sys +import unittest.result +from types import TracebackType from typing import ( Any, AnyStr, Callable, Container, ContextManager, Dict, FrozenSet, Generic, Iterable, List, NoReturn, Optional, overload, Pattern, Sequence, Set, Tuple, Type, TypeVar, Union, ) -import logging -import unittest.result -from types import TracebackType - _E = TypeVar('_E', bound=BaseException) _FT = TypeVar('_FT', bound=Callable[..., Any]) +if sys.version_info >= (3, 8): + def addModuleCleanup(__function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... + def doModuleCleanups() -> None: ... def expectedFailure(func: _FT) -> _FT: ... def skip(reason: str) -> Callable[[_FT], _FT]: ... @@ -154,6 +157,11 @@ class TestCase: def addCleanup(self, function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... def doCleanups(self) -> None: ... + if sys.version_info >= (3, 8): + @classmethod + def addClassCleanup(cls, __function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ... + @classmethod + def doClassCleanups(cls) -> None: ... def _formatMessage(self, msg: Optional[str], standardMsg: str) -> str: ... # undocumented def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented # below is deprecated diff --git a/stdlib/3/unittest/loader.pyi b/stdlib/3/unittest/loader.pyi index d32c7132bdb1..2371778f9ec1 100644 --- a/stdlib/3/unittest/loader.pyi +++ b/stdlib/3/unittest/loader.pyi @@ -1,4 +1,3 @@ -import sys import unittest.case import unittest.suite import unittest.result diff --git a/stdlib/3/unittest/mock.pyi b/stdlib/3/unittest/mock.pyi index b4c4ce38aab9..396d806b1633 100644 --- a/stdlib/3/unittest/mock.pyi +++ b/stdlib/3/unittest/mock.pyi @@ -98,6 +98,8 @@ class MagicMixin: NonCallableMagicMock = Any MagicMock = Any +if sys.version_info >= (3, 8): + AsyncMock = Any class MagicProxy: name: Any diff --git a/stdlib/3/unittest/result.pyi b/stdlib/3/unittest/result.pyi index cb85399a5548..6ce685a290c8 100644 --- a/stdlib/3/unittest/result.pyi +++ b/stdlib/3/unittest/result.pyi @@ -1,4 +1,4 @@ -from typing import Any, List, Optional, Tuple, Type +from typing import List, Optional, Tuple, Type from types import TracebackType import unittest.case diff --git a/stdlib/3/unittest/runner.pyi b/stdlib/3/unittest/runner.pyi index 4c84d8b06fff..95199b2cd518 100644 --- a/stdlib/3/unittest/runner.pyi +++ b/stdlib/3/unittest/runner.pyi @@ -1,5 +1,4 @@ from typing import Callable, Optional, TextIO, Tuple, Type, Union -import sys import unittest.case import unittest.result import unittest.suite diff --git a/stdlib/3/urllib/error.pyi b/stdlib/3/urllib/error.pyi index 191c765edb88..16ceae8fc838 100644 --- a/stdlib/3/urllib/error.pyi +++ b/stdlib/3/urllib/error.pyi @@ -7,6 +7,5 @@ class URLError(IOError): reason: Union[str, BaseException] class HTTPError(URLError, addinfourl): code: int - headers: Dict[str, str] def __init__(self, url, code, msg, hdrs, fp) -> None: ... class ContentTooShortError(URLError): ... diff --git a/stdlib/3/urllib/parse.pyi b/stdlib/3/urllib/parse.pyi index 952d3cf9e346..fb303e5de2a8 100644 --- a/stdlib/3/urllib/parse.pyi +++ b/stdlib/3/urllib/parse.pyi @@ -1,6 +1,5 @@ # Stubs for urllib.parse from typing import Any, List, Dict, Tuple, AnyStr, Generic, overload, Sequence, Mapping, Union, NamedTuple, Callable, Optional -import sys _Str = Union[bytes, str] @@ -26,10 +25,10 @@ class _ResultMixinBytes(_ResultMixinBase[str]): class _NetlocResultMixinBase(Generic[AnyStr]): - username: AnyStr - password: AnyStr - hostname: AnyStr - port: int + username: Optional[AnyStr] + password: Optional[AnyStr] + hostname: Optional[AnyStr] + port: Optional[int] class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ... @@ -40,31 +39,33 @@ class _DefragResultBase(Tuple[Any, ...], Generic[AnyStr]): fragment: AnyStr -_SplitResultBase = NamedTuple( - '_SplitResultBase', - [ - ('scheme', str), ('netloc', str), ('path', str), ('query', str), ('fragment', str) - ] -) -_SplitResultBytesBase = NamedTuple( - '_SplitResultBytesBase', - [ - ('scheme', bytes), ('netloc', bytes), ('path', bytes), ('query', bytes), ('fragment', bytes) - ] -) - -_ParseResultBase = NamedTuple( - '_ParseResultBase', - [ - ('scheme', str), ('netloc', str), ('path', str), ('params', str), ('query', str), ('fragment', str) - ] -) -_ParseResultBytesBase = NamedTuple( - '_ParseResultBytesBase', - [ - ('scheme', bytes), ('netloc', bytes), ('path', bytes), ('params', bytes), ('query', bytes), ('fragment', bytes) - ] -) +class _SplitResultBase(NamedTuple): + scheme: str + netloc: str + path: str + query: str + fragment: str +class _SplitResultBytesBase(NamedTuple): + scheme: bytes + netloc: bytes + path: bytes + query: bytes + fragment: bytes + +class _ParseResultBase(NamedTuple): + scheme: str + netloc: str + path: str + params: str + query: str + fragment: str +class _ParseResultBytesBase(NamedTuple): + scheme: bytes + netloc: bytes + path: bytes + params: bytes + query: bytes + fragment: bytes # Structured result objects for string data class DefragResult(_DefragResultBase[str], _ResultMixinStr): ... @@ -81,9 +82,9 @@ class SplitResultBytes(_SplitResultBytesBase, _NetlocResultMixinBytes): ... class ParseResultBytes(_ParseResultBytesBase, _NetlocResultMixinBytes): ... -def parse_qs(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> Dict[AnyStr, List[AnyStr]]: ... +def parse_qs(qs: Optional[AnyStr], keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> Dict[AnyStr, List[AnyStr]]: ... -def parse_qsl(qs: AnyStr, keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> List[Tuple[AnyStr, AnyStr]]: ... +def parse_qsl(qs: Optional[AnyStr], keep_blank_values: bool = ..., strict_parsing: bool = ..., encoding: str = ..., errors: str = ...) -> List[Tuple[AnyStr, AnyStr]]: ... @overload @@ -107,7 +108,7 @@ def unquote_plus(string: str, encoding: str = ..., errors: str = ...) -> str: .. @overload def urldefrag(url: str) -> DefragResult: ... @overload -def urldefrag(url: bytes) -> DefragResultBytes: ... +def urldefrag(url: Optional[bytes]) -> DefragResultBytes: ... def urlencode( query: Union[Mapping[Any, Any], Mapping[Any, Sequence[Any]], Sequence[Tuple[Any, Any]], Sequence[Tuple[Any, Sequence[Any]]]], @@ -121,21 +122,23 @@ def urlencode( def urljoin(base: AnyStr, url: Optional[AnyStr], allow_fragments: bool = ...) -> AnyStr: ... @overload -def urlparse(url: str, scheme: str = ..., allow_fragments: bool = ...) -> ParseResult: ... +def urlparse(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> ParseResult: ... @overload -def urlparse(url: bytes, scheme: bytes = ..., allow_fragments: bool = ...) -> ParseResultBytes: ... +def urlparse(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> ParseResultBytes: ... @overload -def urlsplit(url: str, scheme: str = ..., allow_fragments: bool = ...) -> SplitResult: ... +def urlsplit(url: str, scheme: Optional[str] = ..., allow_fragments: bool = ...) -> SplitResult: ... @overload -def urlsplit(url: bytes, scheme: bytes = ..., allow_fragments: bool = ...) -> SplitResultBytes: ... +def urlsplit(url: Optional[bytes], scheme: Optional[bytes] = ..., allow_fragments: bool = ...) -> SplitResultBytes: ... @overload -def urlunparse(components: Tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ... +def urlunparse( + components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]] +) -> AnyStr: ... @overload -def urlunparse(components: Sequence[AnyStr]) -> AnyStr: ... +def urlunparse(components: Sequence[Optional[AnyStr]]) -> AnyStr: ... @overload -def urlunsplit(components: Tuple[AnyStr, AnyStr, AnyStr, AnyStr, AnyStr]) -> AnyStr: ... +def urlunsplit(components: Tuple[Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr], Optional[AnyStr]]) -> AnyStr: ... @overload -def urlunsplit(components: Sequence[AnyStr]) -> AnyStr: ... +def urlunsplit(components: Sequence[Optional[AnyStr]]) -> AnyStr: ... diff --git a/stdlib/3/urllib/response.pyi b/stdlib/3/urllib/response.pyi index 7cbc045a3f76..dca0efacc474 100644 --- a/stdlib/3/urllib/response.pyi +++ b/stdlib/3/urllib/response.pyi @@ -1,6 +1,7 @@ # private module, we only expose what's needed from typing import BinaryIO, Iterable, List, Mapping, Optional, Type, TypeVar +from email.message import Message from types import TracebackType _AIUT = TypeVar("_AIUT", bound=addbase) @@ -31,8 +32,8 @@ class addbase(BinaryIO): def writelines(self, lines: Iterable[bytes]) -> None: ... class addinfo(addbase): - headers: Mapping[str, str] - def info(self) -> Mapping[str, str]: ... + headers: Message + def info(self) -> Message: ... class addinfourl(addinfo): url: str diff --git a/stdlib/3/urllib/robotparser.pyi b/stdlib/3/urllib/robotparser.pyi index 36150ab01d5c..2c5b657b1113 100644 --- a/stdlib/3/urllib/robotparser.pyi +++ b/stdlib/3/urllib/robotparser.pyi @@ -3,7 +3,9 @@ from typing import Iterable, NamedTuple, Optional import sys -_RequestRate = NamedTuple('_RequestRate', [('requests', int), ('seconds', int)]) +class _RequestRate(NamedTuple): + requests: int + seconds: int class RobotFileParser: def __init__(self, url: str = ...) -> None: ... diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 161cea2d84b7..909e3708134d 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -14,7 +14,7 @@ {'stdlib/2and3/builtins.pyi', 'stdlib/2/__builtin__.pyi'}, {'stdlib/2/SocketServer.pyi', 'stdlib/3/socketserver.pyi'}, {'stdlib/2/os2emxpath.pyi', 'stdlib/2and3/posixpath.pyi', - 'stdlib/2and3/ntpath.pyi', 'stdlib/2and3/macpath.pyi', + 'stdlib/2and3/ntpath.pyi', 'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'}, {'stdlib/3/enum.pyi', 'third_party/2/enum.pyi'}, {'stdlib/3/unittest/mock.pyi', 'third_party/2and3/mock.pyi'}, @@ -26,6 +26,7 @@ {'stdlib/3.7/dataclasses.pyi', 'third_party/3/dataclasses.pyi'}, {'stdlib/3/pathlib.pyi', 'third_party/2/pathlib2.pyi'}, {'stdlib/3.7/contextvars.pyi', 'third_party/3/contextvars.pyi'}, + {'stdlib/3/ipaddress.pyi', 'third_party/2/ipaddress.pyi'}, ] def main(): diff --git a/tests/pytype_test.py b/tests/pytype_test.py index d4f422827e2d..ee7ac0bb9cb9 100755 --- a/tests/pytype_test.py +++ b/tests/pytype_test.py @@ -133,7 +133,7 @@ def can_run(exe: str, *, args: List[str]) -> bool: def _is_version(path: str, version: str) -> bool: - return any("{}/{}".format(d, version) in path for d in TYPESHED_SUBDIRS) + return any("{}{}{}".format(d, os.path.sep, version) in path for d in TYPESHED_SUBDIRS) def check_subdirs_discoverable(subdir_paths: List[str]) -> None: diff --git a/third_party/2/enum.pyi b/third_party/2/enum.pyi index 703c7cfa8be3..be22d386dbc7 100644 --- a/third_party/2/enum.pyi +++ b/third_party/2/enum.pyi @@ -66,9 +66,7 @@ if sys.version_info >= (3, 6): def __xor__(self: _T, other: _T) -> _T: ... def __invert__(self: _T) -> _T: ... - # The `type: ignore` comment is needed because mypy considers the type - # signatures of several methods defined in int and Flag to be incompatible. - class IntFlag(int, Flag): # type: ignore + class IntFlag(int, Flag): def __or__(self: _T, other: Union[int, _T]) -> _T: ... def __and__(self: _T, other: Union[int, _T]) -> _T: ... def __xor__(self: _T, other: Union[int, _T]) -> _T: ... diff --git a/third_party/2/ipaddress.pyi b/third_party/2/ipaddress.pyi new file mode 100644 index 000000000000..6b6a45d1d48a --- /dev/null +++ b/third_party/2/ipaddress.pyi @@ -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): ... diff --git a/third_party/2/pathlib2.pyi b/third_party/2/pathlib2.pyi index ff6bedd1c043..fb925e60121b 100644 --- a/third_party/2/pathlib2.pyi +++ b/third_party/2/pathlib2.pyi @@ -127,6 +127,8 @@ class Path(PurePath): def write_bytes(self, data: bytes) -> int: ... def write_text(self, data: str, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> int: ... + if sys.version_info >= (3, 8): + def link_to(self, target: Union[str, bytes, os.PathLike[str]]) -> None: ... class PosixPath(Path, PurePosixPath): ... diff --git a/third_party/2/tornado/gen.pyi b/third_party/2/tornado/gen.pyi index ee3954b09863..eac8278b3141 100644 --- a/third_party/2/tornado/gen.pyi +++ b/third_party/2/tornado/gen.pyi @@ -1,5 +1,4 @@ -from typing import Any -from collections import namedtuple +from typing import Any, Dict, NamedTuple, Tuple singledispatch: Any @@ -104,6 +103,8 @@ class Runner: def result_callback(self, key): ... def handle_exception(self, typ, value, tb): ... -Arguments = namedtuple('Arguments', ['args', 'kwargs']) +class Arguments(NamedTuple): + args: Tuple[str, ...] + kwargs: Dict[str, Any] def convert_yielded(yielded): ... diff --git a/third_party/2/tornado/httputil.pyi b/third_party/2/tornado/httputil.pyi index 5f74cb57c31e..85a08ebcdb4c 100644 --- a/third_party/2/tornado/httputil.pyi +++ b/third_party/2/tornado/httputil.pyi @@ -1,6 +1,6 @@ -from typing import Any, Dict +from typing import Any, Dict, NamedTuple + from tornado.util import ObjectDict -from collections import namedtuple class SSLError(Exception): ... @@ -79,11 +79,17 @@ def parse_body_arguments(content_type, body, arguments, files, headers=...): ... def parse_multipart_form_data(boundary, data, arguments, files): ... def format_timestamp(ts): ... -RequestStartLine = namedtuple('RequestStartLine', ['method', 'path', 'version']) +class RequestStartLine(NamedTuple): + method: str + path: str + version: str def parse_request_start_line(line): ... -ResponseStartLine = namedtuple('ResponseStartLine', ['version', 'code', 'reason']) +class ResponseStartLine(NamedTuple): + version: str + code: str + reason: str def parse_response_start_line(line): ... def doctests(): ... diff --git a/third_party/2and3/click/decorators.pyi b/third_party/2and3/click/decorators.pyi index 04787749f253..2df9506acf7a 100644 --- a/third_party/2and3/click/decorators.pyi +++ b/third_party/2and3/click/decorators.pyi @@ -94,7 +94,7 @@ def option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., @@ -126,7 +126,7 @@ def option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., @@ -158,7 +158,7 @@ def option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., @@ -190,7 +190,7 @@ def option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., @@ -221,7 +221,7 @@ def confirmation_option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., @@ -249,7 +249,7 @@ def password_option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., @@ -280,7 +280,7 @@ def version_option( # Option prog_name: Optional[str] = ..., message: Optional[str] = ..., - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., @@ -308,7 +308,7 @@ def help_option( *param_decls: str, cls: Type[Option] = ..., # Option - show_default: bool = ..., + show_default: Union[bool, Text] = ..., prompt: Union[bool, Text] = ..., confirmation_prompt: bool = ..., hide_input: bool = ..., diff --git a/third_party/2and3/cryptography/__init__.pyi b/third_party/2and3/cryptography/__init__.pyi index e69de29bb2d1..e27843e53382 100644 --- a/third_party/2and3/cryptography/__init__.pyi +++ b/third_party/2and3/cryptography/__init__.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/third_party/2and3/cryptography/hazmat/__init__.pyi b/third_party/2and3/cryptography/hazmat/__init__.pyi index e69de29bb2d1..e27843e53382 100644 --- a/third_party/2and3/cryptography/hazmat/__init__.pyi +++ b/third_party/2and3/cryptography/hazmat/__init__.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/third_party/2and3/cryptography/hazmat/primitives/__init__.pyi b/third_party/2and3/cryptography/hazmat/primitives/__init__.pyi index e69de29bb2d1..e27843e53382 100644 --- a/third_party/2and3/cryptography/hazmat/primitives/__init__.pyi +++ b/third_party/2and3/cryptography/hazmat/primitives/__init__.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/third_party/2and3/cryptography/hazmat/primitives/asymmetric/__init__.pyi b/third_party/2and3/cryptography/hazmat/primitives/asymmetric/__init__.pyi index e69de29bb2d1..e27843e53382 100644 --- a/third_party/2and3/cryptography/hazmat/primitives/asymmetric/__init__.pyi +++ b/third_party/2and3/cryptography/hazmat/primitives/asymmetric/__init__.pyi @@ -0,0 +1,3 @@ +from typing import Any + +def __getattr__(name: str) -> Any: ... diff --git a/third_party/2and3/decorator.pyi b/third_party/2and3/decorator.pyi new file mode 100644 index 000000000000..adf5ebe7b47a --- /dev/null +++ b/third_party/2and3/decorator.pyi @@ -0,0 +1,84 @@ +import sys +from typing import Any, Callable, Dict, Iterator, List, NamedTuple, Optional, Pattern, Text, Tuple, TypeVar + +_C = TypeVar("_C", bound=Callable[..., Any]) +_Func = TypeVar("_Func", bound=Callable[..., Any]) +_T = TypeVar("_T") + +def get_init(cls): ... + +if sys.version_info >= (3,): + from inspect import iscoroutinefunction as iscoroutinefunction + from inspect import getfullargspec as getfullargspec +else: + class FullArgSpec(NamedTuple): + args: List[str] + varargs: Optional[str] + varkw: Optional[str] + defaults: Tuple[Any, ...] + kwonlyargs: List[str] + kwonlydefaults: Dict[str, Any] + annotations: Dict[str, Any] + def iscoroutinefunction(f: Callable[..., Any]) -> bool: ... + def getfullargspec(func: Any) -> FullArgSpec: ... + +if sys.version_info >= (3, 2): + from contextlib import _GeneratorContextManager +else: + from contextlib import GeneratorContextManager as _GeneratorContextManager + +DEF: Pattern[str] + +class FunctionMaker(object): + args: List[Text] + varargs: Optional[Text] + varkw: Optional[Text] + defaults: Tuple[Any, ...] + kwonlyargs: List[Text] + kwonlydefaults: Optional[Text] + shortsignature: Optional[Text] + name: Text + doc: Optional[Text] + module: Optional[Text] + annotations: Dict[Text, Any] + signature: Text + dict: Dict[Text, Any] + def __init__( + self, + func: Optional[Callable[..., Any]] = ..., + name: Optional[Text] = ..., + signature: Optional[Text] = ..., + defaults: Optional[Tuple[Any, ...]] = ..., + doc: Optional[Text] = ..., + module: Optional[Text] = ..., + funcdict: Optional[Dict[Text, Any]] = ... + ) -> None: ... + def update(self, func: Any, **kw: Any) -> None: ... + def make( + self, + src_templ: Text, + evaldict: Optional[Dict[Text, Any]] = ..., + addsource: bool = ..., + **attrs: Any + ) -> Callable[..., Any]: ... + @classmethod + def create( + cls, + obj: Any, + body: Text, + evaldict: Dict[Text, Any], + defaults: Optional[Tuple[Any, ...]] = ..., + doc: Optional[Text] = ..., + module: Optional[Text] = ..., + addsource: bool = ..., + **attrs: Any + ) -> Callable[..., Any]: ... + +def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ... +def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ... + +class ContextManager(_GeneratorContextManager[_T]): + def __call__(self, func: _C) -> _C: ... + +def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +def dispatch_on(*dispatch_args: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ... diff --git a/third_party/2and3/geoip2/__init__.pyi b/third_party/2and3/geoip2/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/third_party/2and3/geoip2/database.pyi b/third_party/2and3/geoip2/database.pyi new file mode 100644 index 000000000000..7a8991160162 --- /dev/null +++ b/third_party/2and3/geoip2/database.pyi @@ -0,0 +1,22 @@ +from types import TracebackType +from typing import Optional, Sequence, Text, Type + +from maxminddb.reader import Metadata +from geoip2.models import AnonymousIP, ASN, City, ConnectionType, Country, Domain, Enterprise, ISP + +_Locales = Optional[Sequence[Text]] + +class Reader: + def __init__(self, filename: Text, locales: _Locales = ..., mode: int = ...) -> None: ... + def __enter__(self) -> Reader: ... + def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = ..., exc_tb: Optional[TracebackType] = ...) -> None: ... + def country(self, ip_address: Text) -> Country: ... + def city(self, ip_address: Text) -> City: ... + def anonymous_ip(self, ip_address: Text) -> AnonymousIP: ... + def asn(self, ip_address: Text) -> ASN: ... + def connection_type(self, ip_address: Text) -> ConnectionType: ... + def domain(self, ip_address: Text) -> Domain: ... + def enterprise(self, ip_address: Text) -> Enterprise: ... + def isp(self, ip_address: Text) -> ISP: ... + def metadata(self) -> Metadata: ... + def close(self) -> None: ... diff --git a/third_party/2and3/geoip2/errors.pyi b/third_party/2and3/geoip2/errors.pyi new file mode 100644 index 000000000000..d5b703c30432 --- /dev/null +++ b/third_party/2and3/geoip2/errors.pyi @@ -0,0 +1,18 @@ +from typing import Optional, Text + +class GeoIP2Error(RuntimeError): ... + +class AddressNotFoundError(GeoIP2Error): ... + +class AuthenticationError(GeoIP2Error): ... + +class HTTPError(GeoIP2Error): + http_status: Optional[int] + uri: Optional[Text] + def __init__(self, message: Text, http_status: Optional[int] = ..., uri: Optional[Text] = ...) -> None: ... + +class InvalidRequestError(GeoIP2Error): ... + +class OutOfQueriesError(GeoIP2Error): ... + +class PermissionRequiredError(GeoIP2Error): ... diff --git a/third_party/2and3/geoip2/mixins.pyi b/third_party/2and3/geoip2/mixins.pyi new file mode 100644 index 000000000000..8c683c26b84b --- /dev/null +++ b/third_party/2and3/geoip2/mixins.pyi @@ -0,0 +1,3 @@ +class SimpleEquality: + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... diff --git a/third_party/2and3/geoip2/models.pyi b/third_party/2and3/geoip2/models.pyi new file mode 100644 index 000000000000..d9330ef8f428 --- /dev/null +++ b/third_party/2and3/geoip2/models.pyi @@ -0,0 +1,65 @@ +from typing import Any, Mapping, Optional, Sequence, Text + +from geoip2 import records + +from geoip2.mixins import SimpleEquality + +_Locales = Optional[Sequence[Text]] +_RawResponse = Mapping[Text, Mapping[Text, Any]] + +class Country(SimpleEquality): + continent: records.Continent + country: records.Country + registered_country: records.Country + represented_country: records.RepresentedCountry + maxmind: records.MaxMind + traits: records.Traits + raw: _RawResponse + def __init__(self, raw_response: _RawResponse, locales: _Locales = ...) -> None: ... + +class City(Country): + city: records.City + location: records.Location + postal: records.Postal + subdivisions: records.Subdivisions + def __init__(self, raw_response: _RawResponse, locales: _Locales = ...) -> None: ... + +class Insights(City): ... + +class Enterprise(City): ... + +class SimpleModel(SimpleEquality): ... + +class AnonymousIP(SimpleModel): + is_anonymous: bool + is_anonymous_vpn: bool + is_hosting_provider: bool + is_public_proxy: bool + is_tor_exit_node: bool + ip_address: Optional[Text] + raw: _RawResponse + def __init__(self, raw: _RawResponse) -> None: ... + +class ASN(SimpleModel): + autonomous_system_number: Optional[int] + autonomous_system_organization: Optional[Text] + ip_address: Optional[Text] + raw: _RawResponse + def __init__(self, raw: _RawResponse) -> None: ... + +class ConnectionType(SimpleModel): + connection_type: Optional[Text] + ip_address: Optional[Text] + raw: _RawResponse + def __init__(self, raw: _RawResponse) -> None: ... + +class Domain(SimpleModel): + domain: Optional[Text] + ip_address: Optional[Text] + raw: Optional[Text] + def __init__(self, raw: _RawResponse) -> None: ... + +class ISP(ASN): + isp: Optional[Text] + organization: Optional[Text] + def __init__(self, raw: _RawResponse) -> None: ... diff --git a/third_party/2and3/geoip2/records.pyi b/third_party/2and3/geoip2/records.pyi new file mode 100644 index 000000000000..0d90b18ca449 --- /dev/null +++ b/third_party/2and3/geoip2/records.pyi @@ -0,0 +1,83 @@ +from typing import Any, Mapping, Optional, Sequence, Text, Tuple + +from geoip2.mixins import SimpleEquality + +_Locales = Optional[Sequence[Text]] +_Names = Mapping[Text, Text] + +class Record(SimpleEquality): + def __init__(self, **kwargs: Any) -> None: ... + def __setattr__(self, name: Text, value: Any) -> None: ... + +class PlaceRecord(Record): + def __init__(self, locales: _Locales = ..., **kwargs: Any) -> None: ... + @property + def name(self) -> Text: ... + +class City(PlaceRecord): + confidence: int + geoname_id: int + names: _Names + +class Continent(PlaceRecord): + code: Text + geoname_id: int + names: _Names + +class Country(PlaceRecord): + confidence: int + geoname_id: int + is_in_european_union: bool + iso_code: Text + names: _Names + def __init__(self, locales: _Locales = ..., **kwargs: Any) -> None: ... + +class RepresentedCountry(Country): + type: Text + +class Location(Record): + average_income: int + accuracy_radius: int + latitude: float + longitude: float + metro_code: int + population_density: int + time_zone: Text + +class MaxMind(Record): + queries_remaining: int + +class Postal(Record): + code: Text + confidence: int + +class Subdivision(PlaceRecord): + confidence: int + geoname_id: int + iso_code: Text + names: _Names + +class Subdivisions(Tuple[Subdivision]): + def __new__(cls, locales: _Locales, *subdivisions: Subdivision) -> Subdivisions: ... + def __init__(self, locales: _Locales, *subdivisions: Subdivision) -> None: ... + @property + def most_specific(self) -> Subdivision: ... + +class Traits(Record): + autonomous_system_number: int + autonomous_system_organization: Text + connection_type: Text + domain: Text + ip_address: Text + is_anonymous: bool + is_anonymous_proxy: bool + is_anonymous_vpn: bool + is_hosting_provider: bool + is_legitimate_proxy: bool + is_public_proxy: bool + is_satellite_provider: bool + is_tor_exit_node: bool + isp: Text + organization: Text + user_type: Text + def __init__(self, **kwargs: Any) -> None: ... diff --git a/third_party/2and3/google/protobuf/any_pb2.pyi b/third_party/2and3/google/protobuf/any_pb2.pyi index c2a7295a9725..4b8680728250 100644 --- a/third_party/2and3/google/protobuf/any_pb2.pyi +++ b/third_party/2and3/google/protobuf/any_pb2.pyi @@ -1,22 +1,9 @@ -from google.protobuf.message import ( - Message, -) +from google.protobuf.message import Message from google.protobuf.internal import well_known_types -from typing import ( - Optional, - Text, -) - +from typing import Optional, Text class Any(Message, well_known_types.Any_): type_url: Text value: bytes - - def __init__(self, - type_url: Optional[Text] = ..., - value: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Any: ... + def __init__(self, type_url: Optional[Text] = ..., value: Optional[bytes] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/any_test_pb2.pyi b/third_party/2and3/google/protobuf/any_test_pb2.pyi index d352badb3418..67985f5e25c6 100644 --- a/third_party/2and3/google/protobuf/any_test_pb2.pyi +++ b/third_party/2and3/google/protobuf/any_test_pb2.pyi @@ -1,32 +1,14 @@ -from google.protobuf.any_pb2 import ( - Any, -) -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from typing import ( - Iterable, - Optional, -) - +from google.protobuf.any_pb2 import Any +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer +from google.protobuf.message import Message +from typing import Iterable, Optional class TestAny(Message): int32_value: int - @property def any_value(self) -> Any: ... - @property def repeated_any_value(self) -> RepeatedCompositeFieldContainer[Any]: ... - - def __init__(self, - int32_value: Optional[int] = ..., - any_value: Optional[Any] = ..., - repeated_any_value: Optional[Iterable[Any]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAny: ... + def __init__( + self, int32_value: Optional[int] = ..., any_value: Optional[Any] = ..., repeated_any_value: Optional[Iterable[Any]] = ... + ) -> None: ... diff --git a/third_party/2and3/google/protobuf/api_pb2.pyi b/third_party/2and3/google/protobuf/api_pb2.pyi index 36468780e0e5..f1f76548ad30 100644 --- a/third_party/2and3/google/protobuf/api_pb2.pyi +++ b/third_party/2and3/google/protobuf/api_pb2.pyi @@ -1,53 +1,31 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.source_context_pb2 import ( - SourceContext, -) -from google.protobuf.type_pb2 import ( - Option, - Syntax, -) -from typing import ( - Iterable, - Optional, - Text, -) - +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer +from google.protobuf.message import Message +from google.protobuf.source_context_pb2 import SourceContext +from google.protobuf.type_pb2 import Option, Syntax +from typing import Iterable, Optional, Text class Api(Message): name: Text version: Text syntax: Syntax - @property def methods(self) -> RepeatedCompositeFieldContainer[Method]: ... - @property def options(self) -> RepeatedCompositeFieldContainer[Option]: ... - @property def source_context(self) -> SourceContext: ... - @property def mixins(self) -> RepeatedCompositeFieldContainer[Mixin]: ... - - def __init__(self, - name: Optional[Text] = ..., - methods: Optional[Iterable[Method]] = ..., - options: Optional[Iterable[Option]] = ..., - version: Optional[Text] = ..., - source_context: Optional[SourceContext] = ..., - mixins: Optional[Iterable[Mixin]] = ..., - syntax: Optional[Syntax] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Api: ... - + def __init__( + self, + name: Optional[Text] = ..., + methods: Optional[Iterable[Method]] = ..., + options: Optional[Iterable[Option]] = ..., + version: Optional[Text] = ..., + source_context: Optional[SourceContext] = ..., + mixins: Optional[Iterable[Mixin]] = ..., + syntax: Optional[Syntax] = ..., + ) -> None: ... class Method(Message): name: Text @@ -56,32 +34,20 @@ class Method(Message): response_type_url: Text response_streaming: bool syntax: Syntax - @property def options(self) -> RepeatedCompositeFieldContainer[Option]: ... - - def __init__(self, - name: Optional[Text] = ..., - request_type_url: Optional[Text] = ..., - request_streaming: Optional[bool] = ..., - response_type_url: Optional[Text] = ..., - response_streaming: Optional[bool] = ..., - options: Optional[Iterable[Option]] = ..., - syntax: Optional[Syntax] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Method: ... - + def __init__( + self, + name: Optional[Text] = ..., + request_type_url: Optional[Text] = ..., + request_streaming: Optional[bool] = ..., + response_type_url: Optional[Text] = ..., + response_streaming: Optional[bool] = ..., + options: Optional[Iterable[Option]] = ..., + syntax: Optional[Syntax] = ..., + ) -> None: ... class Mixin(Message): name: Text root: Text - - def __init__(self, - name: Optional[Text] = ..., - root: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Mixin: ... + def __init__(self, name: Optional[Text] = ..., root: Optional[Text] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi b/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi index d1037fa3a483..7ed1a665d244 100644 --- a/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi +++ b/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi @@ -1,82 +1,41 @@ -from google.protobuf.descriptor_pb2 import ( - FileDescriptorProto, -) -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from typing import ( - Iterable, - Optional, - Text, -) - +from google.protobuf.descriptor_pb2 import FileDescriptorProto +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from typing import Iterable, Optional, Text class Version(Message): major: int minor: int patch: int suffix: Text - - def __init__(self, - major: Optional[int] = ..., - minor: Optional[int] = ..., - patch: Optional[int] = ..., - suffix: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Version: ... - + def __init__( + self, major: Optional[int] = ..., minor: Optional[int] = ..., patch: Optional[int] = ..., suffix: Optional[Text] = ... + ) -> None: ... class CodeGeneratorRequest(Message): file_to_generate: RepeatedScalarFieldContainer[Text] parameter: Text - @property def proto_file(self) -> RepeatedCompositeFieldContainer[FileDescriptorProto]: ... - @property def compiler_version(self) -> Version: ... - - def __init__(self, - file_to_generate: Optional[Iterable[Text]] = ..., - parameter: Optional[Text] = ..., - proto_file: Optional[Iterable[FileDescriptorProto]] = ..., - compiler_version: Optional[Version] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CodeGeneratorRequest: ... - + def __init__( + self, + file_to_generate: Optional[Iterable[Text]] = ..., + parameter: Optional[Text] = ..., + proto_file: Optional[Iterable[FileDescriptorProto]] = ..., + compiler_version: Optional[Version] = ..., + ) -> None: ... class CodeGeneratorResponse(Message): - class File(Message): name: Text insertion_point: Text content: Text - - def __init__(self, - name: Optional[Text] = ..., - insertion_point: Optional[Text] = ..., - content: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CodeGeneratorResponse.File: ... + def __init__( + self, name: Optional[Text] = ..., insertion_point: Optional[Text] = ..., content: Optional[Text] = ... + ) -> None: ... error: Text - @property def file(self) -> RepeatedCompositeFieldContainer[CodeGeneratorResponse.File]: ... - - def __init__(self, - error: Optional[Text] = ..., - file: Optional[Iterable[CodeGeneratorResponse.File]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CodeGeneratorResponse: ... + def __init__(self, error: Optional[Text] = ..., file: Optional[Iterable[CodeGeneratorResponse.File]] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/descriptor.pyi b/third_party/2and3/google/protobuf/descriptor.pyi index 44352c6a7cce..39d08aba3453 100644 --- a/third_party/2and3/google/protobuf/descriptor.pyi +++ b/third_party/2and3/google/protobuf/descriptor.pyi @@ -28,12 +28,32 @@ class _NestedDescriptorBase(DescriptorBase): full_name: Any file: Any containing_type: Any - def __init__(self, options, options_class_name, name, full_name, file, containing_type, serialized_start=..., serialized_end=...) -> None: ... + def __init__( + self, options, options_class_name, name, full_name, file, containing_type, serialized_start=..., serialized_end=... + ) -> None: ... def GetTopLevelContainingType(self): ... def CopyToProto(self, proto): ... class Descriptor(_NestedDescriptorBase): - def __new__(cls, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=..., is_extendable=..., extension_ranges=..., oneofs=..., file=..., serialized_start=..., serialized_end=..., syntax=...): ... + def __new__( + cls, + name, + full_name, + filename, + containing_type, + fields, + nested_types, + enum_types, + extensions, + options=..., + is_extendable=..., + extension_ranges=..., + oneofs=..., + file=..., + serialized_start=..., + serialized_end=..., + syntax=..., + ): ... fields: Any fields_by_number: Any fields_by_name: Any @@ -49,7 +69,25 @@ class Descriptor(_NestedDescriptorBase): oneofs: Any oneofs_by_name: Any syntax: Any - def __init__(self, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=..., is_extendable=..., extension_ranges=..., oneofs=..., file=..., serialized_start=..., serialized_end=..., syntax=...) -> None: ... + def __init__( + self, + name, + full_name, + filename, + containing_type, + fields, + nested_types, + enum_types, + extensions, + options=..., + is_extendable=..., + extension_ranges=..., + oneofs=..., + file=..., + serialized_start=..., + serialized_end=..., + syntax=..., + ) -> None: ... def EnumValueName(self, enum, value): ... def CopyToProto(self, proto): ... def GetOptions(self) -> MessageOptions: ... @@ -92,7 +130,26 @@ class FieldDescriptor(DescriptorBase): MAX_FIELD_NUMBER: Any FIRST_RESERVED_FIELD_NUMBER: Any LAST_RESERVED_FIELD_NUMBER: Any - def __new__(cls, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=..., file=..., has_default_value=..., containing_oneof=...): ... + def __new__( + cls, + name, + full_name, + index, + number, + type, + cpp_type, + label, + default_value, + message_type, + enum_type, + containing_type, + is_extension, + extension_scope, + options=..., + file=..., + has_default_value=..., + containing_oneof=..., + ): ... name: Any full_name: Any index: Any @@ -108,17 +165,58 @@ class FieldDescriptor(DescriptorBase): is_extension: Any extension_scope: Any containing_oneof: Any - def __init__(self, name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=..., file=..., has_default_value=..., containing_oneof=...) -> None: ... + def __init__( + self, + name, + full_name, + index, + number, + type, + cpp_type, + label, + default_value, + message_type, + enum_type, + containing_type, + is_extension, + extension_scope, + options=..., + file=..., + has_default_value=..., + containing_oneof=..., + ) -> None: ... @staticmethod def ProtoTypeToCppProtoType(proto_type): ... def GetOptions(self) -> FieldOptions: ... class EnumDescriptor(_NestedDescriptorBase): - def __new__(cls, name, full_name, filename, values, containing_type=..., options=..., file=..., serialized_start=..., serialized_end=...): ... + def __new__( + cls, + name, + full_name, + filename, + values, + containing_type=..., + options=..., + file=..., + serialized_start=..., + serialized_end=..., + ): ... values: Any values_by_name: Any values_by_number: Any - def __init__(self, name, full_name, filename, values, containing_type=..., options=..., file=..., serialized_start=..., serialized_end=...) -> None: ... + def __init__( + self, + name, + full_name, + filename, + values, + containing_type=..., + options=..., + file=..., + serialized_start=..., + serialized_end=..., + ) -> None: ... def CopyToProto(self, proto): ... def GetOptions(self) -> EnumOptions: ... @@ -145,7 +243,9 @@ class ServiceDescriptor(_NestedDescriptorBase): index: Any methods: Any methods_by_name: Any - def __init__(self, name, full_name, index, methods, options=..., file=..., serialized_start=..., serialized_end=...) -> None: ... + def __init__( + self, name, full_name, index, methods, options=..., file=..., serialized_start=..., serialized_end=... + ) -> None: ... def FindMethodByName(self, name): ... def CopyToProto(self, proto): ... def GetOptions(self) -> ServiceOptions: ... @@ -161,7 +261,9 @@ class MethodDescriptor(DescriptorBase): def GetOptions(self) -> MethodOptions: ... class FileDescriptor(DescriptorBase): - def __new__(cls, name, package, options=..., serialized_pb=..., dependencies=..., public_dependencies=..., syntax=..., pool=...): ... + def __new__( + cls, name, package, options=..., serialized_pb=..., dependencies=..., public_dependencies=..., syntax=..., pool=... + ): ... _options: Any pool: Any message_types_by_name: Any @@ -174,7 +276,9 @@ class FileDescriptor(DescriptorBase): services_by_name: Any dependencies: Any public_dependencies: Any - def __init__(self, name, package, options=..., serialized_pb=..., dependencies=..., public_dependencies=..., syntax=..., pool=...) -> None: ... + def __init__( + self, name, package, options=..., serialized_pb=..., dependencies=..., public_dependencies=..., syntax=..., pool=... + ) -> None: ... def CopyToProto(self, proto): ... def GetOptions(self) -> FileOptions: ... diff --git a/third_party/2and3/google/protobuf/descriptor_pb2.pyi b/third_party/2and3/google/protobuf/descriptor_pb2.pyi index d0fbcdc2f865..4588c1bc45e8 100644 --- a/third_party/2and3/google/protobuf/descriptor_pb2.pyi +++ b/third_party/2and3/google/protobuf/descriptor_pb2.pyi @@ -1,32 +1,11 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from typing import ( - Iterable, - List, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from typing import Iterable, List, Optional, Text, Tuple, cast class FileDescriptorSet(Message): - @property def file(self) -> RepeatedCompositeFieldContainer[FileDescriptorProto]: ... - - def __init__(self, - file: Optional[Iterable[FileDescriptorProto]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FileDescriptorSet: ... - + def __init__(self, file: Optional[Iterable[FileDescriptorProto]] = ...) -> None: ... class FileDescriptorProto(Message): name: Text @@ -35,158 +14,94 @@ class FileDescriptorProto(Message): public_dependency: RepeatedScalarFieldContainer[int] weak_dependency: RepeatedScalarFieldContainer[int] syntax: Text - @property - def message_type( - self) -> RepeatedCompositeFieldContainer[DescriptorProto]: ... - + def message_type(self) -> RepeatedCompositeFieldContainer[DescriptorProto]: ... @property - def enum_type( - self) -> RepeatedCompositeFieldContainer[EnumDescriptorProto]: ... - + def enum_type(self) -> RepeatedCompositeFieldContainer[EnumDescriptorProto]: ... @property - def service( - self) -> RepeatedCompositeFieldContainer[ServiceDescriptorProto]: ... - + def service(self) -> RepeatedCompositeFieldContainer[ServiceDescriptorProto]: ... @property - def extension( - self) -> RepeatedCompositeFieldContainer[FieldDescriptorProto]: ... - + def extension(self) -> RepeatedCompositeFieldContainer[FieldDescriptorProto]: ... @property def options(self) -> FileOptions: ... - @property def source_code_info(self) -> SourceCodeInfo: ... - - def __init__(self, - name: Optional[Text] = ..., - package: Optional[Text] = ..., - dependency: Optional[Iterable[Text]] = ..., - public_dependency: Optional[Iterable[int]] = ..., - weak_dependency: Optional[Iterable[int]] = ..., - message_type: Optional[Iterable[DescriptorProto]] = ..., - enum_type: Optional[Iterable[EnumDescriptorProto]] = ..., - service: Optional[Iterable[ServiceDescriptorProto]] = ..., - extension: Optional[Iterable[FieldDescriptorProto]] = ..., - options: Optional[FileOptions] = ..., - source_code_info: Optional[SourceCodeInfo] = ..., - syntax: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FileDescriptorProto: ... - + def __init__( + self, + name: Optional[Text] = ..., + package: Optional[Text] = ..., + dependency: Optional[Iterable[Text]] = ..., + public_dependency: Optional[Iterable[int]] = ..., + weak_dependency: Optional[Iterable[int]] = ..., + message_type: Optional[Iterable[DescriptorProto]] = ..., + enum_type: Optional[Iterable[EnumDescriptorProto]] = ..., + service: Optional[Iterable[ServiceDescriptorProto]] = ..., + extension: Optional[Iterable[FieldDescriptorProto]] = ..., + options: Optional[FileOptions] = ..., + source_code_info: Optional[SourceCodeInfo] = ..., + syntax: Optional[Text] = ..., + ) -> None: ... class DescriptorProto(Message): - class ExtensionRange(Message): start: int end: int - @property def options(self) -> ExtensionRangeOptions: ... - - def __init__(self, - start: Optional[int] = ..., - end: Optional[int] = ..., - options: Optional[ExtensionRangeOptions] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> DescriptorProto.ExtensionRange: ... - + def __init__( + self, start: Optional[int] = ..., end: Optional[int] = ..., options: Optional[ExtensionRangeOptions] = ... + ) -> None: ... class ReservedRange(Message): start: int end: int - - def __init__(self, - start: Optional[int] = ..., - end: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> DescriptorProto.ReservedRange: ... + def __init__(self, start: Optional[int] = ..., end: Optional[int] = ...) -> None: ... name: Text reserved_name: RepeatedScalarFieldContainer[Text] - @property - def field( - self) -> RepeatedCompositeFieldContainer[FieldDescriptorProto]: ... - + def field(self) -> RepeatedCompositeFieldContainer[FieldDescriptorProto]: ... @property - def extension( - self) -> RepeatedCompositeFieldContainer[FieldDescriptorProto]: ... - + def extension(self) -> RepeatedCompositeFieldContainer[FieldDescriptorProto]: ... @property - def nested_type( - self) -> RepeatedCompositeFieldContainer[DescriptorProto]: ... - + def nested_type(self) -> RepeatedCompositeFieldContainer[DescriptorProto]: ... @property - def enum_type( - self) -> RepeatedCompositeFieldContainer[EnumDescriptorProto]: ... - + def enum_type(self) -> RepeatedCompositeFieldContainer[EnumDescriptorProto]: ... @property - def extension_range( - self) -> RepeatedCompositeFieldContainer[DescriptorProto.ExtensionRange]: ... - + def extension_range(self) -> RepeatedCompositeFieldContainer[DescriptorProto.ExtensionRange]: ... @property - def oneof_decl( - self) -> RepeatedCompositeFieldContainer[OneofDescriptorProto]: ... - + def oneof_decl(self) -> RepeatedCompositeFieldContainer[OneofDescriptorProto]: ... @property def options(self) -> MessageOptions: ... - @property - def reserved_range( - self) -> RepeatedCompositeFieldContainer[DescriptorProto.ReservedRange]: ... - - def __init__(self, - name: Optional[Text] = ..., - field: Optional[Iterable[FieldDescriptorProto]] = ..., - extension: Optional[Iterable[FieldDescriptorProto]] = ..., - nested_type: Optional[Iterable[DescriptorProto]] = ..., - enum_type: Optional[Iterable[EnumDescriptorProto]] = ..., - extension_range: Optional[Iterable[DescriptorProto.ExtensionRange]] = ..., - oneof_decl: Optional[Iterable[OneofDescriptorProto]] = ..., - options: Optional[MessageOptions] = ..., - reserved_range: Optional[Iterable[DescriptorProto.ReservedRange]] = ..., - reserved_name: Optional[Iterable[Text]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> DescriptorProto: ... - + def reserved_range(self) -> RepeatedCompositeFieldContainer[DescriptorProto.ReservedRange]: ... + def __init__( + self, + name: Optional[Text] = ..., + field: Optional[Iterable[FieldDescriptorProto]] = ..., + extension: Optional[Iterable[FieldDescriptorProto]] = ..., + nested_type: Optional[Iterable[DescriptorProto]] = ..., + enum_type: Optional[Iterable[EnumDescriptorProto]] = ..., + extension_range: Optional[Iterable[DescriptorProto.ExtensionRange]] = ..., + oneof_decl: Optional[Iterable[OneofDescriptorProto]] = ..., + options: Optional[MessageOptions] = ..., + reserved_range: Optional[Iterable[DescriptorProto.ReservedRange]] = ..., + reserved_name: Optional[Iterable[Text]] = ..., + ) -> None: ... class ExtensionRangeOptions(Message): - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ExtensionRangeOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__(self, uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ...) -> None: ... class FieldDescriptorProto(Message): - class Type(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> FieldDescriptorProto.Type: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[FieldDescriptorProto.Type]: ... - @classmethod def items(cls) -> List[Tuple[bytes, FieldDescriptorProto.Type]]: ... TYPE_DOUBLE: FieldDescriptorProto.Type @@ -207,21 +122,15 @@ class FieldDescriptorProto(Message): TYPE_SFIXED64: FieldDescriptorProto.Type TYPE_SINT32: FieldDescriptorProto.Type TYPE_SINT64: FieldDescriptorProto.Type - class Label(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> FieldDescriptorProto.Label: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[FieldDescriptorProto.Label]: ... - @classmethod def items(cls) -> List[Tuple[bytes, FieldDescriptorProto.Label]]: ... LABEL_OPTIONAL: FieldDescriptorProto.Label @@ -236,118 +145,71 @@ class FieldDescriptorProto(Message): default_value: Text oneof_index: int json_name: Text - @property def options(self) -> FieldOptions: ... - - def __init__(self, - name: Optional[Text] = ..., - number: Optional[int] = ..., - label: Optional[FieldDescriptorProto.Label] = ..., - type: Optional[FieldDescriptorProto.Type] = ..., - type_name: Optional[Text] = ..., - extendee: Optional[Text] = ..., - default_value: Optional[Text] = ..., - oneof_index: Optional[int] = ..., - json_name: Optional[Text] = ..., - options: Optional[FieldOptions] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FieldDescriptorProto: ... - + def __init__( + self, + name: Optional[Text] = ..., + number: Optional[int] = ..., + label: Optional[FieldDescriptorProto.Label] = ..., + type: Optional[FieldDescriptorProto.Type] = ..., + type_name: Optional[Text] = ..., + extendee: Optional[Text] = ..., + default_value: Optional[Text] = ..., + oneof_index: Optional[int] = ..., + json_name: Optional[Text] = ..., + options: Optional[FieldOptions] = ..., + ) -> None: ... class OneofDescriptorProto(Message): name: Text - @property def options(self) -> OneofOptions: ... - - def __init__(self, - name: Optional[Text] = ..., - options: Optional[OneofOptions] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> OneofDescriptorProto: ... - + def __init__(self, name: Optional[Text] = ..., options: Optional[OneofOptions] = ...) -> None: ... class EnumDescriptorProto(Message): - class EnumReservedRange(Message): start: int end: int - - def __init__(self, - start: Optional[int] = ..., - end: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> EnumDescriptorProto.EnumReservedRange: ... + def __init__(self, start: Optional[int] = ..., end: Optional[int] = ...) -> None: ... name: Text reserved_name: RepeatedScalarFieldContainer[Text] - @property - def value( - self) -> RepeatedCompositeFieldContainer[EnumValueDescriptorProto]: ... - + def value(self) -> RepeatedCompositeFieldContainer[EnumValueDescriptorProto]: ... @property def options(self) -> EnumOptions: ... - @property - def reserved_range( - self) -> RepeatedCompositeFieldContainer[EnumDescriptorProto.EnumReservedRange]: ... - - def __init__(self, - name: Optional[Text] = ..., - value: Optional[Iterable[EnumValueDescriptorProto]] = ..., - options: Optional[EnumOptions] = ..., - reserved_range: Optional[Iterable[EnumDescriptorProto.EnumReservedRange]] = ..., - reserved_name: Optional[Iterable[Text]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> EnumDescriptorProto: ... - + def reserved_range(self) -> RepeatedCompositeFieldContainer[EnumDescriptorProto.EnumReservedRange]: ... + def __init__( + self, + name: Optional[Text] = ..., + value: Optional[Iterable[EnumValueDescriptorProto]] = ..., + options: Optional[EnumOptions] = ..., + reserved_range: Optional[Iterable[EnumDescriptorProto.EnumReservedRange]] = ..., + reserved_name: Optional[Iterable[Text]] = ..., + ) -> None: ... class EnumValueDescriptorProto(Message): name: Text number: int - @property def options(self) -> EnumValueOptions: ... - - def __init__(self, - name: Optional[Text] = ..., - number: Optional[int] = ..., - options: Optional[EnumValueOptions] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> EnumValueDescriptorProto: ... - + def __init__( + self, name: Optional[Text] = ..., number: Optional[int] = ..., options: Optional[EnumValueOptions] = ... + ) -> None: ... class ServiceDescriptorProto(Message): name: Text - @property - def method( - self) -> RepeatedCompositeFieldContainer[MethodDescriptorProto]: ... - + def method(self) -> RepeatedCompositeFieldContainer[MethodDescriptorProto]: ... @property def options(self) -> ServiceOptions: ... - - def __init__(self, - name: Optional[Text] = ..., - method: Optional[Iterable[MethodDescriptorProto]] = ..., - options: Optional[ServiceOptions] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ServiceDescriptorProto: ... - + def __init__( + self, + name: Optional[Text] = ..., + method: Optional[Iterable[MethodDescriptorProto]] = ..., + options: Optional[ServiceOptions] = ..., + ) -> None: ... class MethodDescriptorProto(Message): name: Text @@ -355,39 +217,28 @@ class MethodDescriptorProto(Message): output_type: Text client_streaming: bool server_streaming: bool - @property def options(self) -> MethodOptions: ... - - def __init__(self, - name: Optional[Text] = ..., - input_type: Optional[Text] = ..., - output_type: Optional[Text] = ..., - options: Optional[MethodOptions] = ..., - client_streaming: Optional[bool] = ..., - server_streaming: Optional[bool] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MethodDescriptorProto: ... - + def __init__( + self, + name: Optional[Text] = ..., + input_type: Optional[Text] = ..., + output_type: Optional[Text] = ..., + options: Optional[MethodOptions] = ..., + client_streaming: Optional[bool] = ..., + server_streaming: Optional[bool] = ..., + ) -> None: ... class FileOptions(Message): - class OptimizeMode(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> FileOptions.OptimizeMode: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[FileOptions.OptimizeMode]: ... - @classmethod def items(cls) -> List[Tuple[bytes, FileOptions.OptimizeMode]]: ... SPEED: FileOptions.OptimizeMode @@ -411,95 +262,71 @@ class FileOptions(Message): swift_prefix: Text php_class_prefix: Text php_namespace: Text - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - java_package: Optional[Text] = ..., - java_outer_classname: Optional[Text] = ..., - java_multiple_files: Optional[bool] = ..., - java_generate_equals_and_hash: Optional[bool] = ..., - java_string_check_utf8: Optional[bool] = ..., - optimize_for: Optional[FileOptions.OptimizeMode] = ..., - go_package: Optional[Text] = ..., - cc_generic_services: Optional[bool] = ..., - java_generic_services: Optional[bool] = ..., - py_generic_services: Optional[bool] = ..., - php_generic_services: Optional[bool] = ..., - deprecated: Optional[bool] = ..., - cc_enable_arenas: Optional[bool] = ..., - objc_class_prefix: Optional[Text] = ..., - csharp_namespace: Optional[Text] = ..., - swift_prefix: Optional[Text] = ..., - php_class_prefix: Optional[Text] = ..., - php_namespace: Optional[Text] = ..., - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FileOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__( + self, + java_package: Optional[Text] = ..., + java_outer_classname: Optional[Text] = ..., + java_multiple_files: Optional[bool] = ..., + java_generate_equals_and_hash: Optional[bool] = ..., + java_string_check_utf8: Optional[bool] = ..., + optimize_for: Optional[FileOptions.OptimizeMode] = ..., + go_package: Optional[Text] = ..., + cc_generic_services: Optional[bool] = ..., + java_generic_services: Optional[bool] = ..., + py_generic_services: Optional[bool] = ..., + php_generic_services: Optional[bool] = ..., + deprecated: Optional[bool] = ..., + cc_enable_arenas: Optional[bool] = ..., + objc_class_prefix: Optional[Text] = ..., + csharp_namespace: Optional[Text] = ..., + swift_prefix: Optional[Text] = ..., + php_class_prefix: Optional[Text] = ..., + php_namespace: Optional[Text] = ..., + uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., + ) -> None: ... class MessageOptions(Message): message_set_wire_format: bool no_standard_descriptor_accessor: bool deprecated: bool map_entry: bool - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - message_set_wire_format: Optional[bool] = ..., - no_standard_descriptor_accessor: Optional[bool] = ..., - deprecated: Optional[bool] = ..., - map_entry: Optional[bool] = ..., - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MessageOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__( + self, + message_set_wire_format: Optional[bool] = ..., + no_standard_descriptor_accessor: Optional[bool] = ..., + deprecated: Optional[bool] = ..., + map_entry: Optional[bool] = ..., + uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., + ) -> None: ... class FieldOptions(Message): - class CType(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> FieldOptions.CType: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[FieldOptions.CType]: ... - @classmethod def items(cls) -> List[Tuple[bytes, FieldOptions.CType]]: ... STRING: FieldOptions.CType CORD: FieldOptions.CType STRING_PIECE: FieldOptions.CType - class JSType(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> FieldOptions.JSType: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[FieldOptions.JSType]: ... - @classmethod def items(cls) -> List[Tuple[bytes, FieldOptions.JSType]]: ... JS_NORMAL: FieldOptions.JSType @@ -511,105 +338,62 @@ class FieldOptions(Message): lazy: bool deprecated: bool weak: bool - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - ctype: Optional[FieldOptions.CType] = ..., - packed: Optional[bool] = ..., - jstype: Optional[FieldOptions.JSType] = ..., - lazy: Optional[bool] = ..., - deprecated: Optional[bool] = ..., - weak: Optional[bool] = ..., - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FieldOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__( + self, + ctype: Optional[FieldOptions.CType] = ..., + packed: Optional[bool] = ..., + jstype: Optional[FieldOptions.JSType] = ..., + lazy: Optional[bool] = ..., + deprecated: Optional[bool] = ..., + weak: Optional[bool] = ..., + uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., + ) -> None: ... class OneofOptions(Message): - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> OneofOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__(self, uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ...) -> None: ... class EnumOptions(Message): allow_alias: bool deprecated: bool - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - allow_alias: Optional[bool] = ..., - deprecated: Optional[bool] = ..., - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> EnumOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__( + self, + allow_alias: Optional[bool] = ..., + deprecated: Optional[bool] = ..., + uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., + ) -> None: ... class EnumValueOptions(Message): deprecated: bool - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - deprecated: Optional[bool] = ..., - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> EnumValueOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__( + self, deprecated: Optional[bool] = ..., uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ... + ) -> None: ... class ServiceOptions(Message): deprecated: bool - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - deprecated: Optional[bool] = ..., - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ServiceOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__( + self, deprecated: Optional[bool] = ..., uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ... + ) -> None: ... class MethodOptions(Message): - class IdempotencyLevel(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> MethodOptions.IdempotencyLevel: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[MethodOptions.IdempotencyLevel]: ... - @classmethod def items(cls) -> List[Tuple[bytes, MethodOptions.IdempotencyLevel]]: ... IDEMPOTENCY_UNKNOWN: MethodOptions.IdempotencyLevel @@ -617,116 +401,71 @@ class MethodOptions(Message): IDEMPOTENT: MethodOptions.IdempotencyLevel deprecated: bool idempotency_level: MethodOptions.IdempotencyLevel - @property - def uninterpreted_option( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... - - def __init__(self, - deprecated: Optional[bool] = ..., - idempotency_level: Optional[MethodOptions.IdempotencyLevel] = ..., - uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MethodOptions: ... - + def uninterpreted_option(self) -> RepeatedCompositeFieldContainer[UninterpretedOption]: ... + def __init__( + self, + deprecated: Optional[bool] = ..., + idempotency_level: Optional[MethodOptions.IdempotencyLevel] = ..., + uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., + ) -> None: ... class UninterpretedOption(Message): - class NamePart(Message): name_part: Text is_extension: bool - - def __init__(self, - name_part: Text, - is_extension: bool, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> UninterpretedOption.NamePart: ... + def __init__(self, name_part: Text, is_extension: bool) -> None: ... identifier_value: Text positive_int_value: int negative_int_value: int double_value: float string_value: bytes aggregate_value: Text - @property - def name( - self) -> RepeatedCompositeFieldContainer[UninterpretedOption.NamePart]: ... - - def __init__(self, - name: Optional[Iterable[UninterpretedOption.NamePart]] = ..., - identifier_value: Optional[Text] = ..., - positive_int_value: Optional[int] = ..., - negative_int_value: Optional[int] = ..., - double_value: Optional[float] = ..., - string_value: Optional[bytes] = ..., - aggregate_value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> UninterpretedOption: ... - + def name(self) -> RepeatedCompositeFieldContainer[UninterpretedOption.NamePart]: ... + def __init__( + self, + name: Optional[Iterable[UninterpretedOption.NamePart]] = ..., + identifier_value: Optional[Text] = ..., + positive_int_value: Optional[int] = ..., + negative_int_value: Optional[int] = ..., + double_value: Optional[float] = ..., + string_value: Optional[bytes] = ..., + aggregate_value: Optional[Text] = ..., + ) -> None: ... class SourceCodeInfo(Message): - class Location(Message): path: RepeatedScalarFieldContainer[int] span: RepeatedScalarFieldContainer[int] leading_comments: Text trailing_comments: Text leading_detached_comments: RepeatedScalarFieldContainer[Text] - - def __init__(self, - path: Optional[Iterable[int]] = ..., - span: Optional[Iterable[int]] = ..., - leading_comments: Optional[Text] = ..., - trailing_comments: Optional[Text] = ..., - leading_detached_comments: Optional[Iterable[Text]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> SourceCodeInfo.Location: ... - - @property - def location( - self) -> RepeatedCompositeFieldContainer[SourceCodeInfo.Location]: ... - - def __init__(self, - location: Optional[Iterable[SourceCodeInfo.Location]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> SourceCodeInfo: ... - + def __init__( + self, + path: Optional[Iterable[int]] = ..., + span: Optional[Iterable[int]] = ..., + leading_comments: Optional[Text] = ..., + trailing_comments: Optional[Text] = ..., + leading_detached_comments: Optional[Iterable[Text]] = ..., + ) -> None: ... + @property + def location(self) -> RepeatedCompositeFieldContainer[SourceCodeInfo.Location]: ... + def __init__(self, location: Optional[Iterable[SourceCodeInfo.Location]] = ...) -> None: ... class GeneratedCodeInfo(Message): - class Annotation(Message): path: RepeatedScalarFieldContainer[int] source_file: Text begin: int end: int - - def __init__(self, - path: Optional[Iterable[int]] = ..., - source_file: Optional[Text] = ..., - begin: Optional[int] = ..., - end: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> GeneratedCodeInfo.Annotation: ... - - @property - def annotation( - self) -> RepeatedCompositeFieldContainer[GeneratedCodeInfo.Annotation]: ... - - def __init__(self, - annotation: Optional[Iterable[GeneratedCodeInfo.Annotation]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> GeneratedCodeInfo: ... + def __init__( + self, + path: Optional[Iterable[int]] = ..., + source_file: Optional[Text] = ..., + begin: Optional[int] = ..., + end: Optional[int] = ..., + ) -> None: ... + @property + def annotation(self) -> RepeatedCompositeFieldContainer[GeneratedCodeInfo.Annotation]: ... + def __init__(self, annotation: Optional[Iterable[GeneratedCodeInfo.Annotation]] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/duration_pb2.pyi b/third_party/2and3/google/protobuf/duration_pb2.pyi index 378c2e57ce01..a7e4bf3caf1e 100644 --- a/third_party/2and3/google/protobuf/duration_pb2.pyi +++ b/third_party/2and3/google/protobuf/duration_pb2.pyi @@ -1,21 +1,9 @@ -from google.protobuf.message import ( - Message, -) +from google.protobuf.message import Message from google.protobuf.internal import well_known_types -from typing import ( - Optional, -) - +from typing import Optional class Duration(Message, well_known_types.Duration): seconds: int nanos: int - - def __init__(self, - seconds: Optional[int] = ..., - nanos: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Duration: ... + def __init__(self, seconds: Optional[int] = ..., nanos: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/empty_pb2.pyi b/third_party/2and3/google/protobuf/empty_pb2.pyi index 295ebfa938be..7046e6432bce 100644 --- a/third_party/2and3/google/protobuf/empty_pb2.pyi +++ b/third_party/2and3/google/protobuf/empty_pb2.pyi @@ -1,12 +1,4 @@ -from google.protobuf.message import ( - Message, -) - +from google.protobuf.message import Message class Empty(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Empty: ... + def __init__(self,) -> None: ... diff --git a/third_party/2and3/google/protobuf/field_mask_pb2.pyi b/third_party/2and3/google/protobuf/field_mask_pb2.pyi index 1c96a02bbe1e..1185519653d3 100644 --- a/third_party/2and3/google/protobuf/field_mask_pb2.pyi +++ b/third_party/2and3/google/protobuf/field_mask_pb2.pyi @@ -1,24 +1,9 @@ -from google.protobuf.internal.containers import ( - RepeatedScalarFieldContainer, -) +from google.protobuf.internal.containers import RepeatedScalarFieldContainer from google.protobuf.internal import well_known_types -from google.protobuf.message import ( - Message, -) -from typing import ( - Iterable, - Optional, - Text, -) - +from google.protobuf.message import Message +from typing import Iterable, Optional, Text class FieldMask(Message, well_known_types.FieldMask): paths: RepeatedScalarFieldContainer[Text] - - def __init__(self, - paths: Optional[Iterable[Text]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FieldMask: ... + def __init__(self, paths: Optional[Iterable[Text]] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/internal/containers.pyi b/third_party/2and3/google/protobuf/internal/containers.pyi index 06efb544d560..fc97c7330ce3 100644 --- a/third_party/2and3/google/protobuf/internal/containers.pyi +++ b/third_party/2and3/google/protobuf/internal/containers.pyi @@ -1,12 +1,10 @@ from google.protobuf.descriptor import Descriptor from google.protobuf.internal.message_listener import MessageListener from google.protobuf.message import Message -from typing import ( - Sequence, TypeVar, Generic, Any, Iterator, Iterable, - Union, Optional, Callable, overload, List -) +from typing import Sequence, TypeVar, Generic, Any, Iterator, Iterable, Union, Optional, Callable, overload, List + +_T = TypeVar("_T") -_T = TypeVar('_T') class BaseContainer(Sequence[_T]): def __init__(self, message_listener: MessageListener) -> None: ... def __len__(self) -> int: ... diff --git a/third_party/2and3/google/protobuf/internal/enum_type_wrapper.pyi b/third_party/2and3/google/protobuf/internal/enum_type_wrapper.pyi index 61d6ea10c5b6..174002d7a414 100644 --- a/third_party/2and3/google/protobuf/internal/enum_type_wrapper.pyi +++ b/third_party/2and3/google/protobuf/internal/enum_type_wrapper.pyi @@ -6,6 +6,5 @@ class EnumTypeWrapper(object): def Value(self, name: bytes) -> int: ... def keys(self) -> List[bytes]: ... def values(self) -> List[int]: ... - @classmethod def items(cls) -> List[Tuple[bytes, int]]: ... diff --git a/third_party/2and3/google/protobuf/internal/well_known_types.pyi b/third_party/2and3/google/protobuf/internal/well_known_types.pyi index 91a42a33ce25..fc0344f74edc 100644 --- a/third_party/2and3/google/protobuf/internal/well_known_types.pyi +++ b/third_party/2and3/google/protobuf/internal/well_known_types.pyi @@ -55,7 +55,9 @@ class FieldMask: def CanonicalFormFromMask(self, mask: Any) -> None: ... def Union(self, mask1: Any, mask2: Any) -> None: ... def Intersect(self, mask1: Any, mask2: Any) -> None: ... - def MergeMessage(self, source: Any, destination: Any, replace_message_field: bool = ..., replace_repeated_field: bool = ...) -> None: ... + def MergeMessage( + self, source: Any, destination: Any, replace_message_field: bool = ..., replace_repeated_field: bool = ... + ) -> None: ... class _FieldMaskTree: def __init__(self, field_mask: Optional[Any] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/json_format.pyi b/third_party/2and3/google/protobuf/json_format.pyi index e61ccb869fbf..89024438a466 100644 --- a/third_party/2and3/google/protobuf/json_format.pyi +++ b/third_party/2and3/google/protobuf/json_format.pyi @@ -2,12 +2,10 @@ import sys from typing import Any, Dict, Text, TypeVar, Union from google.protobuf.message import Message -_MessageVar = TypeVar('_MessageVar', bound=Message) +_MessageVar = TypeVar("_MessageVar", bound=Message) class Error(Exception): ... - class ParseError(Error): ... - class SerializeToJsonError(Error): ... def MessageToJson( @@ -16,16 +14,13 @@ def MessageToJson( preserving_proto_field_name: bool = ..., indent: int = ..., sort_keys: bool = ..., - use_integers_for_enums: bool = ... + use_integers_for_enums: bool = ..., ) -> str: ... - def MessageToDict( message: Message, including_default_value_fields: bool = ..., preserving_proto_field_name: bool = ..., - use_integers_for_enums: bool = ... + use_integers_for_enums: bool = ..., ) -> Dict[Text, Any]: ... - def Parse(text: Union[bytes, Text], message: _MessageVar, ignore_unknown_fields: bool = ...) -> _MessageVar: ... - def ParseDict(js_dict: Any, message: _MessageVar, ignore_unknown_fields: bool = ...) -> _MessageVar: ... diff --git a/third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi b/third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi index fd12d108a998..71abad99505e 100644 --- a/third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi @@ -1,428 +1,198 @@ -from google.protobuf.message import ( - Message, -) -from google.protobuf.unittest_import_pb2 import ( - ImportEnumForMap, -) -from typing import ( - List, - Mapping, - MutableMapping, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.message import Message +from google.protobuf.unittest_import_pb2 import ImportEnumForMap +from typing import List, Mapping, MutableMapping, Optional, Text, Tuple, cast class Proto2MapEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> Proto2MapEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[Proto2MapEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, Proto2MapEnum]]: ... + PROTO2_MAP_ENUM_FOO: Proto2MapEnum PROTO2_MAP_ENUM_BAR: Proto2MapEnum PROTO2_MAP_ENUM_BAZ: Proto2MapEnum - class Proto2MapEnumPlusExtra(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> Proto2MapEnumPlusExtra: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[Proto2MapEnumPlusExtra]: ... - @classmethod def items(cls) -> List[Tuple[bytes, Proto2MapEnumPlusExtra]]: ... + E_PROTO2_MAP_ENUM_FOO: Proto2MapEnumPlusExtra E_PROTO2_MAP_ENUM_BAR: Proto2MapEnumPlusExtra E_PROTO2_MAP_ENUM_BAZ: Proto2MapEnumPlusExtra E_PROTO2_MAP_ENUM_EXTRA: Proto2MapEnumPlusExtra - class TestEnumMap(Message): - class KnownMapFieldEntry(Message): key: int value: Proto2MapEnum - - def __init__(self, - key: Optional[int] = ..., - value: Optional[Proto2MapEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumMap.KnownMapFieldEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[Proto2MapEnum] = ...) -> None: ... class UnknownMapFieldEntry(Message): key: int value: Proto2MapEnum - - def __init__(self, - key: Optional[int] = ..., - value: Optional[Proto2MapEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumMap.UnknownMapFieldEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[Proto2MapEnum] = ...) -> None: ... @property def known_map_field(self) -> MutableMapping[int, Proto2MapEnum]: ... - @property def unknown_map_field(self) -> MutableMapping[int, Proto2MapEnum]: ... - - def __init__(self, - known_map_field: Optional[Mapping[int, Proto2MapEnum]] = ..., - unknown_map_field: Optional[Mapping[int, Proto2MapEnum]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumMap: ... - + def __init__( + self, + known_map_field: Optional[Mapping[int, Proto2MapEnum]] = ..., + unknown_map_field: Optional[Mapping[int, Proto2MapEnum]] = ..., + ) -> None: ... class TestEnumMapPlusExtra(Message): - class KnownMapFieldEntry(Message): key: int value: Proto2MapEnumPlusExtra - - def __init__(self, - key: Optional[int] = ..., - value: Optional[Proto2MapEnumPlusExtra] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumMapPlusExtra.KnownMapFieldEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[Proto2MapEnumPlusExtra] = ...) -> None: ... class UnknownMapFieldEntry(Message): key: int value: Proto2MapEnumPlusExtra - - def __init__(self, - key: Optional[int] = ..., - value: Optional[Proto2MapEnumPlusExtra] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumMapPlusExtra.UnknownMapFieldEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[Proto2MapEnumPlusExtra] = ...) -> None: ... @property def known_map_field(self) -> MutableMapping[int, Proto2MapEnumPlusExtra]: ... - @property def unknown_map_field(self) -> MutableMapping[int, Proto2MapEnumPlusExtra]: ... - - def __init__(self, - known_map_field: Optional[Mapping[int, Proto2MapEnumPlusExtra]] = ..., - unknown_map_field: Optional[Mapping[int, Proto2MapEnumPlusExtra]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumMapPlusExtra: ... - + def __init__( + self, + known_map_field: Optional[Mapping[int, Proto2MapEnumPlusExtra]] = ..., + unknown_map_field: Optional[Mapping[int, Proto2MapEnumPlusExtra]] = ..., + ) -> None: ... class TestImportEnumMap(Message): - class ImportEnumAmpEntry(Message): key: int value: ImportEnumForMap - - def __init__(self, - key: Optional[int] = ..., - value: Optional[ImportEnumForMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestImportEnumMap.ImportEnumAmpEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[ImportEnumForMap] = ...) -> None: ... @property def import_enum_amp(self) -> MutableMapping[int, ImportEnumForMap]: ... - - def __init__(self, - import_enum_amp: Optional[Mapping[int, ImportEnumForMap]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestImportEnumMap: ... - + def __init__(self, import_enum_amp: Optional[Mapping[int, ImportEnumForMap]] = ...) -> None: ... class TestIntIntMap(Message): - class MEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestIntIntMap.MEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... @property def m(self) -> MutableMapping[int, int]: ... - - def __init__(self, - m: Optional[Mapping[int, int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestIntIntMap: ... - + def __init__(self, m: Optional[Mapping[int, int]] = ...) -> None: ... class TestMaps(Message): - class MInt32Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MInt32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MInt64Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MInt64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MUint32Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MUint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MUint64Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MUint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MSint32Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MSint64Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MFixed32Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MFixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MFixed64Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MFixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MSfixed32Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSfixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MSfixed64Entry(Message): key: int - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSfixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MBoolEntry(Message): key: bool - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MBoolEntry: ... - + def __init__(self, key: Optional[bool] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... class MStringEntry(Message): key: Text - @property def value(self) -> TestIntIntMap: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[TestIntIntMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MStringEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[TestIntIntMap] = ...) -> None: ... @property def m_int32(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_int64(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_uint32(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_uint64(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_sint32(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_sint64(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_fixed32(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_fixed64(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_sfixed32(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_sfixed64(self) -> MutableMapping[int, TestIntIntMap]: ... - @property def m_bool(self) -> MutableMapping[bool, TestIntIntMap]: ... - @property def m_string(self) -> MutableMapping[Text, TestIntIntMap]: ... - - def __init__(self, - m_int32: Optional[Mapping[int, TestIntIntMap]] = ..., - m_int64: Optional[Mapping[int, TestIntIntMap]] = ..., - m_uint32: Optional[Mapping[int, TestIntIntMap]] = ..., - m_uint64: Optional[Mapping[int, TestIntIntMap]] = ..., - m_sint32: Optional[Mapping[int, TestIntIntMap]] = ..., - m_sint64: Optional[Mapping[int, TestIntIntMap]] = ..., - m_fixed32: Optional[Mapping[int, TestIntIntMap]] = ..., - m_fixed64: Optional[Mapping[int, TestIntIntMap]] = ..., - m_sfixed32: Optional[Mapping[int, TestIntIntMap]] = ..., - m_sfixed64: Optional[Mapping[int, TestIntIntMap]] = ..., - m_bool: Optional[Mapping[bool, TestIntIntMap]] = ..., - m_string: Optional[Mapping[Text, TestIntIntMap]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMaps: ... - + def __init__( + self, + m_int32: Optional[Mapping[int, TestIntIntMap]] = ..., + m_int64: Optional[Mapping[int, TestIntIntMap]] = ..., + m_uint32: Optional[Mapping[int, TestIntIntMap]] = ..., + m_uint64: Optional[Mapping[int, TestIntIntMap]] = ..., + m_sint32: Optional[Mapping[int, TestIntIntMap]] = ..., + m_sint64: Optional[Mapping[int, TestIntIntMap]] = ..., + m_fixed32: Optional[Mapping[int, TestIntIntMap]] = ..., + m_fixed64: Optional[Mapping[int, TestIntIntMap]] = ..., + m_sfixed32: Optional[Mapping[int, TestIntIntMap]] = ..., + m_sfixed64: Optional[Mapping[int, TestIntIntMap]] = ..., + m_bool: Optional[Mapping[bool, TestIntIntMap]] = ..., + m_string: Optional[Mapping[Text, TestIntIntMap]] = ..., + ) -> None: ... class TestSubmessageMaps(Message): - @property def m(self) -> TestMaps: ... - - def __init__(self, - m: Optional[TestMaps] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestSubmessageMaps: ... + def __init__(self, m: Optional[TestMaps] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/map_unittest_pb2.pyi b/third_party/2and3/google/protobuf/map_unittest_pb2.pyi index 25058bbde6d4..e802bb761d3f 100644 --- a/third_party/2and3/google/protobuf/map_unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/map_unittest_pb2.pyi @@ -1,882 +1,375 @@ -from google.protobuf.message import ( - Message, -) -from google.protobuf.unittest_no_arena_pb2 import ( - ForeignMessage, -) -from google.protobuf.unittest_pb2 import ( - ForeignMessage as ForeignMessage1, - TestAllTypes, - TestRequired, -) -from typing import ( - List, - Mapping, - MutableMapping, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.message import Message +from google.protobuf.unittest_no_arena_pb2 import ForeignMessage +from google.protobuf.unittest_pb2 import ForeignMessage as ForeignMessage1, TestAllTypes, TestRequired +from typing import List, Mapping, MutableMapping, Optional, Text, Tuple, cast class MapEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> MapEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[MapEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, MapEnum]]: ... - MAP_ENUM_FOO: MapEnum MAP_ENUM_BAR: MapEnum MAP_ENUM_BAZ: MapEnum - class TestMap(Message): - class MapInt32Int32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32Int32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt64Int64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt64Int64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint32Uint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapUint32Uint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint64Uint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapUint64Uint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint32Sint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSint32Sint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint64Sint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSint64Sint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed32Fixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapFixed32Fixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed64Fixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapFixed64Fixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed32Sfixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSfixed32Sfixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed64Sfixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSfixed64Sfixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt32FloatEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32FloatEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapInt32DoubleEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32DoubleEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapBoolBoolEntry(Message): key: bool value: bool - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[bool] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapBoolBoolEntry: ... - + def __init__(self, key: Optional[bool] = ..., value: Optional[bool] = ...) -> None: ... class MapStringStringEntry(Message): key: Text value: Text - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapStringStringEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[Text] = ...) -> None: ... class MapInt32BytesEntry(Message): key: int value: bytes - - def __init__(self, - key: Optional[int] = ..., - value: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32BytesEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[bytes] = ...) -> None: ... class MapInt32EnumEntry(Message): key: int value: MapEnum - - def __init__(self, - key: Optional[int] = ..., - value: Optional[MapEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32EnumEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[MapEnum] = ...) -> None: ... class MapInt32ForeignMessageEntry(Message): key: int - @property def value(self) -> ForeignMessage1: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[ForeignMessage1] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32ForeignMessageEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[ForeignMessage1] = ...) -> None: ... class MapStringForeignMessageEntry(Message): key: Text - @property def value(self) -> ForeignMessage1: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[ForeignMessage1] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestMap.MapStringForeignMessageEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[ForeignMessage1] = ...) -> None: ... class MapInt32AllTypesEntry(Message): key: int - @property def value(self) -> TestAllTypes: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32AllTypesEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestAllTypes] = ...) -> None: ... @property def map_int32_int32(self) -> MutableMapping[int, int]: ... - @property def map_int64_int64(self) -> MutableMapping[int, int]: ... - @property def map_uint32_uint32(self) -> MutableMapping[int, int]: ... - @property def map_uint64_uint64(self) -> MutableMapping[int, int]: ... - @property def map_sint32_sint32(self) -> MutableMapping[int, int]: ... - @property def map_sint64_sint64(self) -> MutableMapping[int, int]: ... - @property def map_fixed32_fixed32(self) -> MutableMapping[int, int]: ... - @property def map_fixed64_fixed64(self) -> MutableMapping[int, int]: ... - @property def map_sfixed32_sfixed32(self) -> MutableMapping[int, int]: ... - @property def map_sfixed64_sfixed64(self) -> MutableMapping[int, int]: ... - @property def map_int32_float(self) -> MutableMapping[int, float]: ... - @property def map_int32_double(self) -> MutableMapping[int, float]: ... - @property def map_bool_bool(self) -> MutableMapping[bool, bool]: ... - @property def map_string_string(self) -> MutableMapping[Text, Text]: ... - @property def map_int32_bytes(self) -> MutableMapping[int, bytes]: ... - @property def map_int32_enum(self) -> MutableMapping[int, MapEnum]: ... - @property - def map_int32_foreign_message( - self) -> MutableMapping[int, ForeignMessage1]: ... - + def map_int32_foreign_message(self) -> MutableMapping[int, ForeignMessage1]: ... @property - def map_string_foreign_message( - self) -> MutableMapping[Text, ForeignMessage1]: ... - + def map_string_foreign_message(self) -> MutableMapping[Text, ForeignMessage1]: ... @property def map_int32_all_types(self) -> MutableMapping[int, TestAllTypes]: ... - - def __init__(self, - map_int32_int32: Optional[Mapping[int, int]] = ..., - map_int64_int64: Optional[Mapping[int, int]] = ..., - map_uint32_uint32: Optional[Mapping[int, int]] = ..., - map_uint64_uint64: Optional[Mapping[int, int]] = ..., - map_sint32_sint32: Optional[Mapping[int, int]] = ..., - map_sint64_sint64: Optional[Mapping[int, int]] = ..., - map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., - map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., - map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., - map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., - map_int32_float: Optional[Mapping[int, float]] = ..., - map_int32_double: Optional[Mapping[int, float]] = ..., - map_bool_bool: Optional[Mapping[bool, bool]] = ..., - map_string_string: Optional[Mapping[Text, Text]] = ..., - map_int32_bytes: Optional[Mapping[int, bytes]] = ..., - map_int32_enum: Optional[Mapping[int, MapEnum]] = ..., - map_int32_foreign_message: Optional[Mapping[int, ForeignMessage1]] = ..., - map_string_foreign_message: Optional[Mapping[Text, ForeignMessage1]] = ..., - map_int32_all_types: Optional[Mapping[int, TestAllTypes]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap: ... - + def __init__( + self, + map_int32_int32: Optional[Mapping[int, int]] = ..., + map_int64_int64: Optional[Mapping[int, int]] = ..., + map_uint32_uint32: Optional[Mapping[int, int]] = ..., + map_uint64_uint64: Optional[Mapping[int, int]] = ..., + map_sint32_sint32: Optional[Mapping[int, int]] = ..., + map_sint64_sint64: Optional[Mapping[int, int]] = ..., + map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., + map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., + map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., + map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., + map_int32_float: Optional[Mapping[int, float]] = ..., + map_int32_double: Optional[Mapping[int, float]] = ..., + map_bool_bool: Optional[Mapping[bool, bool]] = ..., + map_string_string: Optional[Mapping[Text, Text]] = ..., + map_int32_bytes: Optional[Mapping[int, bytes]] = ..., + map_int32_enum: Optional[Mapping[int, MapEnum]] = ..., + map_int32_foreign_message: Optional[Mapping[int, ForeignMessage1]] = ..., + map_string_foreign_message: Optional[Mapping[Text, ForeignMessage1]] = ..., + map_int32_all_types: Optional[Mapping[int, TestAllTypes]] = ..., + ) -> None: ... class TestMapSubmessage(Message): - @property def test_map(self) -> TestMap: ... - - def __init__(self, - test_map: Optional[TestMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMapSubmessage: ... - + def __init__(self, test_map: Optional[TestMap] = ...) -> None: ... class TestMessageMap(Message): - class MapInt32MessageEntry(Message): key: int - @property def value(self) -> TestAllTypes: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageMap.MapInt32MessageEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestAllTypes] = ...) -> None: ... @property def map_int32_message(self) -> MutableMapping[int, TestAllTypes]: ... - - def __init__(self, - map_int32_message: Optional[Mapping[int, TestAllTypes]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageMap: ... - + def __init__(self, map_int32_message: Optional[Mapping[int, TestAllTypes]] = ...) -> None: ... class TestSameTypeMap(Message): - class Map1Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestSameTypeMap.Map1Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class Map2Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestSameTypeMap.Map2Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... @property def map1(self) -> MutableMapping[int, int]: ... - @property def map2(self) -> MutableMapping[int, int]: ... - - def __init__(self, - map1: Optional[Mapping[int, int]] = ..., - map2: Optional[Mapping[int, int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestSameTypeMap: ... - + def __init__(self, map1: Optional[Mapping[int, int]] = ..., map2: Optional[Mapping[int, int]] = ...) -> None: ... class TestRequiredMessageMap(Message): - class MapFieldEntry(Message): key: int - @property def value(self) -> TestRequired: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[TestRequired] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestRequiredMessageMap.MapFieldEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[TestRequired] = ...) -> None: ... @property def map_field(self) -> MutableMapping[int, TestRequired]: ... - - def __init__(self, - map_field: Optional[Mapping[int, TestRequired]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRequiredMessageMap: ... - + def __init__(self, map_field: Optional[Mapping[int, TestRequired]] = ...) -> None: ... class TestArenaMap(Message): - class MapInt32Int32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32Int32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt64Int64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt64Int64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint32Uint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapUint32Uint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint64Uint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapUint64Uint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint32Sint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapSint32Sint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint64Sint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapSint64Sint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed32Fixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapFixed32Fixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed64Fixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapFixed64Fixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed32Sfixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapSfixed32Sfixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed64Sfixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapSfixed64Sfixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt32FloatEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32FloatEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapInt32DoubleEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32DoubleEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapBoolBoolEntry(Message): key: bool value: bool - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[bool] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapBoolBoolEntry: ... - + def __init__(self, key: Optional[bool] = ..., value: Optional[bool] = ...) -> None: ... class MapStringStringEntry(Message): key: Text value: Text - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapStringStringEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[Text] = ...) -> None: ... class MapInt32BytesEntry(Message): key: int value: bytes - - def __init__(self, - key: Optional[int] = ..., - value: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32BytesEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[bytes] = ...) -> None: ... class MapInt32EnumEntry(Message): key: int value: MapEnum - - def __init__(self, - key: Optional[int] = ..., - value: Optional[MapEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32EnumEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[MapEnum] = ...) -> None: ... class MapInt32ForeignMessageEntry(Message): key: int - @property def value(self) -> ForeignMessage1: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[ForeignMessage1] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapInt32ForeignMessageEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[ForeignMessage1] = ...) -> None: ... class MapInt32ForeignMessageNoArenaEntry(Message): key: int - @property def value(self) -> ForeignMessage: ... - - def __init__(self, - key: Optional[int] = ..., - value: Optional[ForeignMessage] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapInt32ForeignMessageNoArenaEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[ForeignMessage] = ...) -> None: ... @property def map_int32_int32(self) -> MutableMapping[int, int]: ... - @property def map_int64_int64(self) -> MutableMapping[int, int]: ... - @property def map_uint32_uint32(self) -> MutableMapping[int, int]: ... - @property def map_uint64_uint64(self) -> MutableMapping[int, int]: ... - @property def map_sint32_sint32(self) -> MutableMapping[int, int]: ... - @property def map_sint64_sint64(self) -> MutableMapping[int, int]: ... - @property def map_fixed32_fixed32(self) -> MutableMapping[int, int]: ... - @property def map_fixed64_fixed64(self) -> MutableMapping[int, int]: ... - @property def map_sfixed32_sfixed32(self) -> MutableMapping[int, int]: ... - @property def map_sfixed64_sfixed64(self) -> MutableMapping[int, int]: ... - @property def map_int32_float(self) -> MutableMapping[int, float]: ... - @property def map_int32_double(self) -> MutableMapping[int, float]: ... - @property def map_bool_bool(self) -> MutableMapping[bool, bool]: ... - @property def map_string_string(self) -> MutableMapping[Text, Text]: ... - @property def map_int32_bytes(self) -> MutableMapping[int, bytes]: ... - @property def map_int32_enum(self) -> MutableMapping[int, MapEnum]: ... - - @property - def map_int32_foreign_message( - self) -> MutableMapping[int, ForeignMessage1]: ... - @property - def map_int32_foreign_message_no_arena( - self) -> MutableMapping[int, ForeignMessage]: ... - - def __init__(self, - map_int32_int32: Optional[Mapping[int, int]] = ..., - map_int64_int64: Optional[Mapping[int, int]] = ..., - map_uint32_uint32: Optional[Mapping[int, int]] = ..., - map_uint64_uint64: Optional[Mapping[int, int]] = ..., - map_sint32_sint32: Optional[Mapping[int, int]] = ..., - map_sint64_sint64: Optional[Mapping[int, int]] = ..., - map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., - map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., - map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., - map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., - map_int32_float: Optional[Mapping[int, float]] = ..., - map_int32_double: Optional[Mapping[int, float]] = ..., - map_bool_bool: Optional[Mapping[bool, bool]] = ..., - map_string_string: Optional[Mapping[Text, Text]] = ..., - map_int32_bytes: Optional[Mapping[int, bytes]] = ..., - map_int32_enum: Optional[Mapping[int, MapEnum]] = ..., - map_int32_foreign_message: Optional[Mapping[int, ForeignMessage1]] = ..., - map_int32_foreign_message_no_arena: Optional[Mapping[int, ForeignMessage]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap: ... - + def map_int32_foreign_message(self) -> MutableMapping[int, ForeignMessage1]: ... + @property + def map_int32_foreign_message_no_arena(self) -> MutableMapping[int, ForeignMessage]: ... + def __init__( + self, + map_int32_int32: Optional[Mapping[int, int]] = ..., + map_int64_int64: Optional[Mapping[int, int]] = ..., + map_uint32_uint32: Optional[Mapping[int, int]] = ..., + map_uint64_uint64: Optional[Mapping[int, int]] = ..., + map_sint32_sint32: Optional[Mapping[int, int]] = ..., + map_sint64_sint64: Optional[Mapping[int, int]] = ..., + map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., + map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., + map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., + map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., + map_int32_float: Optional[Mapping[int, float]] = ..., + map_int32_double: Optional[Mapping[int, float]] = ..., + map_bool_bool: Optional[Mapping[bool, bool]] = ..., + map_string_string: Optional[Mapping[Text, Text]] = ..., + map_int32_bytes: Optional[Mapping[int, bytes]] = ..., + map_int32_enum: Optional[Mapping[int, MapEnum]] = ..., + map_int32_foreign_message: Optional[Mapping[int, ForeignMessage1]] = ..., + map_int32_foreign_message_no_arena: Optional[Mapping[int, ForeignMessage]] = ..., + ) -> None: ... class MessageContainingEnumCalledType(Message): - class Type(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> MessageContainingEnumCalledType.Type: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[MessageContainingEnumCalledType.Type]: ... - @classmethod - def items(cls) -> List[Tuple[bytes, - MessageContainingEnumCalledType.Type]]: ... + def items(cls) -> List[Tuple[bytes, MessageContainingEnumCalledType.Type]]: ... TYPE_FOO: MessageContainingEnumCalledType.Type - class TypeEntry(Message): key: Text - @property def value(self) -> MessageContainingEnumCalledType: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[MessageContainingEnumCalledType] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> MessageContainingEnumCalledType.TypeEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[MessageContainingEnumCalledType] = ...) -> None: ... @property - def type(self) -> MutableMapping[Text, - MessageContainingEnumCalledType]: ... - - def __init__(self, - type: Optional[Mapping[Text, MessageContainingEnumCalledType]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MessageContainingEnumCalledType: ... - + def type(self) -> MutableMapping[Text, MessageContainingEnumCalledType]: ... + def __init__(self, type: Optional[Mapping[Text, MessageContainingEnumCalledType]] = ...) -> None: ... class MessageContainingMapCalledEntry(Message): - class EntryEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> MessageContainingMapCalledEntry.EntryEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... @property def entry(self) -> MutableMapping[int, int]: ... - - def __init__(self, - entry: Optional[Mapping[int, int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MessageContainingMapCalledEntry: ... - + def __init__(self, entry: Optional[Mapping[int, int]] = ...) -> None: ... class TestRecursiveMapMessage(Message): - class AEntry(Message): key: Text - @property def value(self) -> TestRecursiveMapMessage: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[TestRecursiveMapMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRecursiveMapMessage.AEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[TestRecursiveMapMessage] = ...) -> None: ... @property def a(self) -> MutableMapping[Text, TestRecursiveMapMessage]: ... - - def __init__(self, - a: Optional[Mapping[Text, TestRecursiveMapMessage]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRecursiveMapMessage: ... + def __init__(self, a: Optional[Mapping[Text, TestRecursiveMapMessage]] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/message.pyi b/third_party/2and3/google/protobuf/message.pyi index 4bf8cabfb282..215fb2b4ca3b 100644 --- a/third_party/2and3/google/protobuf/message.pyi +++ b/third_party/2and3/google/protobuf/message.pyi @@ -1,9 +1,8 @@ -from typing import Any, Sequence, Optional, Tuple +import sys -from .descriptor import ( - DescriptorBase, - FieldDescriptor, -) +from typing import Any, Sequence, Optional, Tuple, Type, TypeVar, Union + +from .descriptor import DescriptorBase, FieldDescriptor class Error(Exception): ... class DecodeError(Error): ... @@ -13,6 +12,13 @@ class _ExtensionDict: def __getitem__(self, extension_handle: DescriptorBase) -> Any: ... def __setitem__(self, extension_handle: DescriptorBase, value: Any) -> None: ... +_T = TypeVar("_T") + +if sys.version_info < (3,): + _Serialized = Union[bytes, buffer, unicode] +else: + _Serialized = bytes + class Message: DESCRIPTOR: Any def __deepcopy__(self, memo=...): ... @@ -23,17 +29,18 @@ class Message: def Clear(self) -> None: ... def SetInParent(self) -> None: ... def IsInitialized(self) -> bool: ... - def MergeFromString(self, serialized: Any) -> int: ... # TODO: we need to be able to call buffer() on serialized - def ParseFromString(self, serialized: Any) -> None: ... + def MergeFromString(self, serialized: _Serialized) -> int: ... + def ParseFromString(self, serialized: _Serialized) -> None: ... def SerializeToString(self, deterministic: bool = ...) -> bytes: ... def SerializePartialToString(self, deterministic: bool = ...) -> bytes: ... def ListFields(self) -> Sequence[Tuple[FieldDescriptor, Any]]: ... def HasExtension(self, extension_handle): ... def ClearExtension(self, extension_handle): ... def ByteSize(self) -> int: ... + @classmethod + def FromString(cls: Type[_T], s: _Serialized) -> _T: ... @property def Extensions(self) -> _ExtensionDict: ... - # Intentionally left out typing on these three methods, because they are # stringly typed and it is not useful to call them on a Message directly. # We prefer more specific typing on individual subclasses of Message @@ -41,6 +48,5 @@ class Message: def HasField(self, field_name: Any) -> bool: ... def ClearField(self, field_name: Any) -> None: ... def WhichOneof(self, oneof_group: Any) -> Any: ... - # TODO: check kwargs def __init__(self, **kwargs) -> None: ... diff --git a/third_party/2and3/google/protobuf/source_context_pb2.pyi b/third_party/2and3/google/protobuf/source_context_pb2.pyi index 527ac1a4f8c0..5d5cc8b7470d 100644 --- a/third_party/2and3/google/protobuf/source_context_pb2.pyi +++ b/third_party/2and3/google/protobuf/source_context_pb2.pyi @@ -1,18 +1,6 @@ -from google.protobuf.message import ( - Message, -) -from typing import ( - Optional, - Text, -) - +from google.protobuf.message import Message +from typing import Optional, Text class SourceContext(Message): file_name: Text - - def __init__(self, - file_name: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> SourceContext: ... + def __init__(self, file_name: Optional[Text] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/struct_pb2.pyi b/third_party/2and3/google/protobuf/struct_pb2.pyi index 21afcc71b393..18a67215a78b 100644 --- a/third_party/2and3/google/protobuf/struct_pb2.pyi +++ b/third_party/2and3/google/protobuf/struct_pb2.pyi @@ -1,105 +1,55 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, -) +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer from google.protobuf.internal import well_known_types -from google.protobuf.message import ( - Message, -) -from typing import ( - Iterable, - List, - Mapping, - MutableMapping, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.message import Message +from typing import Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, cast class NullValue(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> NullValue: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[NullValue]: ... - @classmethod def items(cls) -> List[Tuple[bytes, NullValue]]: ... - NULL_VALUE: NullValue - class Struct(Message, well_known_types.Struct): class FieldsEntry(Message): key: Text - @property def value(self) -> Value: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[Value] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Struct.FieldsEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[Value] = ...) -> None: ... @property def fields(self) -> MutableMapping[Text, Value]: ... - - def __init__(self, - fields: Optional[Mapping[Text, Value]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Struct: ... - + def __init__(self, fields: Optional[Mapping[Text, Value]] = ...) -> None: ... class _Value(Message): null_value: NullValue number_value: float string_value: Text bool_value: bool - @property def struct_value(self) -> Struct: ... - @property def list_value(self) -> ListValue: ... - - def __init__(self, - null_value: Optional[NullValue] = ..., - number_value: Optional[float] = ..., - string_value: Optional[Text] = ..., - bool_value: Optional[bool] = ..., - struct_value: Optional[Struct] = ..., - list_value: Optional[ListValue] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> _Value: ... - + def __init__( + self, + null_value: Optional[NullValue] = ..., + number_value: Optional[float] = ..., + string_value: Optional[Text] = ..., + bool_value: Optional[bool] = ..., + struct_value: Optional[Struct] = ..., + list_value: Optional[ListValue] = ..., + ) -> None: ... Value = _Value - class ListValue(Message, well_known_types.ListValue): - @property def values(self) -> RepeatedCompositeFieldContainer[Value]: ... - - def __init__(self, - values: Optional[Iterable[Value]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ListValue: ... + def __init__(self, values: Optional[Iterable[Value]] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi b/third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi index 03e34be76ad7..1795f81df877 100644 --- a/third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi +++ b/third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi @@ -1,375 +1,135 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message import builtins -from typing import ( - Iterable, - List, - Mapping, - MutableMapping, - Optional, - Text, - Tuple, - cast, -) - +from typing import Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, cast class ForeignEnumProto2(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> ForeignEnumProto2: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[ForeignEnumProto2]: ... - @classmethod def items(cls) -> List[Tuple[bytes, ForeignEnumProto2]]: ... - FOREIGN_FOO: ForeignEnumProto2 FOREIGN_BAR: ForeignEnumProto2 FOREIGN_BAZ: ForeignEnumProto2 - class TestAllTypesProto2(Message): - class NestedEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestAllTypesProto2.NestedEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestAllTypesProto2.NestedEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestAllTypesProto2.NestedEnum]]: ... FOO: TestAllTypesProto2.NestedEnum BAR: TestAllTypesProto2.NestedEnum BAZ: TestAllTypesProto2.NestedEnum NEG: TestAllTypesProto2.NestedEnum - class NestedMessage(Message): a: int - @property def corecursive(self) -> TestAllTypesProto2: ... - - def __init__(self, - a: Optional[int] = ..., - corecursive: Optional[TestAllTypesProto2] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2.NestedMessage: ... - + def __init__(self, a: Optional[int] = ..., corecursive: Optional[TestAllTypesProto2] = ...) -> None: ... class MapInt32Int32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt32Int32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt64Int64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt64Int64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint32Uint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapUint32Uint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint64Uint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapUint64Uint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint32Sint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSint32Sint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint64Sint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSint64Sint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed32Fixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapFixed32Fixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed64Fixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapFixed64Fixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed32Sfixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSfixed32Sfixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed64Sfixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSfixed64Sfixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt32FloatEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt32FloatEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapInt32DoubleEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt32DoubleEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapBoolBoolEntry(Message): key: bool value: bool - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[bool] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2.MapBoolBoolEntry: ... - + def __init__(self, key: Optional[bool] = ..., value: Optional[bool] = ...) -> None: ... class MapStringStringEntry(Message): key: Text value: Text - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringStringEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[Text] = ...) -> None: ... class MapStringBytesEntry(Message): key: Text value: bytes - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringBytesEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[bytes] = ...) -> None: ... class MapStringNestedMessageEntry(Message): key: Text - @property def value(self) -> TestAllTypesProto2.NestedMessage: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[TestAllTypesProto2.NestedMessage] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringNestedMessageEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[TestAllTypesProto2.NestedMessage] = ...) -> None: ... class MapStringForeignMessageEntry(Message): key: Text - @property def value(self) -> ForeignMessageProto2: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[ForeignMessageProto2] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringForeignMessageEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[ForeignMessageProto2] = ...) -> None: ... class MapStringNestedEnumEntry(Message): key: Text value: TestAllTypesProto2.NestedEnum - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[TestAllTypesProto2.NestedEnum] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringNestedEnumEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[TestAllTypesProto2.NestedEnum] = ...) -> None: ... class MapStringForeignEnumEntry(Message): key: Text value: ForeignEnumProto2 - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[ForeignEnumProto2] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringForeignEnumEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[ForeignEnumProto2] = ...) -> None: ... class Data(Message): group_int32: int group_uint32: int - - def __init__(self, - group_int32: Optional[int] = ..., - group_uint32: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2.Data: ... - + def __init__(self, group_int32: Optional[int] = ..., group_uint32: Optional[int] = ...) -> None: ... class MessageSetCorrect(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MessageSetCorrect: ... - + def __init__(self,) -> None: ... class MessageSetCorrectExtension1(Message): bytes: Text - - def __init__(self, - bytes: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: builtins.bytes) -> TestAllTypesProto2.MessageSetCorrectExtension1: ... - + def __init__(self, bytes: Optional[Text] = ...) -> None: ... class MessageSetCorrectExtension2(Message): i: int - - def __init__(self, - i: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MessageSetCorrectExtension2: ... + def __init__(self, i: Optional[int] = ...) -> None: ... optional_int32: int optional_int64: int optional_uint32: int @@ -434,194 +194,152 @@ class TestAllTypesProto2(Message): field__Name16: int field_name17__: int Field_name18__: int - @property def optional_nested_message(self) -> TestAllTypesProto2.NestedMessage: ... - @property def optional_foreign_message(self) -> ForeignMessageProto2: ... - @property def recursive_message(self) -> TestAllTypesProto2: ... - @property - def repeated_nested_message( - self) -> RepeatedCompositeFieldContainer[TestAllTypesProto2.NestedMessage]: ... - + def repeated_nested_message(self) -> RepeatedCompositeFieldContainer[TestAllTypesProto2.NestedMessage]: ... @property - def repeated_foreign_message( - self) -> RepeatedCompositeFieldContainer[ForeignMessageProto2]: ... - + def repeated_foreign_message(self) -> RepeatedCompositeFieldContainer[ForeignMessageProto2]: ... @property def map_int32_int32(self) -> MutableMapping[int, int]: ... - @property def map_int64_int64(self) -> MutableMapping[int, int]: ... - @property def map_uint32_uint32(self) -> MutableMapping[int, int]: ... - @property def map_uint64_uint64(self) -> MutableMapping[int, int]: ... - @property def map_sint32_sint32(self) -> MutableMapping[int, int]: ... - @property def map_sint64_sint64(self) -> MutableMapping[int, int]: ... - @property def map_fixed32_fixed32(self) -> MutableMapping[int, int]: ... - @property def map_fixed64_fixed64(self) -> MutableMapping[int, int]: ... - @property def map_sfixed32_sfixed32(self) -> MutableMapping[int, int]: ... - @property def map_sfixed64_sfixed64(self) -> MutableMapping[int, int]: ... - @property def map_int32_float(self) -> MutableMapping[int, float]: ... - @property def map_int32_double(self) -> MutableMapping[int, float]: ... - @property def map_bool_bool(self) -> MutableMapping[bool, bool]: ... - @property def map_string_string(self) -> MutableMapping[Text, Text]: ... - @property def map_string_bytes(self) -> MutableMapping[Text, bytes]: ... - @property - def map_string_nested_message( - self) -> MutableMapping[Text, TestAllTypesProto2.NestedMessage]: ... - + def map_string_nested_message(self) -> MutableMapping[Text, TestAllTypesProto2.NestedMessage]: ... @property - def map_string_foreign_message( - self) -> MutableMapping[Text, ForeignMessageProto2]: ... - + def map_string_foreign_message(self) -> MutableMapping[Text, ForeignMessageProto2]: ... @property - def map_string_nested_enum( - self) -> MutableMapping[Text, TestAllTypesProto2.NestedEnum]: ... - + def map_string_nested_enum(self) -> MutableMapping[Text, TestAllTypesProto2.NestedEnum]: ... @property - def map_string_foreign_enum( - self) -> MutableMapping[Text, ForeignEnumProto2]: ... - + def map_string_foreign_enum(self) -> MutableMapping[Text, ForeignEnumProto2]: ... @property def oneof_nested_message(self) -> TestAllTypesProto2.NestedMessage: ... - @property def data(self) -> TestAllTypesProto2.Data: ... - - def __init__(self, - optional_int32: Optional[int] = ..., - optional_int64: Optional[int] = ..., - optional_uint32: Optional[int] = ..., - optional_uint64: Optional[int] = ..., - optional_sint32: Optional[int] = ..., - optional_sint64: Optional[int] = ..., - optional_fixed32: Optional[int] = ..., - optional_fixed64: Optional[int] = ..., - optional_sfixed32: Optional[int] = ..., - optional_sfixed64: Optional[int] = ..., - optional_float: Optional[float] = ..., - optional_double: Optional[float] = ..., - optional_bool: Optional[bool] = ..., - optional_string: Optional[Text] = ..., - optional_bytes: Optional[bytes] = ..., - optional_nested_message: Optional[TestAllTypesProto2.NestedMessage] = ..., - optional_foreign_message: Optional[ForeignMessageProto2] = ..., - optional_nested_enum: Optional[TestAllTypesProto2.NestedEnum] = ..., - optional_foreign_enum: Optional[ForeignEnumProto2] = ..., - optional_string_piece: Optional[Text] = ..., - optional_cord: Optional[Text] = ..., - recursive_message: Optional[TestAllTypesProto2] = ..., - repeated_int32: Optional[Iterable[int]] = ..., - repeated_int64: Optional[Iterable[int]] = ..., - repeated_uint32: Optional[Iterable[int]] = ..., - repeated_uint64: Optional[Iterable[int]] = ..., - repeated_sint32: Optional[Iterable[int]] = ..., - repeated_sint64: Optional[Iterable[int]] = ..., - repeated_fixed32: Optional[Iterable[int]] = ..., - repeated_fixed64: Optional[Iterable[int]] = ..., - repeated_sfixed32: Optional[Iterable[int]] = ..., - repeated_sfixed64: Optional[Iterable[int]] = ..., - repeated_float: Optional[Iterable[float]] = ..., - repeated_double: Optional[Iterable[float]] = ..., - repeated_bool: Optional[Iterable[bool]] = ..., - repeated_string: Optional[Iterable[Text]] = ..., - repeated_bytes: Optional[Iterable[bytes]] = ..., - repeated_nested_message: Optional[Iterable[TestAllTypesProto2.NestedMessage]] = ..., - repeated_foreign_message: Optional[Iterable[ForeignMessageProto2]] = ..., - repeated_nested_enum: Optional[Iterable[TestAllTypesProto2.NestedEnum]] = ..., - repeated_foreign_enum: Optional[Iterable[ForeignEnumProto2]] = ..., - repeated_string_piece: Optional[Iterable[Text]] = ..., - repeated_cord: Optional[Iterable[Text]] = ..., - map_int32_int32: Optional[Mapping[int, int]] = ..., - map_int64_int64: Optional[Mapping[int, int]] = ..., - map_uint32_uint32: Optional[Mapping[int, int]] = ..., - map_uint64_uint64: Optional[Mapping[int, int]] = ..., - map_sint32_sint32: Optional[Mapping[int, int]] = ..., - map_sint64_sint64: Optional[Mapping[int, int]] = ..., - map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., - map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., - map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., - map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., - map_int32_float: Optional[Mapping[int, float]] = ..., - map_int32_double: Optional[Mapping[int, float]] = ..., - map_bool_bool: Optional[Mapping[bool, bool]] = ..., - map_string_string: Optional[Mapping[Text, Text]] = ..., - map_string_bytes: Optional[Mapping[Text, bytes]] = ..., - map_string_nested_message: Optional[Mapping[Text, TestAllTypesProto2.NestedMessage]] = ..., - map_string_foreign_message: Optional[Mapping[Text, ForeignMessageProto2]] = ..., - map_string_nested_enum: Optional[Mapping[Text, TestAllTypesProto2.NestedEnum]] = ..., - map_string_foreign_enum: Optional[Mapping[Text, ForeignEnumProto2]] = ..., - oneof_uint32: Optional[int] = ..., - oneof_nested_message: Optional[TestAllTypesProto2.NestedMessage] = ..., - oneof_string: Optional[Text] = ..., - oneof_bytes: Optional[bytes] = ..., - oneof_bool: Optional[bool] = ..., - oneof_uint64: Optional[int] = ..., - oneof_float: Optional[float] = ..., - oneof_double: Optional[float] = ..., - oneof_enum: Optional[TestAllTypesProto2.NestedEnum] = ..., - data: Optional[TestAllTypesProto2.Data] = ..., - fieldname1: Optional[int] = ..., - field_name2: Optional[int] = ..., - _field_name3: Optional[int] = ..., - field__name4_: Optional[int] = ..., - field0name5: Optional[int] = ..., - field_0_name6: Optional[int] = ..., - fieldName7: Optional[int] = ..., - FieldName8: Optional[int] = ..., - field_Name9: Optional[int] = ..., - Field_Name10: Optional[int] = ..., - FIELD_NAME11: Optional[int] = ..., - FIELD_name12: Optional[int] = ..., - __field_name13: Optional[int] = ..., - __Field_name14: Optional[int] = ..., - field__name15: Optional[int] = ..., - field__Name16: Optional[int] = ..., - field_name17__: Optional[int] = ..., - Field_name18__: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2: ... - + def __init__( + self, + optional_int32: Optional[int] = ..., + optional_int64: Optional[int] = ..., + optional_uint32: Optional[int] = ..., + optional_uint64: Optional[int] = ..., + optional_sint32: Optional[int] = ..., + optional_sint64: Optional[int] = ..., + optional_fixed32: Optional[int] = ..., + optional_fixed64: Optional[int] = ..., + optional_sfixed32: Optional[int] = ..., + optional_sfixed64: Optional[int] = ..., + optional_float: Optional[float] = ..., + optional_double: Optional[float] = ..., + optional_bool: Optional[bool] = ..., + optional_string: Optional[Text] = ..., + optional_bytes: Optional[bytes] = ..., + optional_nested_message: Optional[TestAllTypesProto2.NestedMessage] = ..., + optional_foreign_message: Optional[ForeignMessageProto2] = ..., + optional_nested_enum: Optional[TestAllTypesProto2.NestedEnum] = ..., + optional_foreign_enum: Optional[ForeignEnumProto2] = ..., + optional_string_piece: Optional[Text] = ..., + optional_cord: Optional[Text] = ..., + recursive_message: Optional[TestAllTypesProto2] = ..., + repeated_int32: Optional[Iterable[int]] = ..., + repeated_int64: Optional[Iterable[int]] = ..., + repeated_uint32: Optional[Iterable[int]] = ..., + repeated_uint64: Optional[Iterable[int]] = ..., + repeated_sint32: Optional[Iterable[int]] = ..., + repeated_sint64: Optional[Iterable[int]] = ..., + repeated_fixed32: Optional[Iterable[int]] = ..., + repeated_fixed64: Optional[Iterable[int]] = ..., + repeated_sfixed32: Optional[Iterable[int]] = ..., + repeated_sfixed64: Optional[Iterable[int]] = ..., + repeated_float: Optional[Iterable[float]] = ..., + repeated_double: Optional[Iterable[float]] = ..., + repeated_bool: Optional[Iterable[bool]] = ..., + repeated_string: Optional[Iterable[Text]] = ..., + repeated_bytes: Optional[Iterable[bytes]] = ..., + repeated_nested_message: Optional[Iterable[TestAllTypesProto2.NestedMessage]] = ..., + repeated_foreign_message: Optional[Iterable[ForeignMessageProto2]] = ..., + repeated_nested_enum: Optional[Iterable[TestAllTypesProto2.NestedEnum]] = ..., + repeated_foreign_enum: Optional[Iterable[ForeignEnumProto2]] = ..., + repeated_string_piece: Optional[Iterable[Text]] = ..., + repeated_cord: Optional[Iterable[Text]] = ..., + map_int32_int32: Optional[Mapping[int, int]] = ..., + map_int64_int64: Optional[Mapping[int, int]] = ..., + map_uint32_uint32: Optional[Mapping[int, int]] = ..., + map_uint64_uint64: Optional[Mapping[int, int]] = ..., + map_sint32_sint32: Optional[Mapping[int, int]] = ..., + map_sint64_sint64: Optional[Mapping[int, int]] = ..., + map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., + map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., + map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., + map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., + map_int32_float: Optional[Mapping[int, float]] = ..., + map_int32_double: Optional[Mapping[int, float]] = ..., + map_bool_bool: Optional[Mapping[bool, bool]] = ..., + map_string_string: Optional[Mapping[Text, Text]] = ..., + map_string_bytes: Optional[Mapping[Text, bytes]] = ..., + map_string_nested_message: Optional[Mapping[Text, TestAllTypesProto2.NestedMessage]] = ..., + map_string_foreign_message: Optional[Mapping[Text, ForeignMessageProto2]] = ..., + map_string_nested_enum: Optional[Mapping[Text, TestAllTypesProto2.NestedEnum]] = ..., + map_string_foreign_enum: Optional[Mapping[Text, ForeignEnumProto2]] = ..., + oneof_uint32: Optional[int] = ..., + oneof_nested_message: Optional[TestAllTypesProto2.NestedMessage] = ..., + oneof_string: Optional[Text] = ..., + oneof_bytes: Optional[bytes] = ..., + oneof_bool: Optional[bool] = ..., + oneof_uint64: Optional[int] = ..., + oneof_float: Optional[float] = ..., + oneof_double: Optional[float] = ..., + oneof_enum: Optional[TestAllTypesProto2.NestedEnum] = ..., + data: Optional[TestAllTypesProto2.Data] = ..., + fieldname1: Optional[int] = ..., + field_name2: Optional[int] = ..., + _field_name3: Optional[int] = ..., + field__name4_: Optional[int] = ..., + field0name5: Optional[int] = ..., + field_0_name6: Optional[int] = ..., + fieldName7: Optional[int] = ..., + FieldName8: Optional[int] = ..., + field_Name9: Optional[int] = ..., + Field_Name10: Optional[int] = ..., + FIELD_NAME11: Optional[int] = ..., + FIELD_name12: Optional[int] = ..., + __field_name13: Optional[int] = ..., + __Field_name14: Optional[int] = ..., + field__name15: Optional[int] = ..., + field__Name16: Optional[int] = ..., + field_name17__: Optional[int] = ..., + Field_name18__: Optional[int] = ..., + ) -> None: ... class ForeignMessageProto2(Message): c: int - - def __init__(self, - c: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ForeignMessageProto2: ... + def __init__(self, c: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi b/third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi index 5a9cce340cd0..d9f01cec1a33 100644 --- a/third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi +++ b/third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi @@ -1,26 +1,10 @@ -from google.protobuf.any_pb2 import ( - Any, -) -from google.protobuf.duration_pb2 import ( - Duration, -) -from google.protobuf.field_mask_pb2 import ( - FieldMask, -) -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.struct_pb2 import ( - Struct, - Value, -) -from google.protobuf.timestamp_pb2 import ( - Timestamp, -) +from google.protobuf.any_pb2 import Any +from google.protobuf.duration_pb2 import Duration +from google.protobuf.field_mask_pb2 import FieldMask +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from google.protobuf.struct_pb2 import Struct, Value +from google.protobuf.timestamp_pb2 import Timestamp from google.protobuf.wrappers_pb2 import ( BoolValue, BytesValue, @@ -32,307 +16,123 @@ from google.protobuf.wrappers_pb2 import ( UInt32Value, UInt64Value, ) -from typing import ( - Iterable, - List, - Mapping, - MutableMapping, - Optional, - Text, - Tuple, - cast, -) - +from typing import Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, cast class ForeignEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> ForeignEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[ForeignEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, ForeignEnum]]: ... + FOREIGN_FOO: ForeignEnum FOREIGN_BAR: ForeignEnum FOREIGN_BAZ: ForeignEnum - class TestAllTypesProto3(Message): - class NestedEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestAllTypesProto3.NestedEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestAllTypesProto3.NestedEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestAllTypesProto3.NestedEnum]]: ... FOO: TestAllTypesProto3.NestedEnum BAR: TestAllTypesProto3.NestedEnum BAZ: TestAllTypesProto3.NestedEnum NEG: TestAllTypesProto3.NestedEnum - class NestedMessage(Message): a: int - @property def corecursive(self) -> TestAllTypesProto3: ... - - def __init__(self, - a: Optional[int] = ..., - corecursive: Optional[TestAllTypesProto3] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.NestedMessage: ... - + def __init__(self, a: Optional[int] = ..., corecursive: Optional[TestAllTypesProto3] = ...) -> None: ... class MapInt32Int32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt32Int32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt64Int64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt64Int64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint32Uint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapUint32Uint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapUint64Uint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapUint64Uint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint32Sint32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSint32Sint32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSint64Sint64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSint64Sint64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed32Fixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapFixed32Fixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapFixed64Fixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapFixed64Fixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed32Sfixed32Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSfixed32Sfixed32Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapSfixed64Sfixed64Entry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSfixed64Sfixed64Entry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class MapInt32FloatEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt32FloatEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapInt32DoubleEntry(Message): key: int value: float - - def __init__(self, - key: Optional[int] = ..., - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt32DoubleEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[float] = ...) -> None: ... class MapBoolBoolEntry(Message): key: bool value: bool - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[bool] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapBoolBoolEntry: ... - + def __init__(self, key: Optional[bool] = ..., value: Optional[bool] = ...) -> None: ... class MapStringStringEntry(Message): key: Text value: Text - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringStringEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[Text] = ...) -> None: ... class MapStringBytesEntry(Message): key: Text value: bytes - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringBytesEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[bytes] = ...) -> None: ... class MapStringNestedMessageEntry(Message): key: Text - @property def value(self) -> TestAllTypesProto3.NestedMessage: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[TestAllTypesProto3.NestedMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringNestedMessageEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[TestAllTypesProto3.NestedMessage] = ...) -> None: ... class MapStringForeignMessageEntry(Message): key: Text - @property def value(self) -> ForeignMessage: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[ForeignMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringForeignMessageEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[ForeignMessage] = ...) -> None: ... class MapStringNestedEnumEntry(Message): key: Text value: TestAllTypesProto3.NestedEnum - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[TestAllTypesProto3.NestedEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringNestedEnumEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[TestAllTypesProto3.NestedEnum] = ...) -> None: ... class MapStringForeignEnumEntry(Message): key: Text value: ForeignEnum - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[ForeignEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringForeignEnumEntry: ... + def __init__(self, key: Optional[Text] = ..., value: Optional[ForeignEnum] = ...) -> None: ... optional_int32: int optional_int64: int optional_uint32: int @@ -397,304 +197,239 @@ class TestAllTypesProto3(Message): field__Name16: int field_name17__: int Field_name18__: int - @property def optional_nested_message(self) -> TestAllTypesProto3.NestedMessage: ... - @property def optional_foreign_message(self) -> ForeignMessage: ... - @property def recursive_message(self) -> TestAllTypesProto3: ... - @property def repeated_nested_message(self) -> RepeatedCompositeFieldContainer[TestAllTypesProto3.NestedMessage]: ... - @property def repeated_foreign_message(self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... - @property def map_int32_int32(self) -> MutableMapping[int, int]: ... - @property def map_int64_int64(self) -> MutableMapping[int, int]: ... - @property def map_uint32_uint32(self) -> MutableMapping[int, int]: ... - @property def map_uint64_uint64(self) -> MutableMapping[int, int]: ... - @property def map_sint32_sint32(self) -> MutableMapping[int, int]: ... - @property def map_sint64_sint64(self) -> MutableMapping[int, int]: ... - @property def map_fixed32_fixed32(self) -> MutableMapping[int, int]: ... - @property def map_fixed64_fixed64(self) -> MutableMapping[int, int]: ... - @property def map_sfixed32_sfixed32(self) -> MutableMapping[int, int]: ... - @property def map_sfixed64_sfixed64(self) -> MutableMapping[int, int]: ... - @property def map_int32_float(self) -> MutableMapping[int, float]: ... - @property def map_int32_double(self) -> MutableMapping[int, float]: ... - @property def map_bool_bool(self) -> MutableMapping[bool, bool]: ... - @property def map_string_string(self) -> MutableMapping[Text, Text]: ... - @property def map_string_bytes(self) -> MutableMapping[Text, bytes]: ... - @property def map_string_nested_message(self) -> MutableMapping[Text, TestAllTypesProto3.NestedMessage]: ... - @property def map_string_foreign_message(self) -> MutableMapping[Text, ForeignMessage]: ... - @property def map_string_nested_enum(self) -> MutableMapping[Text, TestAllTypesProto3.NestedEnum]: ... - @property def map_string_foreign_enum(self) -> MutableMapping[Text, ForeignEnum]: ... - @property def oneof_nested_message(self) -> TestAllTypesProto3.NestedMessage: ... - @property def optional_bool_wrapper(self) -> BoolValue: ... - @property def optional_int32_wrapper(self) -> Int32Value: ... - @property def optional_int64_wrapper(self) -> Int64Value: ... - @property def optional_uint32_wrapper(self) -> UInt32Value: ... - @property def optional_uint64_wrapper(self) -> UInt64Value: ... - @property def optional_float_wrapper(self) -> FloatValue: ... - @property def optional_double_wrapper(self) -> DoubleValue: ... - @property def optional_string_wrapper(self) -> StringValue: ... - @property def optional_bytes_wrapper(self) -> BytesValue: ... - @property def repeated_bool_wrapper(self) -> RepeatedCompositeFieldContainer[BoolValue]: ... - @property def repeated_int32_wrapper(self) -> RepeatedCompositeFieldContainer[Int32Value]: ... - @property def repeated_int64_wrapper(self) -> RepeatedCompositeFieldContainer[Int64Value]: ... - @property def repeated_uint32_wrapper(self) -> RepeatedCompositeFieldContainer[UInt32Value]: ... - @property def repeated_uint64_wrapper(self) -> RepeatedCompositeFieldContainer[UInt64Value]: ... - @property def repeated_float_wrapper(self) -> RepeatedCompositeFieldContainer[FloatValue]: ... - @property def repeated_double_wrapper(self) -> RepeatedCompositeFieldContainer[DoubleValue]: ... - @property def repeated_string_wrapper(self) -> RepeatedCompositeFieldContainer[StringValue]: ... - @property def repeated_bytes_wrapper(self) -> RepeatedCompositeFieldContainer[BytesValue]: ... - @property def optional_duration(self) -> Duration: ... - @property def optional_timestamp(self) -> Timestamp: ... - @property def optional_field_mask(self) -> FieldMask: ... - @property def optional_struct(self) -> Struct: ... - @property def optional_any(self) -> Any: ... - @property def optional_value(self) -> Value: ... - @property def repeated_duration(self) -> RepeatedCompositeFieldContainer[Duration]: ... - @property def repeated_timestamp(self) -> RepeatedCompositeFieldContainer[Timestamp]: ... - @property def repeated_fieldmask(self) -> RepeatedCompositeFieldContainer[FieldMask]: ... - @property def repeated_struct(self) -> RepeatedCompositeFieldContainer[Struct]: ... - @property def repeated_any(self) -> RepeatedCompositeFieldContainer[Any]: ... - @property def repeated_value(self) -> RepeatedCompositeFieldContainer[Value]: ... - - def __init__(self, - optional_int32: Optional[int] = ..., - optional_int64: Optional[int] = ..., - optional_uint32: Optional[int] = ..., - optional_uint64: Optional[int] = ..., - optional_sint32: Optional[int] = ..., - optional_sint64: Optional[int] = ..., - optional_fixed32: Optional[int] = ..., - optional_fixed64: Optional[int] = ..., - optional_sfixed32: Optional[int] = ..., - optional_sfixed64: Optional[int] = ..., - optional_float: Optional[float] = ..., - optional_double: Optional[float] = ..., - optional_bool: Optional[bool] = ..., - optional_string: Optional[Text] = ..., - optional_bytes: Optional[bytes] = ..., - optional_nested_message: Optional[TestAllTypesProto3.NestedMessage] = ..., - optional_foreign_message: Optional[ForeignMessage] = ..., - optional_nested_enum: Optional[TestAllTypesProto3.NestedEnum] = ..., - optional_foreign_enum: Optional[ForeignEnum] = ..., - optional_string_piece: Optional[Text] = ..., - optional_cord: Optional[Text] = ..., - recursive_message: Optional[TestAllTypesProto3] = ..., - repeated_int32: Optional[Iterable[int]] = ..., - repeated_int64: Optional[Iterable[int]] = ..., - repeated_uint32: Optional[Iterable[int]] = ..., - repeated_uint64: Optional[Iterable[int]] = ..., - repeated_sint32: Optional[Iterable[int]] = ..., - repeated_sint64: Optional[Iterable[int]] = ..., - repeated_fixed32: Optional[Iterable[int]] = ..., - repeated_fixed64: Optional[Iterable[int]] = ..., - repeated_sfixed32: Optional[Iterable[int]] = ..., - repeated_sfixed64: Optional[Iterable[int]] = ..., - repeated_float: Optional[Iterable[float]] = ..., - repeated_double: Optional[Iterable[float]] = ..., - repeated_bool: Optional[Iterable[bool]] = ..., - repeated_string: Optional[Iterable[Text]] = ..., - repeated_bytes: Optional[Iterable[bytes]] = ..., - repeated_nested_message: Optional[Iterable[TestAllTypesProto3.NestedMessage]] = ..., - repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., - repeated_nested_enum: Optional[Iterable[TestAllTypesProto3.NestedEnum]] = ..., - repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., - repeated_string_piece: Optional[Iterable[Text]] = ..., - repeated_cord: Optional[Iterable[Text]] = ..., - map_int32_int32: Optional[Mapping[int, int]] = ..., - map_int64_int64: Optional[Mapping[int, int]] = ..., - map_uint32_uint32: Optional[Mapping[int, int]] = ..., - map_uint64_uint64: Optional[Mapping[int, int]] = ..., - map_sint32_sint32: Optional[Mapping[int, int]] = ..., - map_sint64_sint64: Optional[Mapping[int, int]] = ..., - map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., - map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., - map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., - map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., - map_int32_float: Optional[Mapping[int, float]] = ..., - map_int32_double: Optional[Mapping[int, float]] = ..., - map_bool_bool: Optional[Mapping[bool, bool]] = ..., - map_string_string: Optional[Mapping[Text, Text]] = ..., - map_string_bytes: Optional[Mapping[Text, bytes]] = ..., - map_string_nested_message: Optional[Mapping[Text, TestAllTypesProto3.NestedMessage]] = ..., - map_string_foreign_message: Optional[Mapping[Text, ForeignMessage]] = ..., - map_string_nested_enum: Optional[Mapping[Text, TestAllTypesProto3.NestedEnum]] = ..., - map_string_foreign_enum: Optional[Mapping[Text, ForeignEnum]] = ..., - oneof_uint32: Optional[int] = ..., - oneof_nested_message: Optional[TestAllTypesProto3.NestedMessage] = ..., - oneof_string: Optional[Text] = ..., - oneof_bytes: Optional[bytes] = ..., - oneof_bool: Optional[bool] = ..., - oneof_uint64: Optional[int] = ..., - oneof_float: Optional[float] = ..., - oneof_double: Optional[float] = ..., - oneof_enum: Optional[TestAllTypesProto3.NestedEnum] = ..., - optional_bool_wrapper: Optional[BoolValue] = ..., - optional_int32_wrapper: Optional[Int32Value] = ..., - optional_int64_wrapper: Optional[Int64Value] = ..., - optional_uint32_wrapper: Optional[UInt32Value] = ..., - optional_uint64_wrapper: Optional[UInt64Value] = ..., - optional_float_wrapper: Optional[FloatValue] = ..., - optional_double_wrapper: Optional[DoubleValue] = ..., - optional_string_wrapper: Optional[StringValue] = ..., - optional_bytes_wrapper: Optional[BytesValue] = ..., - repeated_bool_wrapper: Optional[Iterable[BoolValue]] = ..., - repeated_int32_wrapper: Optional[Iterable[Int32Value]] = ..., - repeated_int64_wrapper: Optional[Iterable[Int64Value]] = ..., - repeated_uint32_wrapper: Optional[Iterable[UInt32Value]] = ..., - repeated_uint64_wrapper: Optional[Iterable[UInt64Value]] = ..., - repeated_float_wrapper: Optional[Iterable[FloatValue]] = ..., - repeated_double_wrapper: Optional[Iterable[DoubleValue]] = ..., - repeated_string_wrapper: Optional[Iterable[StringValue]] = ..., - repeated_bytes_wrapper: Optional[Iterable[BytesValue]] = ..., - optional_duration: Optional[Duration] = ..., - optional_timestamp: Optional[Timestamp] = ..., - optional_field_mask: Optional[FieldMask] = ..., - optional_struct: Optional[Struct] = ..., - optional_any: Optional[Any] = ..., - optional_value: Optional[Value] = ..., - repeated_duration: Optional[Iterable[Duration]] = ..., - repeated_timestamp: Optional[Iterable[Timestamp]] = ..., - repeated_fieldmask: Optional[Iterable[FieldMask]] = ..., - repeated_struct: Optional[Iterable[Struct]] = ..., - repeated_any: Optional[Iterable[Any]] = ..., - repeated_value: Optional[Iterable[Value]] = ..., - fieldname1: Optional[int] = ..., - field_name2: Optional[int] = ..., - _field_name3: Optional[int] = ..., - field__name4_: Optional[int] = ..., - field0name5: Optional[int] = ..., - field_0_name6: Optional[int] = ..., - fieldName7: Optional[int] = ..., - FieldName8: Optional[int] = ..., - field_Name9: Optional[int] = ..., - Field_Name10: Optional[int] = ..., - FIELD_NAME11: Optional[int] = ..., - FIELD_name12: Optional[int] = ..., - __field_name13: Optional[int] = ..., - __Field_name14: Optional[int] = ..., - field__name15: Optional[int] = ..., - field__Name16: Optional[int] = ..., - field_name17__: Optional[int] = ..., - Field_name18__: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3: ... - + def __init__( + self, + optional_int32: Optional[int] = ..., + optional_int64: Optional[int] = ..., + optional_uint32: Optional[int] = ..., + optional_uint64: Optional[int] = ..., + optional_sint32: Optional[int] = ..., + optional_sint64: Optional[int] = ..., + optional_fixed32: Optional[int] = ..., + optional_fixed64: Optional[int] = ..., + optional_sfixed32: Optional[int] = ..., + optional_sfixed64: Optional[int] = ..., + optional_float: Optional[float] = ..., + optional_double: Optional[float] = ..., + optional_bool: Optional[bool] = ..., + optional_string: Optional[Text] = ..., + optional_bytes: Optional[bytes] = ..., + optional_nested_message: Optional[TestAllTypesProto3.NestedMessage] = ..., + optional_foreign_message: Optional[ForeignMessage] = ..., + optional_nested_enum: Optional[TestAllTypesProto3.NestedEnum] = ..., + optional_foreign_enum: Optional[ForeignEnum] = ..., + optional_string_piece: Optional[Text] = ..., + optional_cord: Optional[Text] = ..., + recursive_message: Optional[TestAllTypesProto3] = ..., + repeated_int32: Optional[Iterable[int]] = ..., + repeated_int64: Optional[Iterable[int]] = ..., + repeated_uint32: Optional[Iterable[int]] = ..., + repeated_uint64: Optional[Iterable[int]] = ..., + repeated_sint32: Optional[Iterable[int]] = ..., + repeated_sint64: Optional[Iterable[int]] = ..., + repeated_fixed32: Optional[Iterable[int]] = ..., + repeated_fixed64: Optional[Iterable[int]] = ..., + repeated_sfixed32: Optional[Iterable[int]] = ..., + repeated_sfixed64: Optional[Iterable[int]] = ..., + repeated_float: Optional[Iterable[float]] = ..., + repeated_double: Optional[Iterable[float]] = ..., + repeated_bool: Optional[Iterable[bool]] = ..., + repeated_string: Optional[Iterable[Text]] = ..., + repeated_bytes: Optional[Iterable[bytes]] = ..., + repeated_nested_message: Optional[Iterable[TestAllTypesProto3.NestedMessage]] = ..., + repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., + repeated_nested_enum: Optional[Iterable[TestAllTypesProto3.NestedEnum]] = ..., + repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., + repeated_string_piece: Optional[Iterable[Text]] = ..., + repeated_cord: Optional[Iterable[Text]] = ..., + map_int32_int32: Optional[Mapping[int, int]] = ..., + map_int64_int64: Optional[Mapping[int, int]] = ..., + map_uint32_uint32: Optional[Mapping[int, int]] = ..., + map_uint64_uint64: Optional[Mapping[int, int]] = ..., + map_sint32_sint32: Optional[Mapping[int, int]] = ..., + map_sint64_sint64: Optional[Mapping[int, int]] = ..., + map_fixed32_fixed32: Optional[Mapping[int, int]] = ..., + map_fixed64_fixed64: Optional[Mapping[int, int]] = ..., + map_sfixed32_sfixed32: Optional[Mapping[int, int]] = ..., + map_sfixed64_sfixed64: Optional[Mapping[int, int]] = ..., + map_int32_float: Optional[Mapping[int, float]] = ..., + map_int32_double: Optional[Mapping[int, float]] = ..., + map_bool_bool: Optional[Mapping[bool, bool]] = ..., + map_string_string: Optional[Mapping[Text, Text]] = ..., + map_string_bytes: Optional[Mapping[Text, bytes]] = ..., + map_string_nested_message: Optional[Mapping[Text, TestAllTypesProto3.NestedMessage]] = ..., + map_string_foreign_message: Optional[Mapping[Text, ForeignMessage]] = ..., + map_string_nested_enum: Optional[Mapping[Text, TestAllTypesProto3.NestedEnum]] = ..., + map_string_foreign_enum: Optional[Mapping[Text, ForeignEnum]] = ..., + oneof_uint32: Optional[int] = ..., + oneof_nested_message: Optional[TestAllTypesProto3.NestedMessage] = ..., + oneof_string: Optional[Text] = ..., + oneof_bytes: Optional[bytes] = ..., + oneof_bool: Optional[bool] = ..., + oneof_uint64: Optional[int] = ..., + oneof_float: Optional[float] = ..., + oneof_double: Optional[float] = ..., + oneof_enum: Optional[TestAllTypesProto3.NestedEnum] = ..., + optional_bool_wrapper: Optional[BoolValue] = ..., + optional_int32_wrapper: Optional[Int32Value] = ..., + optional_int64_wrapper: Optional[Int64Value] = ..., + optional_uint32_wrapper: Optional[UInt32Value] = ..., + optional_uint64_wrapper: Optional[UInt64Value] = ..., + optional_float_wrapper: Optional[FloatValue] = ..., + optional_double_wrapper: Optional[DoubleValue] = ..., + optional_string_wrapper: Optional[StringValue] = ..., + optional_bytes_wrapper: Optional[BytesValue] = ..., + repeated_bool_wrapper: Optional[Iterable[BoolValue]] = ..., + repeated_int32_wrapper: Optional[Iterable[Int32Value]] = ..., + repeated_int64_wrapper: Optional[Iterable[Int64Value]] = ..., + repeated_uint32_wrapper: Optional[Iterable[UInt32Value]] = ..., + repeated_uint64_wrapper: Optional[Iterable[UInt64Value]] = ..., + repeated_float_wrapper: Optional[Iterable[FloatValue]] = ..., + repeated_double_wrapper: Optional[Iterable[DoubleValue]] = ..., + repeated_string_wrapper: Optional[Iterable[StringValue]] = ..., + repeated_bytes_wrapper: Optional[Iterable[BytesValue]] = ..., + optional_duration: Optional[Duration] = ..., + optional_timestamp: Optional[Timestamp] = ..., + optional_field_mask: Optional[FieldMask] = ..., + optional_struct: Optional[Struct] = ..., + optional_any: Optional[Any] = ..., + optional_value: Optional[Value] = ..., + repeated_duration: Optional[Iterable[Duration]] = ..., + repeated_timestamp: Optional[Iterable[Timestamp]] = ..., + repeated_fieldmask: Optional[Iterable[FieldMask]] = ..., + repeated_struct: Optional[Iterable[Struct]] = ..., + repeated_any: Optional[Iterable[Any]] = ..., + repeated_value: Optional[Iterable[Value]] = ..., + fieldname1: Optional[int] = ..., + field_name2: Optional[int] = ..., + _field_name3: Optional[int] = ..., + field__name4_: Optional[int] = ..., + field0name5: Optional[int] = ..., + field_0_name6: Optional[int] = ..., + fieldName7: Optional[int] = ..., + FieldName8: Optional[int] = ..., + field_Name9: Optional[int] = ..., + Field_Name10: Optional[int] = ..., + FIELD_NAME11: Optional[int] = ..., + FIELD_name12: Optional[int] = ..., + __field_name13: Optional[int] = ..., + __Field_name14: Optional[int] = ..., + field__name15: Optional[int] = ..., + field__Name16: Optional[int] = ..., + field_name17__: Optional[int] = ..., + Field_name18__: Optional[int] = ..., + ) -> None: ... class ForeignMessage(Message): c: int - - def __init__(self, - c: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... + def __init__(self, c: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/timestamp_pb2.pyi b/third_party/2and3/google/protobuf/timestamp_pb2.pyi index 77ae3055c095..c34570c623e3 100644 --- a/third_party/2and3/google/protobuf/timestamp_pb2.pyi +++ b/third_party/2and3/google/protobuf/timestamp_pb2.pyi @@ -1,21 +1,9 @@ -from google.protobuf.message import ( - Message, -) +from google.protobuf.message import Message from google.protobuf.internal import well_known_types -from typing import ( - Optional, -) - +from typing import Optional class Timestamp(Message, well_known_types.Timestamp): seconds: int nanos: int - - def __init__(self, - seconds: Optional[int] = ..., - nanos: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Timestamp: ... + def __init__(self, seconds: Optional[int] = ..., nanos: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/type_pb2.pyi b/third_party/2and3/google/protobuf/type_pb2.pyi index e3ff9b101d19..40c8633a1e3d 100644 --- a/third_party/2and3/google/protobuf/type_pb2.pyi +++ b/third_party/2and3/google/protobuf/type_pb2.pyi @@ -1,91 +1,54 @@ -from google.protobuf.any_pb2 import ( - Any, -) -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.source_context_pb2 import ( - SourceContext, -) -from typing import ( - Iterable, - List, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.any_pb2 import Any +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from google.protobuf.source_context_pb2 import SourceContext +from typing import Iterable, List, Optional, Text, Tuple, cast class Syntax(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> Syntax: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[Syntax]: ... - @classmethod def items(cls) -> List[Tuple[bytes, Syntax]]: ... - SYNTAX_PROTO2: Syntax SYNTAX_PROTO3: Syntax - class Type(Message): name: Text oneofs: RepeatedScalarFieldContainer[Text] syntax: Syntax - @property def fields(self) -> RepeatedCompositeFieldContainer[Field]: ... - @property def options(self) -> RepeatedCompositeFieldContainer[Option]: ... - @property def source_context(self) -> SourceContext: ... - - def __init__(self, - name: Optional[Text] = ..., - fields: Optional[Iterable[Field]] = ..., - oneofs: Optional[Iterable[Text]] = ..., - options: Optional[Iterable[Option]] = ..., - source_context: Optional[SourceContext] = ..., - syntax: Optional[Syntax] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Type: ... - + def __init__( + self, + name: Optional[Text] = ..., + fields: Optional[Iterable[Field]] = ..., + oneofs: Optional[Iterable[Text]] = ..., + options: Optional[Iterable[Option]] = ..., + source_context: Optional[SourceContext] = ..., + syntax: Optional[Syntax] = ..., + ) -> None: ... class Field(Message): - class Kind(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> Field.Kind: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[Field.Kind]: ... - @classmethod def items(cls) -> List[Tuple[bytes, Field.Kind]]: ... TYPE_UNKNOWN: Field.Kind @@ -107,21 +70,15 @@ class Field(Message): TYPE_SFIXED64: Field.Kind TYPE_SINT32: Field.Kind TYPE_SINT64: Field.Kind - class Cardinality(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> Field.Cardinality: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[Field.Cardinality]: ... - @classmethod def items(cls) -> List[Tuple[bytes, Field.Cardinality]]: ... CARDINALITY_UNKNOWN: Field.Cardinality @@ -137,79 +94,51 @@ class Field(Message): packed: bool json_name: Text default_value: Text - @property def options(self) -> RepeatedCompositeFieldContainer[Option]: ... - - def __init__(self, - kind: Optional[Field.Kind] = ..., - cardinality: Optional[Field.Cardinality] = ..., - number: Optional[int] = ..., - name: Optional[Text] = ..., - type_url: Optional[Text] = ..., - oneof_index: Optional[int] = ..., - packed: Optional[bool] = ..., - options: Optional[Iterable[Option]] = ..., - json_name: Optional[Text] = ..., - default_value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Field: ... - + def __init__( + self, + kind: Optional[Field.Kind] = ..., + cardinality: Optional[Field.Cardinality] = ..., + number: Optional[int] = ..., + name: Optional[Text] = ..., + type_url: Optional[Text] = ..., + oneof_index: Optional[int] = ..., + packed: Optional[bool] = ..., + options: Optional[Iterable[Option]] = ..., + json_name: Optional[Text] = ..., + default_value: Optional[Text] = ..., + ) -> None: ... class Enum(Message): name: Text syntax: Syntax - @property def enumvalue(self) -> RepeatedCompositeFieldContainer[EnumValue]: ... - @property def options(self) -> RepeatedCompositeFieldContainer[Option]: ... - @property def source_context(self) -> SourceContext: ... - - def __init__(self, - name: Optional[Text] = ..., - enumvalue: Optional[Iterable[EnumValue]] = ..., - options: Optional[Iterable[Option]] = ..., - source_context: Optional[SourceContext] = ..., - syntax: Optional[Syntax] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Enum: ... - + def __init__( + self, + name: Optional[Text] = ..., + enumvalue: Optional[Iterable[EnumValue]] = ..., + options: Optional[Iterable[Option]] = ..., + source_context: Optional[SourceContext] = ..., + syntax: Optional[Syntax] = ..., + ) -> None: ... class EnumValue(Message): name: Text number: int - @property def options(self) -> RepeatedCompositeFieldContainer[Option]: ... - - def __init__(self, - name: Optional[Text] = ..., - number: Optional[int] = ..., - options: Optional[Iterable[Option]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> EnumValue: ... - + def __init__( + self, name: Optional[Text] = ..., number: Optional[int] = ..., options: Optional[Iterable[Option]] = ... + ) -> None: ... class Option(Message): name: Text - @property def value(self) -> Any: ... - - def __init__(self, - name: Optional[Text] = ..., - value: Optional[Any] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Option: ... + def __init__(self, name: Optional[Text] = ..., value: Optional[Any] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi b/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi index 89d6042be384..8be9db18b9fa 100644 --- a/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi @@ -1,43 +1,19 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.unittest_no_arena_import_pb2 import ( - ImportNoArenaNestedMessage, -) -from typing import ( - Iterable, - Optional, -) - +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer +from google.protobuf.message import Message +from google.protobuf.unittest_no_arena_import_pb2 import ImportNoArenaNestedMessage +from typing import Iterable, Optional class NestedMessage(Message): d: int - - def __init__(self, - d: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> NestedMessage: ... - + def __init__(self, d: Optional[int] = ...) -> None: ... class ArenaMessage(Message): - @property - def repeated_nested_message( - self) -> RepeatedCompositeFieldContainer[NestedMessage]: ... - + def repeated_nested_message(self) -> RepeatedCompositeFieldContainer[NestedMessage]: ... @property - def repeated_import_no_arena_message( - self) -> RepeatedCompositeFieldContainer[ImportNoArenaNestedMessage]: ... - - def __init__(self, - repeated_nested_message: Optional[Iterable[NestedMessage]] = ..., - repeated_import_no_arena_message: Optional[Iterable[ImportNoArenaNestedMessage]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ArenaMessage: ... + def repeated_import_no_arena_message(self) -> RepeatedCompositeFieldContainer[ImportNoArenaNestedMessage]: ... + def __init__( + self, + repeated_nested_message: Optional[Iterable[NestedMessage]] = ..., + repeated_import_no_arena_message: Optional[Iterable[ImportNoArenaNestedMessage]] = ..., + ) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi b/third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi index 5028e079eaee..83c710db9055 100644 --- a/third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi @@ -1,472 +1,226 @@ -from google.protobuf.descriptor_pb2 import ( - FileOptions, -) -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from typing import ( - Iterable, - List, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.descriptor_pb2 import FileOptions +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from typing import Iterable, List, Optional, Text, Tuple, cast class MethodOpt1(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> MethodOpt1: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[MethodOpt1]: ... - @classmethod def items(cls) -> List[Tuple[bytes, MethodOpt1]]: ... - METHODOPT1_VAL1: MethodOpt1 METHODOPT1_VAL2: MethodOpt1 - class AggregateEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> AggregateEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[AggregateEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, AggregateEnum]]: ... - VALUE: AggregateEnum - class TestMessageWithCustomOptions(Message): - class AnEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestMessageWithCustomOptions.AnEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestMessageWithCustomOptions.AnEnum]: ... - @classmethod - def items(cls) -> List[Tuple[bytes, - TestMessageWithCustomOptions.AnEnum]]: ... + def items(cls) -> List[Tuple[bytes, TestMessageWithCustomOptions.AnEnum]]: ... ANENUM_VAL1: TestMessageWithCustomOptions.AnEnum ANENUM_VAL2: TestMessageWithCustomOptions.AnEnum field1: Text oneof_field: int - - def __init__(self, - field1: Optional[Text] = ..., - oneof_field: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageWithCustomOptions: ... - + def __init__(self, field1: Optional[Text] = ..., oneof_field: Optional[int] = ...) -> None: ... class CustomOptionFooRequest(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooRequest: ... - + def __init__(self,) -> None: ... class CustomOptionFooResponse(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooResponse: ... - + def __init__(self,) -> None: ... class CustomOptionFooClientMessage(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooClientMessage: ... - + def __init__(self,) -> None: ... class CustomOptionFooServerMessage(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooServerMessage: ... - + def __init__(self,) -> None: ... class DummyMessageContainingEnum(Message): - class TestEnumType(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> DummyMessageContainingEnum.TestEnumType: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[DummyMessageContainingEnum.TestEnumType]: ... - @classmethod - def items(cls) -> List[Tuple[bytes, - DummyMessageContainingEnum.TestEnumType]]: ... + def items(cls) -> List[Tuple[bytes, DummyMessageContainingEnum.TestEnumType]]: ... TEST_OPTION_ENUM_TYPE1: DummyMessageContainingEnum.TestEnumType TEST_OPTION_ENUM_TYPE2: DummyMessageContainingEnum.TestEnumType - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> DummyMessageContainingEnum: ... - + def __init__(self,) -> None: ... class DummyMessageInvalidAsOptionType(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> DummyMessageInvalidAsOptionType: ... - + def __init__(self,) -> None: ... class CustomOptionMinIntegerValues(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CustomOptionMinIntegerValues: ... - + def __init__(self,) -> None: ... class CustomOptionMaxIntegerValues(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CustomOptionMaxIntegerValues: ... - + def __init__(self,) -> None: ... class CustomOptionOtherValues(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CustomOptionOtherValues: ... - + def __init__(self,) -> None: ... class SettingRealsFromPositiveInts(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> SettingRealsFromPositiveInts: ... - + def __init__(self,) -> None: ... class SettingRealsFromNegativeInts(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> SettingRealsFromNegativeInts: ... - + def __init__(self,) -> None: ... class ComplexOptionType1(Message): foo: int foo2: int foo3: int foo4: RepeatedScalarFieldContainer[int] - - def __init__(self, - foo: Optional[int] = ..., - foo2: Optional[int] = ..., - foo3: Optional[int] = ..., - foo4: Optional[Iterable[int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ComplexOptionType1: ... - + def __init__( + self, foo: Optional[int] = ..., foo2: Optional[int] = ..., foo3: Optional[int] = ..., foo4: Optional[Iterable[int]] = ... + ) -> None: ... class ComplexOptionType2(Message): - class ComplexOptionType4(Message): waldo: int - - def __init__(self, - waldo: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> ComplexOptionType2.ComplexOptionType4: ... + def __init__(self, waldo: Optional[int] = ...) -> None: ... baz: int - @property def bar(self) -> ComplexOptionType1: ... - @property def fred(self) -> ComplexOptionType2.ComplexOptionType4: ... - @property - def barney( - self) -> RepeatedCompositeFieldContainer[ComplexOptionType2.ComplexOptionType4]: ... - - def __init__(self, - bar: Optional[ComplexOptionType1] = ..., - baz: Optional[int] = ..., - fred: Optional[ComplexOptionType2.ComplexOptionType4] = ..., - barney: Optional[Iterable[ComplexOptionType2.ComplexOptionType4]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ComplexOptionType2: ... - + def barney(self) -> RepeatedCompositeFieldContainer[ComplexOptionType2.ComplexOptionType4]: ... + def __init__( + self, + bar: Optional[ComplexOptionType1] = ..., + baz: Optional[int] = ..., + fred: Optional[ComplexOptionType2.ComplexOptionType4] = ..., + barney: Optional[Iterable[ComplexOptionType2.ComplexOptionType4]] = ..., + ) -> None: ... class ComplexOptionType3(Message): - class ComplexOptionType5(Message): plugh: int - - def __init__(self, - plugh: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> ComplexOptionType3.ComplexOptionType5: ... + def __init__(self, plugh: Optional[int] = ...) -> None: ... qux: int - @property def complexoptiontype5(self) -> ComplexOptionType3.ComplexOptionType5: ... - - def __init__(self, - qux: Optional[int] = ..., - complexoptiontype5: Optional[ComplexOptionType3.ComplexOptionType5] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ComplexOptionType3: ... - + def __init__( + self, qux: Optional[int] = ..., complexoptiontype5: Optional[ComplexOptionType3.ComplexOptionType5] = ... + ) -> None: ... class ComplexOpt6(Message): xyzzy: int - - def __init__(self, - xyzzy: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ComplexOpt6: ... - + def __init__(self, xyzzy: Optional[int] = ...) -> None: ... class VariousComplexOptions(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> VariousComplexOptions: ... - + def __init__(self,) -> None: ... class AggregateMessageSet(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> AggregateMessageSet: ... - + def __init__(self,) -> None: ... class AggregateMessageSetElement(Message): s: Text - - def __init__(self, - s: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> AggregateMessageSetElement: ... - + def __init__(self, s: Optional[Text] = ...) -> None: ... class Aggregate(Message): i: int s: Text - @property def sub(self) -> Aggregate: ... - @property def file(self) -> FileOptions: ... - @property def mset(self) -> AggregateMessageSet: ... - - def __init__(self, - i: Optional[int] = ..., - s: Optional[Text] = ..., - sub: Optional[Aggregate] = ..., - file: Optional[FileOptions] = ..., - mset: Optional[AggregateMessageSet] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Aggregate: ... - + def __init__( + self, + i: Optional[int] = ..., + s: Optional[Text] = ..., + sub: Optional[Aggregate] = ..., + file: Optional[FileOptions] = ..., + mset: Optional[AggregateMessageSet] = ..., + ) -> None: ... class AggregateMessage(Message): fieldname: int - - def __init__(self, - fieldname: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> AggregateMessage: ... - + def __init__(self, fieldname: Optional[int] = ...) -> None: ... class NestedOptionType(Message): - class NestedEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> NestedOptionType.NestedEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[NestedOptionType.NestedEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, NestedOptionType.NestedEnum]]: ... NESTED_ENUM_VALUE: NestedOptionType.NestedEnum - class NestedMessage(Message): nested_field: int - - def __init__(self, - nested_field: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> NestedOptionType.NestedMessage: ... - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> NestedOptionType: ... - + def __init__(self, nested_field: Optional[int] = ...) -> None: ... + def __init__(self,) -> None: ... class OldOptionType(Message): - class TestEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> OldOptionType.TestEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[OldOptionType.TestEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, OldOptionType.TestEnum]]: ... OLD_VALUE: OldOptionType.TestEnum value: OldOptionType.TestEnum - - def __init__(self, - value: OldOptionType.TestEnum, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> OldOptionType: ... - + def __init__(self, value: OldOptionType.TestEnum) -> None: ... class NewOptionType(Message): - class TestEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> NewOptionType.TestEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[NewOptionType.TestEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, NewOptionType.TestEnum]]: ... OLD_VALUE: NewOptionType.TestEnum NEW_VALUE: NewOptionType.TestEnum value: NewOptionType.TestEnum - - def __init__(self, - value: NewOptionType.TestEnum, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> NewOptionType: ... - + def __init__(self, value: NewOptionType.TestEnum) -> None: ... class TestMessageWithRequiredEnumOption(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageWithRequiredEnumOption: ... + def __init__(self,) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_import_pb2.pyi b/third_party/2and3/google/protobuf/unittest_import_pb2.pyi index 92f191473ea5..3d4b91cf02e0 100644 --- a/third_party/2and3/google/protobuf/unittest_import_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_import_pb2.pyi @@ -1,66 +1,38 @@ -from google.protobuf.message import ( - Message, -) -from typing import ( - List, - Optional, - Tuple, - cast, -) - +from google.protobuf.message import Message +from typing import List, Optional, Tuple, cast class ImportEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> ImportEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[ImportEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, ImportEnum]]: ... - IMPORT_FOO: ImportEnum IMPORT_BAR: ImportEnum IMPORT_BAZ: ImportEnum - class ImportEnumForMap(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> ImportEnumForMap: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[ImportEnumForMap]: ... - @classmethod def items(cls) -> List[Tuple[bytes, ImportEnumForMap]]: ... - UNKNOWN: ImportEnumForMap FOO: ImportEnumForMap BAR: ImportEnumForMap - class ImportMessage(Message): d: int - - def __init__(self, - d: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ImportMessage: ... + def __init__(self, d: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi b/third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi index c8e13ff01e89..db23156018e7 100644 --- a/third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi @@ -1,17 +1,6 @@ -from google.protobuf.message import ( - Message, -) -from typing import ( - Optional, -) - +from google.protobuf.message import Message +from typing import Optional class PublicImportMessage(Message): e: int - - def __init__(self, - e: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> PublicImportMessage: ... + def __init__(self, e: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi b/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi index 63663207bda0..60a204c2a085 100644 --- a/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi @@ -1,75 +1,27 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.unittest_mset_wire_format_pb2 import ( - TestMessageSet, -) +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer +from google.protobuf.message import Message +from google.protobuf.unittest_mset_wire_format_pb2 import TestMessageSet import builtins -from typing import ( - Iterable, - Optional, - Text, -) - +from typing import Iterable, Optional, Text class TestMessageSetContainer(Message): - @property def message_set(self) -> TestMessageSet: ... - - def __init__(self, - message_set: Optional[TestMessageSet] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageSetContainer: ... - + def __init__(self, message_set: Optional[TestMessageSet] = ...) -> None: ... class TestMessageSetExtension1(Message): i: int - - def __init__(self, - i: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageSetExtension1: ... - + def __init__(self, i: Optional[int] = ...) -> None: ... class TestMessageSetExtension2(Message): str: Text - - def __init__(self, - bytes: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: builtins.bytes) -> TestMessageSetExtension2: ... - + def __init__(self, bytes: Optional[Text] = ...) -> None: ... class RawMessageSet(Message): - class Item(Message): type_id: int message: bytes - - def __init__(self, - type_id: int, - message: bytes, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> RawMessageSet.Item: ... - + def __init__(self, type_id: int, message: bytes) -> None: ... @property def item(self) -> RepeatedCompositeFieldContainer[RawMessageSet.Item]: ... - - def __init__(self, - item: Optional[Iterable[RawMessageSet.Item]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> RawMessageSet: ... + def __init__(self, item: Optional[Iterable[RawMessageSet.Item]] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_mset_wire_format_pb2.pyi b/third_party/2and3/google/protobuf/unittest_mset_wire_format_pb2.pyi index acb24a46f693..2414cd080b9c 100644 --- a/third_party/2and3/google/protobuf/unittest_mset_wire_format_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_mset_wire_format_pb2.pyi @@ -1,28 +1,10 @@ -from google.protobuf.message import ( - Message, -) -from typing import ( - Optional, -) - +from google.protobuf.message import Message +from typing import Optional class TestMessageSet(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageSet: ... - + def __init__(self,) -> None: ... class TestMessageSetWireFormatContainer(Message): - @property def message_set(self) -> TestMessageSet: ... - - def __init__(self, - message_set: Optional[TestMessageSet] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageSetWireFormatContainer: ... + def __init__(self, message_set: Optional[TestMessageSet] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_no_arena_import_pb2.pyi b/third_party/2and3/google/protobuf/unittest_no_arena_import_pb2.pyi index c02e4d3c74e7..e3032a684625 100644 --- a/third_party/2and3/google/protobuf/unittest_no_arena_import_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_no_arena_import_pb2.pyi @@ -1,17 +1,6 @@ -from google.protobuf.message import ( - Message, -) -from typing import ( - Optional, -) - +from google.protobuf.message import Message +from typing import Optional class ImportNoArenaNestedMessage(Message): d: int - - def __init__(self, - d: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ImportNoArenaNestedMessage: ... + def __init__(self, d: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi b/third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi index 8a256222b082..57c40294c663 100644 --- a/third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi @@ -1,105 +1,51 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.unittest_arena_pb2 import ( - ArenaMessage, -) -from google.protobuf.unittest_import_pb2 import ( - ImportEnum, - ImportMessage, -) -from google.protobuf.unittest_import_public_pb2 import ( - PublicImportMessage, -) -from typing import ( - Iterable, - List, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from google.protobuf.unittest_arena_pb2 import ArenaMessage +from google.protobuf.unittest_import_pb2 import ImportEnum, ImportMessage +from google.protobuf.unittest_import_public_pb2 import PublicImportMessage +from typing import Iterable, List, Optional, Text, Tuple, cast class ForeignEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> ForeignEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[ForeignEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, ForeignEnum]]: ... - FOREIGN_FOO: ForeignEnum FOREIGN_BAR: ForeignEnum FOREIGN_BAZ: ForeignEnum - class TestAllTypes(Message): - class NestedEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestAllTypes.NestedEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestAllTypes.NestedEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestAllTypes.NestedEnum]]: ... FOO: TestAllTypes.NestedEnum BAR: TestAllTypes.NestedEnum BAZ: TestAllTypes.NestedEnum NEG: TestAllTypes.NestedEnum - class NestedMessage(Message): bb: int - - def __init__(self, - bb: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.NestedMessage: ... - + def __init__(self, bb: Optional[int] = ...) -> None: ... class OptionalGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.OptionalGroup: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class RepeatedGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.RepeatedGroup: ... + def __init__(self, a: Optional[int] = ...) -> None: ... optional_int32: int optional_int64: int optional_uint32: int @@ -163,153 +109,117 @@ class TestAllTypes(Message): oneof_uint32: int oneof_string: Text oneof_bytes: bytes - @property def optionalgroup(self) -> TestAllTypes.OptionalGroup: ... - @property def optional_nested_message(self) -> TestAllTypes.NestedMessage: ... - @property def optional_foreign_message(self) -> ForeignMessage: ... - @property def optional_import_message(self) -> ImportMessage: ... - @property def optional_public_import_message(self) -> PublicImportMessage: ... - @property def optional_message(self) -> TestAllTypes.NestedMessage: ... - @property - def repeatedgroup( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.RepeatedGroup]: ... - + def repeatedgroup(self) -> RepeatedCompositeFieldContainer[TestAllTypes.RepeatedGroup]: ... @property - def repeated_nested_message( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... - + def repeated_nested_message(self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... @property - def repeated_foreign_message( - self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... - + def repeated_foreign_message(self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... @property - def repeated_import_message( - self) -> RepeatedCompositeFieldContainer[ImportMessage]: ... - + def repeated_import_message(self) -> RepeatedCompositeFieldContainer[ImportMessage]: ... @property - def repeated_lazy_message( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... - + def repeated_lazy_message(self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... @property def oneof_nested_message(self) -> TestAllTypes.NestedMessage: ... - @property def lazy_oneof_nested_message(self) -> TestAllTypes.NestedMessage: ... - - def __init__(self, - optional_int32: Optional[int] = ..., - optional_int64: Optional[int] = ..., - optional_uint32: Optional[int] = ..., - optional_uint64: Optional[int] = ..., - optional_sint32: Optional[int] = ..., - optional_sint64: Optional[int] = ..., - optional_fixed32: Optional[int] = ..., - optional_fixed64: Optional[int] = ..., - optional_sfixed32: Optional[int] = ..., - optional_sfixed64: Optional[int] = ..., - optional_float: Optional[float] = ..., - optional_double: Optional[float] = ..., - optional_bool: Optional[bool] = ..., - optional_string: Optional[Text] = ..., - optional_bytes: Optional[bytes] = ..., - optionalgroup: Optional[TestAllTypes.OptionalGroup] = ..., - optional_nested_message: Optional[TestAllTypes.NestedMessage] = ..., - optional_foreign_message: Optional[ForeignMessage] = ..., - optional_import_message: Optional[ImportMessage] = ..., - optional_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., - optional_foreign_enum: Optional[ForeignEnum] = ..., - optional_import_enum: Optional[ImportEnum] = ..., - optional_string_piece: Optional[Text] = ..., - optional_cord: Optional[Text] = ..., - optional_public_import_message: Optional[PublicImportMessage] = ..., - optional_message: Optional[TestAllTypes.NestedMessage] = ..., - repeated_int32: Optional[Iterable[int]] = ..., - repeated_int64: Optional[Iterable[int]] = ..., - repeated_uint32: Optional[Iterable[int]] = ..., - repeated_uint64: Optional[Iterable[int]] = ..., - repeated_sint32: Optional[Iterable[int]] = ..., - repeated_sint64: Optional[Iterable[int]] = ..., - repeated_fixed32: Optional[Iterable[int]] = ..., - repeated_fixed64: Optional[Iterable[int]] = ..., - repeated_sfixed32: Optional[Iterable[int]] = ..., - repeated_sfixed64: Optional[Iterable[int]] = ..., - repeated_float: Optional[Iterable[float]] = ..., - repeated_double: Optional[Iterable[float]] = ..., - repeated_bool: Optional[Iterable[bool]] = ..., - repeated_string: Optional[Iterable[Text]] = ..., - repeated_bytes: Optional[Iterable[bytes]] = ..., - repeatedgroup: Optional[Iterable[TestAllTypes.RepeatedGroup]] = ..., - repeated_nested_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., - repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., - repeated_import_message: Optional[Iterable[ImportMessage]] = ..., - repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., - repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., - repeated_import_enum: Optional[Iterable[ImportEnum]] = ..., - repeated_string_piece: Optional[Iterable[Text]] = ..., - repeated_cord: Optional[Iterable[Text]] = ..., - repeated_lazy_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., - default_int32: Optional[int] = ..., - default_int64: Optional[int] = ..., - default_uint32: Optional[int] = ..., - default_uint64: Optional[int] = ..., - default_sint32: Optional[int] = ..., - default_sint64: Optional[int] = ..., - default_fixed32: Optional[int] = ..., - default_fixed64: Optional[int] = ..., - default_sfixed32: Optional[int] = ..., - default_sfixed64: Optional[int] = ..., - default_float: Optional[float] = ..., - default_double: Optional[float] = ..., - default_bool: Optional[bool] = ..., - default_string: Optional[Text] = ..., - default_bytes: Optional[bytes] = ..., - default_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., - default_foreign_enum: Optional[ForeignEnum] = ..., - default_import_enum: Optional[ImportEnum] = ..., - default_string_piece: Optional[Text] = ..., - default_cord: Optional[Text] = ..., - oneof_uint32: Optional[int] = ..., - oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., - oneof_string: Optional[Text] = ..., - oneof_bytes: Optional[bytes] = ..., - lazy_oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes: ... - + def __init__( + self, + optional_int32: Optional[int] = ..., + optional_int64: Optional[int] = ..., + optional_uint32: Optional[int] = ..., + optional_uint64: Optional[int] = ..., + optional_sint32: Optional[int] = ..., + optional_sint64: Optional[int] = ..., + optional_fixed32: Optional[int] = ..., + optional_fixed64: Optional[int] = ..., + optional_sfixed32: Optional[int] = ..., + optional_sfixed64: Optional[int] = ..., + optional_float: Optional[float] = ..., + optional_double: Optional[float] = ..., + optional_bool: Optional[bool] = ..., + optional_string: Optional[Text] = ..., + optional_bytes: Optional[bytes] = ..., + optionalgroup: Optional[TestAllTypes.OptionalGroup] = ..., + optional_nested_message: Optional[TestAllTypes.NestedMessage] = ..., + optional_foreign_message: Optional[ForeignMessage] = ..., + optional_import_message: Optional[ImportMessage] = ..., + optional_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., + optional_foreign_enum: Optional[ForeignEnum] = ..., + optional_import_enum: Optional[ImportEnum] = ..., + optional_string_piece: Optional[Text] = ..., + optional_cord: Optional[Text] = ..., + optional_public_import_message: Optional[PublicImportMessage] = ..., + optional_message: Optional[TestAllTypes.NestedMessage] = ..., + repeated_int32: Optional[Iterable[int]] = ..., + repeated_int64: Optional[Iterable[int]] = ..., + repeated_uint32: Optional[Iterable[int]] = ..., + repeated_uint64: Optional[Iterable[int]] = ..., + repeated_sint32: Optional[Iterable[int]] = ..., + repeated_sint64: Optional[Iterable[int]] = ..., + repeated_fixed32: Optional[Iterable[int]] = ..., + repeated_fixed64: Optional[Iterable[int]] = ..., + repeated_sfixed32: Optional[Iterable[int]] = ..., + repeated_sfixed64: Optional[Iterable[int]] = ..., + repeated_float: Optional[Iterable[float]] = ..., + repeated_double: Optional[Iterable[float]] = ..., + repeated_bool: Optional[Iterable[bool]] = ..., + repeated_string: Optional[Iterable[Text]] = ..., + repeated_bytes: Optional[Iterable[bytes]] = ..., + repeatedgroup: Optional[Iterable[TestAllTypes.RepeatedGroup]] = ..., + repeated_nested_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., + repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., + repeated_import_message: Optional[Iterable[ImportMessage]] = ..., + repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., + repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., + repeated_import_enum: Optional[Iterable[ImportEnum]] = ..., + repeated_string_piece: Optional[Iterable[Text]] = ..., + repeated_cord: Optional[Iterable[Text]] = ..., + repeated_lazy_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., + default_int32: Optional[int] = ..., + default_int64: Optional[int] = ..., + default_uint32: Optional[int] = ..., + default_uint64: Optional[int] = ..., + default_sint32: Optional[int] = ..., + default_sint64: Optional[int] = ..., + default_fixed32: Optional[int] = ..., + default_fixed64: Optional[int] = ..., + default_sfixed32: Optional[int] = ..., + default_sfixed64: Optional[int] = ..., + default_float: Optional[float] = ..., + default_double: Optional[float] = ..., + default_bool: Optional[bool] = ..., + default_string: Optional[Text] = ..., + default_bytes: Optional[bytes] = ..., + default_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., + default_foreign_enum: Optional[ForeignEnum] = ..., + default_import_enum: Optional[ImportEnum] = ..., + default_string_piece: Optional[Text] = ..., + default_cord: Optional[Text] = ..., + oneof_uint32: Optional[int] = ..., + oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., + oneof_string: Optional[Text] = ..., + oneof_bytes: Optional[bytes] = ..., + lazy_oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., + ) -> None: ... class ForeignMessage(Message): c: int - - def __init__(self, - c: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... - + def __init__(self, c: Optional[int] = ...) -> None: ... class TestNoArenaMessage(Message): - @property def arena_message(self) -> ArenaMessage: ... - - def __init__(self, - arena_message: Optional[ArenaMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNoArenaMessage: ... + def __init__(self, arena_message: Optional[ArenaMessage] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_no_generic_services_pb2.pyi b/third_party/2and3/google/protobuf/unittest_no_generic_services_pb2.pyi index b65863b1fe16..2a9b7ae18052 100644 --- a/third_party/2and3/google/protobuf/unittest_no_generic_services_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_no_generic_services_pb2.pyi @@ -1,40 +1,20 @@ -from google.protobuf.message import ( - Message, -) -from typing import ( - List, - Optional, - Tuple, - cast, -) - +from google.protobuf.message import Message +from typing import List, Optional, Tuple, cast class TestEnum(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestEnum]]: ... - FOO: TestEnum - class TestMessage(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessage: ... + def __init__(self, a: Optional[int] = ...) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_pb2.pyi b/third_party/2and3/google/protobuf/unittest_pb2.pyi index 7f052577d350..26bc91730d64 100644 --- a/third_party/2and3/google/protobuf/unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_pb2.pyi @@ -1,92 +1,55 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.unittest_import_pb2 import ( - ImportEnum, - ImportMessage, -) -from google.protobuf.unittest_import_public_pb2 import ( - PublicImportMessage, -) -from typing import ( - Iterable, - List, - Mapping, - MutableMapping, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from google.protobuf.unittest_import_pb2 import ImportEnum, ImportMessage +from google.protobuf.unittest_import_public_pb2 import PublicImportMessage +from typing import Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, cast class ForeignEnum(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> ForeignEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[ForeignEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, ForeignEnum]]: ... - FOREIGN_FOO: ForeignEnum FOREIGN_BAR: ForeignEnum FOREIGN_BAZ: ForeignEnum - class TestEnumWithDupValue(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestEnumWithDupValue: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestEnumWithDupValue]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestEnumWithDupValue]]: ... - FOO1: TestEnumWithDupValue BAR1: TestEnumWithDupValue BAZ: TestEnumWithDupValue FOO2: TestEnumWithDupValue BAR2: TestEnumWithDupValue - class TestSparseEnum(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestSparseEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestSparseEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestSparseEnum]]: ... - SPARSE_A: TestSparseEnum SPARSE_B: TestSparseEnum SPARSE_C: TestSparseEnum @@ -95,57 +58,31 @@ SPARSE_E: TestSparseEnum SPARSE_F: TestSparseEnum SPARSE_G: TestSparseEnum - class TestAllTypes(Message): class NestedEnum(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestAllTypes.NestedEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestAllTypes.NestedEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestAllTypes.NestedEnum]]: ... FOO: TestAllTypes.NestedEnum BAR: TestAllTypes.NestedEnum BAZ: TestAllTypes.NestedEnum NEG: TestAllTypes.NestedEnum - class NestedMessage(Message): bb: int - - def __init__(self, - bb: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.NestedMessage: ... - + def __init__(self, bb: Optional[int] = ...) -> None: ... class OptionalGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.OptionalGroup: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class RepeatedGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.RepeatedGroup: ... + def __init__(self, a: Optional[int] = ...) -> None: ... optional_int32: int optional_int64: int optional_uint32: int @@ -209,278 +146,169 @@ class TestAllTypes(Message): oneof_uint32: int oneof_string: Text oneof_bytes: bytes - @property def optionalgroup(self) -> TestAllTypes.OptionalGroup: ... - @property def optional_nested_message(self) -> TestAllTypes.NestedMessage: ... - @property def optional_foreign_message(self) -> ForeignMessage: ... - @property def optional_import_message(self) -> ImportMessage: ... - @property def optional_public_import_message(self) -> PublicImportMessage: ... - @property def optional_lazy_message(self) -> TestAllTypes.NestedMessage: ... - @property - def repeatedgroup( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.RepeatedGroup]: ... - + def repeatedgroup(self) -> RepeatedCompositeFieldContainer[TestAllTypes.RepeatedGroup]: ... @property - def repeated_nested_message( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... - + def repeated_nested_message(self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... @property - def repeated_foreign_message( - self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... - + def repeated_foreign_message(self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... @property - def repeated_import_message( - self) -> RepeatedCompositeFieldContainer[ImportMessage]: ... - + def repeated_import_message(self) -> RepeatedCompositeFieldContainer[ImportMessage]: ... @property - def repeated_lazy_message( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... - + def repeated_lazy_message(self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... @property def oneof_nested_message(self) -> TestAllTypes.NestedMessage: ... - - def __init__(self, - optional_int32: Optional[int] = ..., - optional_int64: Optional[int] = ..., - optional_uint32: Optional[int] = ..., - optional_uint64: Optional[int] = ..., - optional_sint32: Optional[int] = ..., - optional_sint64: Optional[int] = ..., - optional_fixed32: Optional[int] = ..., - optional_fixed64: Optional[int] = ..., - optional_sfixed32: Optional[int] = ..., - optional_sfixed64: Optional[int] = ..., - optional_float: Optional[float] = ..., - optional_double: Optional[float] = ..., - optional_bool: Optional[bool] = ..., - optional_string: Optional[Text] = ..., - optional_bytes: Optional[bytes] = ..., - optionalgroup: Optional[TestAllTypes.OptionalGroup] = ..., - optional_nested_message: Optional[TestAllTypes.NestedMessage] = ..., - optional_foreign_message: Optional[ForeignMessage] = ..., - optional_import_message: Optional[ImportMessage] = ..., - optional_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., - optional_foreign_enum: Optional[ForeignEnum] = ..., - optional_import_enum: Optional[ImportEnum] = ..., - optional_string_piece: Optional[Text] = ..., - optional_cord: Optional[Text] = ..., - optional_public_import_message: Optional[PublicImportMessage] = ..., - optional_lazy_message: Optional[TestAllTypes.NestedMessage] = ..., - repeated_int32: Optional[Iterable[int]] = ..., - repeated_int64: Optional[Iterable[int]] = ..., - repeated_uint32: Optional[Iterable[int]] = ..., - repeated_uint64: Optional[Iterable[int]] = ..., - repeated_sint32: Optional[Iterable[int]] = ..., - repeated_sint64: Optional[Iterable[int]] = ..., - repeated_fixed32: Optional[Iterable[int]] = ..., - repeated_fixed64: Optional[Iterable[int]] = ..., - repeated_sfixed32: Optional[Iterable[int]] = ..., - repeated_sfixed64: Optional[Iterable[int]] = ..., - repeated_float: Optional[Iterable[float]] = ..., - repeated_double: Optional[Iterable[float]] = ..., - repeated_bool: Optional[Iterable[bool]] = ..., - repeated_string: Optional[Iterable[Text]] = ..., - repeated_bytes: Optional[Iterable[bytes]] = ..., - repeatedgroup: Optional[Iterable[TestAllTypes.RepeatedGroup]] = ..., - repeated_nested_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., - repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., - repeated_import_message: Optional[Iterable[ImportMessage]] = ..., - repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., - repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., - repeated_import_enum: Optional[Iterable[ImportEnum]] = ..., - repeated_string_piece: Optional[Iterable[Text]] = ..., - repeated_cord: Optional[Iterable[Text]] = ..., - repeated_lazy_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., - default_int32: Optional[int] = ..., - default_int64: Optional[int] = ..., - default_uint32: Optional[int] = ..., - default_uint64: Optional[int] = ..., - default_sint32: Optional[int] = ..., - default_sint64: Optional[int] = ..., - default_fixed32: Optional[int] = ..., - default_fixed64: Optional[int] = ..., - default_sfixed32: Optional[int] = ..., - default_sfixed64: Optional[int] = ..., - default_float: Optional[float] = ..., - default_double: Optional[float] = ..., - default_bool: Optional[bool] = ..., - default_string: Optional[Text] = ..., - default_bytes: Optional[bytes] = ..., - default_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., - default_foreign_enum: Optional[ForeignEnum] = ..., - default_import_enum: Optional[ImportEnum] = ..., - default_string_piece: Optional[Text] = ..., - default_cord: Optional[Text] = ..., - oneof_uint32: Optional[int] = ..., - oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., - oneof_string: Optional[Text] = ..., - oneof_bytes: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes: ... - + def __init__( + self, + optional_int32: Optional[int] = ..., + optional_int64: Optional[int] = ..., + optional_uint32: Optional[int] = ..., + optional_uint64: Optional[int] = ..., + optional_sint32: Optional[int] = ..., + optional_sint64: Optional[int] = ..., + optional_fixed32: Optional[int] = ..., + optional_fixed64: Optional[int] = ..., + optional_sfixed32: Optional[int] = ..., + optional_sfixed64: Optional[int] = ..., + optional_float: Optional[float] = ..., + optional_double: Optional[float] = ..., + optional_bool: Optional[bool] = ..., + optional_string: Optional[Text] = ..., + optional_bytes: Optional[bytes] = ..., + optionalgroup: Optional[TestAllTypes.OptionalGroup] = ..., + optional_nested_message: Optional[TestAllTypes.NestedMessage] = ..., + optional_foreign_message: Optional[ForeignMessage] = ..., + optional_import_message: Optional[ImportMessage] = ..., + optional_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., + optional_foreign_enum: Optional[ForeignEnum] = ..., + optional_import_enum: Optional[ImportEnum] = ..., + optional_string_piece: Optional[Text] = ..., + optional_cord: Optional[Text] = ..., + optional_public_import_message: Optional[PublicImportMessage] = ..., + optional_lazy_message: Optional[TestAllTypes.NestedMessage] = ..., + repeated_int32: Optional[Iterable[int]] = ..., + repeated_int64: Optional[Iterable[int]] = ..., + repeated_uint32: Optional[Iterable[int]] = ..., + repeated_uint64: Optional[Iterable[int]] = ..., + repeated_sint32: Optional[Iterable[int]] = ..., + repeated_sint64: Optional[Iterable[int]] = ..., + repeated_fixed32: Optional[Iterable[int]] = ..., + repeated_fixed64: Optional[Iterable[int]] = ..., + repeated_sfixed32: Optional[Iterable[int]] = ..., + repeated_sfixed64: Optional[Iterable[int]] = ..., + repeated_float: Optional[Iterable[float]] = ..., + repeated_double: Optional[Iterable[float]] = ..., + repeated_bool: Optional[Iterable[bool]] = ..., + repeated_string: Optional[Iterable[Text]] = ..., + repeated_bytes: Optional[Iterable[bytes]] = ..., + repeatedgroup: Optional[Iterable[TestAllTypes.RepeatedGroup]] = ..., + repeated_nested_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., + repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., + repeated_import_message: Optional[Iterable[ImportMessage]] = ..., + repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., + repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., + repeated_import_enum: Optional[Iterable[ImportEnum]] = ..., + repeated_string_piece: Optional[Iterable[Text]] = ..., + repeated_cord: Optional[Iterable[Text]] = ..., + repeated_lazy_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., + default_int32: Optional[int] = ..., + default_int64: Optional[int] = ..., + default_uint32: Optional[int] = ..., + default_uint64: Optional[int] = ..., + default_sint32: Optional[int] = ..., + default_sint64: Optional[int] = ..., + default_fixed32: Optional[int] = ..., + default_fixed64: Optional[int] = ..., + default_sfixed32: Optional[int] = ..., + default_sfixed64: Optional[int] = ..., + default_float: Optional[float] = ..., + default_double: Optional[float] = ..., + default_bool: Optional[bool] = ..., + default_string: Optional[Text] = ..., + default_bytes: Optional[bytes] = ..., + default_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., + default_foreign_enum: Optional[ForeignEnum] = ..., + default_import_enum: Optional[ImportEnum] = ..., + default_string_piece: Optional[Text] = ..., + default_cord: Optional[Text] = ..., + oneof_uint32: Optional[int] = ..., + oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., + oneof_string: Optional[Text] = ..., + oneof_bytes: Optional[bytes] = ..., + ) -> None: ... class NestedTestAllTypes(Message): - @property def child(self) -> NestedTestAllTypes: ... - @property def payload(self) -> TestAllTypes: ... - @property - def repeated_child( - self) -> RepeatedCompositeFieldContainer[NestedTestAllTypes]: ... - - def __init__(self, - child: Optional[NestedTestAllTypes] = ..., - payload: Optional[TestAllTypes] = ..., - repeated_child: Optional[Iterable[NestedTestAllTypes]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> NestedTestAllTypes: ... - + def repeated_child(self) -> RepeatedCompositeFieldContainer[NestedTestAllTypes]: ... + def __init__( + self, + child: Optional[NestedTestAllTypes] = ..., + payload: Optional[TestAllTypes] = ..., + repeated_child: Optional[Iterable[NestedTestAllTypes]] = ..., + ) -> None: ... class TestDeprecatedFields(Message): deprecated_int32: int deprecated_int32_in_oneof: int - - def __init__(self, - deprecated_int32: Optional[int] = ..., - deprecated_int32_in_oneof: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestDeprecatedFields: ... - + def __init__(self, deprecated_int32: Optional[int] = ..., deprecated_int32_in_oneof: Optional[int] = ...) -> None: ... class TestDeprecatedMessage(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestDeprecatedMessage: ... - + def __init__(self,) -> None: ... class ForeignMessage(Message): c: int d: int - - def __init__(self, - c: Optional[int] = ..., - d: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... - + def __init__(self, c: Optional[int] = ..., d: Optional[int] = ...) -> None: ... class TestReservedFields(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestReservedFields: ... - + def __init__(self,) -> None: ... class TestAllExtensions(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllExtensions: ... - + def __init__(self,) -> None: ... class OptionalGroup_extension(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> OptionalGroup_extension: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class RepeatedGroup_extension(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> RepeatedGroup_extension: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class TestGroup(Message): class OptionalGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestGroup.OptionalGroup: ... + def __init__(self, a: Optional[int] = ...) -> None: ... optional_foreign_enum: ForeignEnum - @property def optionalgroup(self) -> TestGroup.OptionalGroup: ... - - def __init__(self, - optionalgroup: Optional[TestGroup.OptionalGroup] = ..., - optional_foreign_enum: Optional[ForeignEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestGroup: ... - + def __init__( + self, optionalgroup: Optional[TestGroup.OptionalGroup] = ..., optional_foreign_enum: Optional[ForeignEnum] = ... + ) -> None: ... class TestGroupExtension(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestGroupExtension: ... - + def __init__(self,) -> None: ... class TestNestedExtension(Message): class OptionalGroup_extension(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestNestedExtension.OptionalGroup_extension: ... - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedExtension: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... + def __init__(self,) -> None: ... class TestRequired(Message): a: int @@ -516,342 +344,173 @@ class TestRequired(Message): dummy31: int dummy32: int c: int - - def __init__(self, - a: int, - b: int, - c: int, - dummy2: Optional[int] = ..., - dummy4: Optional[int] = ..., - dummy5: Optional[int] = ..., - dummy6: Optional[int] = ..., - dummy7: Optional[int] = ..., - dummy8: Optional[int] = ..., - dummy9: Optional[int] = ..., - dummy10: Optional[int] = ..., - dummy11: Optional[int] = ..., - dummy12: Optional[int] = ..., - dummy13: Optional[int] = ..., - dummy14: Optional[int] = ..., - dummy15: Optional[int] = ..., - dummy16: Optional[int] = ..., - dummy17: Optional[int] = ..., - dummy18: Optional[int] = ..., - dummy19: Optional[int] = ..., - dummy20: Optional[int] = ..., - dummy21: Optional[int] = ..., - dummy22: Optional[int] = ..., - dummy23: Optional[int] = ..., - dummy24: Optional[int] = ..., - dummy25: Optional[int] = ..., - dummy26: Optional[int] = ..., - dummy27: Optional[int] = ..., - dummy28: Optional[int] = ..., - dummy29: Optional[int] = ..., - dummy30: Optional[int] = ..., - dummy31: Optional[int] = ..., - dummy32: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRequired: ... - + def __init__( + self, + a: int, + b: int, + c: int, + dummy2: Optional[int] = ..., + dummy4: Optional[int] = ..., + dummy5: Optional[int] = ..., + dummy6: Optional[int] = ..., + dummy7: Optional[int] = ..., + dummy8: Optional[int] = ..., + dummy9: Optional[int] = ..., + dummy10: Optional[int] = ..., + dummy11: Optional[int] = ..., + dummy12: Optional[int] = ..., + dummy13: Optional[int] = ..., + dummy14: Optional[int] = ..., + dummy15: Optional[int] = ..., + dummy16: Optional[int] = ..., + dummy17: Optional[int] = ..., + dummy18: Optional[int] = ..., + dummy19: Optional[int] = ..., + dummy20: Optional[int] = ..., + dummy21: Optional[int] = ..., + dummy22: Optional[int] = ..., + dummy23: Optional[int] = ..., + dummy24: Optional[int] = ..., + dummy25: Optional[int] = ..., + dummy26: Optional[int] = ..., + dummy27: Optional[int] = ..., + dummy28: Optional[int] = ..., + dummy29: Optional[int] = ..., + dummy30: Optional[int] = ..., + dummy31: Optional[int] = ..., + dummy32: Optional[int] = ..., + ) -> None: ... class TestRequiredForeign(Message): dummy: int - @property def optional_message(self) -> TestRequired: ... - @property - def repeated_message( - self) -> RepeatedCompositeFieldContainer[TestRequired]: ... - - def __init__(self, - optional_message: Optional[TestRequired] = ..., - repeated_message: Optional[Iterable[TestRequired]] = ..., - dummy: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRequiredForeign: ... - + def repeated_message(self) -> RepeatedCompositeFieldContainer[TestRequired]: ... + def __init__( + self, + optional_message: Optional[TestRequired] = ..., + repeated_message: Optional[Iterable[TestRequired]] = ..., + dummy: Optional[int] = ..., + ) -> None: ... class TestRequiredMessage(Message): - @property def optional_message(self) -> TestRequired: ... - @property - def repeated_message( - self) -> RepeatedCompositeFieldContainer[TestRequired]: ... - + def repeated_message(self) -> RepeatedCompositeFieldContainer[TestRequired]: ... @property def required_message(self) -> TestRequired: ... - - def __init__(self, - required_message: TestRequired, - optional_message: Optional[TestRequired] = ..., - repeated_message: Optional[Iterable[TestRequired]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRequiredMessage: ... - + def __init__( + self, + required_message: TestRequired, + optional_message: Optional[TestRequired] = ..., + repeated_message: Optional[Iterable[TestRequired]] = ..., + ) -> None: ... class TestForeignNested(Message): - @property def foreign_nested(self) -> TestAllTypes.NestedMessage: ... - - def __init__(self, - foreign_nested: Optional[TestAllTypes.NestedMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestForeignNested: ... - + def __init__(self, foreign_nested: Optional[TestAllTypes.NestedMessage] = ...) -> None: ... class TestEmptyMessage(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEmptyMessage: ... - + def __init__(self,) -> None: ... class TestEmptyMessageWithExtensions(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEmptyMessageWithExtensions: ... - + def __init__(self,) -> None: ... class TestMultipleExtensionRanges(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMultipleExtensionRanges: ... - + def __init__(self,) -> None: ... class TestReallyLargeTagNumber(Message): a: int bb: int - - def __init__(self, - a: Optional[int] = ..., - bb: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestReallyLargeTagNumber: ... - + def __init__(self, a: Optional[int] = ..., bb: Optional[int] = ...) -> None: ... class TestRecursiveMessage(Message): i: int - @property def a(self) -> TestRecursiveMessage: ... - - def __init__(self, - a: Optional[TestRecursiveMessage] = ..., - i: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRecursiveMessage: ... - + def __init__(self, a: Optional[TestRecursiveMessage] = ..., i: Optional[int] = ...) -> None: ... class TestMutualRecursionA(Message): class SubMessage(Message): - @property def b(self) -> TestMutualRecursionB: ... - - def __init__(self, - b: Optional[TestMutualRecursionB] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionA.SubMessage: ... - + def __init__(self, b: Optional[TestMutualRecursionB] = ...) -> None: ... class SubGroup(Message): - @property def sub_message(self) -> TestMutualRecursionA.SubMessage: ... - @property def not_in_this_scc(self) -> TestAllTypes: ... - - def __init__(self, - sub_message: Optional[TestMutualRecursionA.SubMessage] = ..., - not_in_this_scc: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionA.SubGroup: ... - + def __init__( + self, sub_message: Optional[TestMutualRecursionA.SubMessage] = ..., not_in_this_scc: Optional[TestAllTypes] = ... + ) -> None: ... @property def bb(self) -> TestMutualRecursionB: ... - @property def subgroup(self) -> TestMutualRecursionA.SubGroup: ... - - def __init__(self, - bb: Optional[TestMutualRecursionB] = ..., - subgroup: Optional[TestMutualRecursionA.SubGroup] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionA: ... - + def __init__( + self, bb: Optional[TestMutualRecursionB] = ..., subgroup: Optional[TestMutualRecursionA.SubGroup] = ... + ) -> None: ... class TestMutualRecursionB(Message): optional_int32: int - @property def a(self) -> TestMutualRecursionA: ... - - def __init__(self, - a: Optional[TestMutualRecursionA] = ..., - optional_int32: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionB: ... - + def __init__(self, a: Optional[TestMutualRecursionA] = ..., optional_int32: Optional[int] = ...) -> None: ... class TestIsInitialized(Message): class SubMessage(Message): class SubGroup(Message): i: int - - def __init__(self, - i: int, - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestIsInitialized.SubMessage.SubGroup: ... - + def __init__(self, i: int) -> None: ... @property def subgroup(self) -> TestIsInitialized.SubMessage.SubGroup: ... - - def __init__(self, - subgroup: Optional[TestIsInitialized.SubMessage.SubGroup] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestIsInitialized.SubMessage: ... - + def __init__(self, subgroup: Optional[TestIsInitialized.SubMessage.SubGroup] = ...) -> None: ... @property def sub_message(self) -> TestIsInitialized.SubMessage: ... - - def __init__(self, - sub_message: Optional[TestIsInitialized.SubMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestIsInitialized: ... - + def __init__(self, sub_message: Optional[TestIsInitialized.SubMessage] = ...) -> None: ... class TestDupFieldNumber(Message): class Foo(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestDupFieldNumber.Foo: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class Bar(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestDupFieldNumber.Bar: ... + def __init__(self, a: Optional[int] = ...) -> None: ... a: int - @property def foo(self) -> TestDupFieldNumber.Foo: ... - @property def bar(self) -> TestDupFieldNumber.Bar: ... - - def __init__(self, - a: Optional[int] = ..., - foo: Optional[TestDupFieldNumber.Foo] = ..., - bar: Optional[TestDupFieldNumber.Bar] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestDupFieldNumber: ... - + def __init__( + self, a: Optional[int] = ..., foo: Optional[TestDupFieldNumber.Foo] = ..., bar: Optional[TestDupFieldNumber.Bar] = ... + ) -> None: ... class TestEagerMessage(Message): - @property def sub_message(self) -> TestAllTypes: ... - - def __init__(self, - sub_message: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEagerMessage: ... - + def __init__(self, sub_message: Optional[TestAllTypes] = ...) -> None: ... class TestLazyMessage(Message): - @property def sub_message(self) -> TestAllTypes: ... - - def __init__(self, - sub_message: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestLazyMessage: ... - + def __init__(self, sub_message: Optional[TestAllTypes] = ...) -> None: ... class TestNestedMessageHasBits(Message): class NestedMessage(Message): nestedmessage_repeated_int32: RepeatedScalarFieldContainer[int] - @property - def nestedmessage_repeated_foreignmessage( - self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... - - def __init__(self, - nestedmessage_repeated_int32: Optional[Iterable[int]] = ..., - nestedmessage_repeated_foreignmessage: Optional[Iterable[ForeignMessage]] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestNestedMessageHasBits.NestedMessage: ... - + def nestedmessage_repeated_foreignmessage(self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... + def __init__( + self, + nestedmessage_repeated_int32: Optional[Iterable[int]] = ..., + nestedmessage_repeated_foreignmessage: Optional[Iterable[ForeignMessage]] = ..., + ) -> None: ... @property - def optional_nested_message( - self) -> TestNestedMessageHasBits.NestedMessage: ... - - def __init__(self, - optional_nested_message: Optional[TestNestedMessageHasBits.NestedMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMessageHasBits: ... - + def optional_nested_message(self) -> TestNestedMessageHasBits.NestedMessage: ... + def __init__(self, optional_nested_message: Optional[TestNestedMessageHasBits.NestedMessage] = ...) -> None: ... class TestCamelCaseFieldNames(Message): PrimitiveField: int @@ -864,94 +523,54 @@ class TestCamelCaseFieldNames(Message): RepeatedEnumField: RepeatedScalarFieldContainer[ForeignEnum] RepeatedStringPieceField: RepeatedScalarFieldContainer[Text] RepeatedCordField: RepeatedScalarFieldContainer[Text] - @property def MessageField(self) -> ForeignMessage: ... - @property - def RepeatedMessageField( - self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... - - def __init__(self, - PrimitiveField: Optional[int] = ..., - StringField: Optional[Text] = ..., - EnumField: Optional[ForeignEnum] = ..., - MessageField: Optional[ForeignMessage] = ..., - StringPieceField: Optional[Text] = ..., - CordField: Optional[Text] = ..., - RepeatedPrimitiveField: Optional[Iterable[int]] = ..., - RepeatedStringField: Optional[Iterable[Text]] = ..., - RepeatedEnumField: Optional[Iterable[ForeignEnum]] = ..., - RepeatedMessageField: Optional[Iterable[ForeignMessage]] = ..., - RepeatedStringPieceField: Optional[Iterable[Text]] = ..., - RepeatedCordField: Optional[Iterable[Text]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestCamelCaseFieldNames: ... - + def RepeatedMessageField(self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... + def __init__( + self, + PrimitiveField: Optional[int] = ..., + StringField: Optional[Text] = ..., + EnumField: Optional[ForeignEnum] = ..., + MessageField: Optional[ForeignMessage] = ..., + StringPieceField: Optional[Text] = ..., + CordField: Optional[Text] = ..., + RepeatedPrimitiveField: Optional[Iterable[int]] = ..., + RepeatedStringField: Optional[Iterable[Text]] = ..., + RepeatedEnumField: Optional[Iterable[ForeignEnum]] = ..., + RepeatedMessageField: Optional[Iterable[ForeignMessage]] = ..., + RepeatedStringPieceField: Optional[Iterable[Text]] = ..., + RepeatedCordField: Optional[Iterable[Text]] = ..., + ) -> None: ... class TestFieldOrderings(Message): class NestedMessage(Message): oo: int bb: int - - def __init__(self, - oo: Optional[int] = ..., - bb: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestFieldOrderings.NestedMessage: ... + def __init__(self, oo: Optional[int] = ..., bb: Optional[int] = ...) -> None: ... my_string: Text my_int: int my_float: float - @property def optional_nested_message(self) -> TestFieldOrderings.NestedMessage: ... - - def __init__(self, - my_string: Optional[Text] = ..., - my_int: Optional[int] = ..., - my_float: Optional[float] = ..., - optional_nested_message: Optional[TestFieldOrderings.NestedMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestFieldOrderings: ... - + def __init__( + self, + my_string: Optional[Text] = ..., + my_int: Optional[int] = ..., + my_float: Optional[float] = ..., + optional_nested_message: Optional[TestFieldOrderings.NestedMessage] = ..., + ) -> None: ... class TestExtensionOrderings1(Message): my_string: Text - - def __init__(self, - my_string: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestExtensionOrderings1: ... - + def __init__(self, my_string: Optional[Text] = ...) -> None: ... class TestExtensionOrderings2(Message): class TestExtensionOrderings3(Message): my_string: Text - - def __init__(self, - my_string: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestExtensionOrderings2.TestExtensionOrderings3: ... + def __init__(self, my_string: Optional[Text] = ...) -> None: ... my_string: Text - - def __init__(self, - my_string: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestExtensionOrderings2: ... - + def __init__(self, my_string: Optional[Text] = ...) -> None: ... class TestExtremeDefaultValues(Message): escaped_bytes: bytes @@ -981,259 +600,138 @@ class TestExtremeDefaultValues(Message): string_piece_with_zero: Text cord_with_zero: Text replacement_string: Text - - def __init__(self, - escaped_bytes: Optional[bytes] = ..., - large_uint32: Optional[int] = ..., - large_uint64: Optional[int] = ..., - small_int32: Optional[int] = ..., - small_int64: Optional[int] = ..., - really_small_int32: Optional[int] = ..., - really_small_int64: Optional[int] = ..., - utf8_string: Optional[Text] = ..., - zero_float: Optional[float] = ..., - one_float: Optional[float] = ..., - small_float: Optional[float] = ..., - negative_one_float: Optional[float] = ..., - negative_float: Optional[float] = ..., - large_float: Optional[float] = ..., - small_negative_float: Optional[float] = ..., - inf_double: Optional[float] = ..., - neg_inf_double: Optional[float] = ..., - nan_double: Optional[float] = ..., - inf_float: Optional[float] = ..., - neg_inf_float: Optional[float] = ..., - nan_float: Optional[float] = ..., - cpp_trigraph: Optional[Text] = ..., - string_with_zero: Optional[Text] = ..., - bytes_with_zero: Optional[bytes] = ..., - string_piece_with_zero: Optional[Text] = ..., - cord_with_zero: Optional[Text] = ..., - replacement_string: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestExtremeDefaultValues: ... - + def __init__( + self, + escaped_bytes: Optional[bytes] = ..., + large_uint32: Optional[int] = ..., + large_uint64: Optional[int] = ..., + small_int32: Optional[int] = ..., + small_int64: Optional[int] = ..., + really_small_int32: Optional[int] = ..., + really_small_int64: Optional[int] = ..., + utf8_string: Optional[Text] = ..., + zero_float: Optional[float] = ..., + one_float: Optional[float] = ..., + small_float: Optional[float] = ..., + negative_one_float: Optional[float] = ..., + negative_float: Optional[float] = ..., + large_float: Optional[float] = ..., + small_negative_float: Optional[float] = ..., + inf_double: Optional[float] = ..., + neg_inf_double: Optional[float] = ..., + nan_double: Optional[float] = ..., + inf_float: Optional[float] = ..., + neg_inf_float: Optional[float] = ..., + nan_float: Optional[float] = ..., + cpp_trigraph: Optional[Text] = ..., + string_with_zero: Optional[Text] = ..., + bytes_with_zero: Optional[bytes] = ..., + string_piece_with_zero: Optional[Text] = ..., + cord_with_zero: Optional[Text] = ..., + replacement_string: Optional[Text] = ..., + ) -> None: ... class SparseEnumMessage(Message): sparse_enum: TestSparseEnum - - def __init__(self, - sparse_enum: Optional[TestSparseEnum] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> SparseEnumMessage: ... - + def __init__(self, sparse_enum: Optional[TestSparseEnum] = ...) -> None: ... class OneString(Message): data: Text - - def __init__(self, - data: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> OneString: ... - + def __init__(self, data: Optional[Text] = ...) -> None: ... class MoreString(Message): data: RepeatedScalarFieldContainer[Text] - - def __init__(self, - data: Optional[Iterable[Text]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MoreString: ... - + def __init__(self, data: Optional[Iterable[Text]] = ...) -> None: ... class OneBytes(Message): data: bytes - - def __init__(self, - data: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> OneBytes: ... - + def __init__(self, data: Optional[bytes] = ...) -> None: ... class MoreBytes(Message): data: RepeatedScalarFieldContainer[bytes] - - def __init__(self, - data: Optional[Iterable[bytes]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MoreBytes: ... - + def __init__(self, data: Optional[Iterable[bytes]] = ...) -> None: ... class Int32Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Int32Message: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class Uint32Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Uint32Message: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class Int64Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Int64Message: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class Uint64Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Uint64Message: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class BoolMessage(Message): data: bool - - def __init__(self, - data: Optional[bool] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> BoolMessage: ... - + def __init__(self, data: Optional[bool] = ...) -> None: ... class TestOneof(Message): class FooGroup(Message): a: int b: Text - - def __init__(self, - a: Optional[int] = ..., - b: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestOneof.FooGroup: ... + def __init__(self, a: Optional[int] = ..., b: Optional[Text] = ...) -> None: ... foo_int: int foo_string: Text - @property def foo_message(self) -> TestAllTypes: ... - @property def foogroup(self) -> TestOneof.FooGroup: ... - - def __init__(self, - foo_int: Optional[int] = ..., - foo_string: Optional[Text] = ..., - foo_message: Optional[TestAllTypes] = ..., - foogroup: Optional[TestOneof.FooGroup] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestOneof: ... - + def __init__( + self, + foo_int: Optional[int] = ..., + foo_string: Optional[Text] = ..., + foo_message: Optional[TestAllTypes] = ..., + foogroup: Optional[TestOneof.FooGroup] = ..., + ) -> None: ... class TestOneofBackwardsCompatible(Message): class FooGroup(Message): a: int b: Text - - def __init__(self, - a: Optional[int] = ..., - b: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestOneofBackwardsCompatible.FooGroup: ... + def __init__(self, a: Optional[int] = ..., b: Optional[Text] = ...) -> None: ... foo_int: int foo_string: Text - @property def foo_message(self) -> TestAllTypes: ... - @property def foogroup(self) -> TestOneofBackwardsCompatible.FooGroup: ... - - def __init__(self, - foo_int: Optional[int] = ..., - foo_string: Optional[Text] = ..., - foo_message: Optional[TestAllTypes] = ..., - foogroup: Optional[TestOneofBackwardsCompatible.FooGroup] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestOneofBackwardsCompatible: ... - + def __init__( + self, + foo_int: Optional[int] = ..., + foo_string: Optional[Text] = ..., + foo_message: Optional[TestAllTypes] = ..., + foogroup: Optional[TestOneofBackwardsCompatible.FooGroup] = ..., + ) -> None: ... class TestOneof2(Message): class NestedEnum(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestOneof2.NestedEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestOneof2.NestedEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestOneof2.NestedEnum]]: ... FOO: TestOneof2.NestedEnum BAR: TestOneof2.NestedEnum BAZ: TestOneof2.NestedEnum - class FooGroup(Message): a: int b: Text - - def __init__(self, - a: Optional[int] = ..., - b: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestOneof2.FooGroup: ... - + def __init__(self, a: Optional[int] = ..., b: Optional[Text] = ...) -> None: ... class NestedMessage(Message): qux_int: int corge_int: RepeatedScalarFieldContainer[int] - - def __init__(self, - qux_int: Optional[int] = ..., - corge_int: Optional[Iterable[int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestOneof2.NestedMessage: ... + def __init__(self, qux_int: Optional[int] = ..., corge_int: Optional[Iterable[int]] = ...) -> None: ... foo_int: int foo_string: Text foo_cord: Text @@ -1248,65 +746,47 @@ class TestOneof2(Message): bar_enum: TestOneof2.NestedEnum baz_int: int baz_string: Text - @property def foo_message(self) -> TestOneof2.NestedMessage: ... - @property def foogroup(self) -> TestOneof2.FooGroup: ... - @property def foo_lazy_message(self) -> TestOneof2.NestedMessage: ... - - def __init__(self, - foo_int: Optional[int] = ..., - foo_string: Optional[Text] = ..., - foo_cord: Optional[Text] = ..., - foo_string_piece: Optional[Text] = ..., - foo_bytes: Optional[bytes] = ..., - foo_enum: Optional[TestOneof2.NestedEnum] = ..., - foo_message: Optional[TestOneof2.NestedMessage] = ..., - foogroup: Optional[TestOneof2.FooGroup] = ..., - foo_lazy_message: Optional[TestOneof2.NestedMessage] = ..., - bar_int: Optional[int] = ..., - bar_string: Optional[Text] = ..., - bar_cord: Optional[Text] = ..., - bar_string_piece: Optional[Text] = ..., - bar_bytes: Optional[bytes] = ..., - bar_enum: Optional[TestOneof2.NestedEnum] = ..., - baz_int: Optional[int] = ..., - baz_string: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestOneof2: ... - + def __init__( + self, + foo_int: Optional[int] = ..., + foo_string: Optional[Text] = ..., + foo_cord: Optional[Text] = ..., + foo_string_piece: Optional[Text] = ..., + foo_bytes: Optional[bytes] = ..., + foo_enum: Optional[TestOneof2.NestedEnum] = ..., + foo_message: Optional[TestOneof2.NestedMessage] = ..., + foogroup: Optional[TestOneof2.FooGroup] = ..., + foo_lazy_message: Optional[TestOneof2.NestedMessage] = ..., + bar_int: Optional[int] = ..., + bar_string: Optional[Text] = ..., + bar_cord: Optional[Text] = ..., + bar_string_piece: Optional[Text] = ..., + bar_bytes: Optional[bytes] = ..., + bar_enum: Optional[TestOneof2.NestedEnum] = ..., + baz_int: Optional[int] = ..., + baz_string: Optional[Text] = ..., + ) -> None: ... class TestRequiredOneof(Message): class NestedMessage(Message): required_double: float - - def __init__(self, - required_double: float, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRequiredOneof.NestedMessage: ... + def __init__(self, required_double: float) -> None: ... foo_int: int foo_string: Text - @property def foo_message(self) -> TestRequiredOneof.NestedMessage: ... - - def __init__(self, - foo_int: Optional[int] = ..., - foo_string: Optional[Text] = ..., - foo_message: Optional[TestRequiredOneof.NestedMessage] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRequiredOneof: ... - + def __init__( + self, + foo_int: Optional[int] = ..., + foo_string: Optional[Text] = ..., + foo_message: Optional[TestRequiredOneof.NestedMessage] = ..., + ) -> None: ... class TestPackedTypes(Message): packed_int32: RepeatedScalarFieldContainer[int] @@ -1323,27 +803,23 @@ class TestPackedTypes(Message): packed_double: RepeatedScalarFieldContainer[float] packed_bool: RepeatedScalarFieldContainer[bool] packed_enum: RepeatedScalarFieldContainer[ForeignEnum] - - def __init__(self, - packed_int32: Optional[Iterable[int]] = ..., - packed_int64: Optional[Iterable[int]] = ..., - packed_uint32: Optional[Iterable[int]] = ..., - packed_uint64: Optional[Iterable[int]] = ..., - packed_sint32: Optional[Iterable[int]] = ..., - packed_sint64: Optional[Iterable[int]] = ..., - packed_fixed32: Optional[Iterable[int]] = ..., - packed_fixed64: Optional[Iterable[int]] = ..., - packed_sfixed32: Optional[Iterable[int]] = ..., - packed_sfixed64: Optional[Iterable[int]] = ..., - packed_float: Optional[Iterable[float]] = ..., - packed_double: Optional[Iterable[float]] = ..., - packed_bool: Optional[Iterable[bool]] = ..., - packed_enum: Optional[Iterable[ForeignEnum]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestPackedTypes: ... - + def __init__( + self, + packed_int32: Optional[Iterable[int]] = ..., + packed_int64: Optional[Iterable[int]] = ..., + packed_uint32: Optional[Iterable[int]] = ..., + packed_uint64: Optional[Iterable[int]] = ..., + packed_sint32: Optional[Iterable[int]] = ..., + packed_sint64: Optional[Iterable[int]] = ..., + packed_fixed32: Optional[Iterable[int]] = ..., + packed_fixed64: Optional[Iterable[int]] = ..., + packed_sfixed32: Optional[Iterable[int]] = ..., + packed_sfixed64: Optional[Iterable[int]] = ..., + packed_float: Optional[Iterable[float]] = ..., + packed_double: Optional[Iterable[float]] = ..., + packed_bool: Optional[Iterable[bool]] = ..., + packed_enum: Optional[Iterable[ForeignEnum]] = ..., + ) -> None: ... class TestUnpackedTypes(Message): unpacked_int32: RepeatedScalarFieldContainer[int] @@ -1360,103 +836,67 @@ class TestUnpackedTypes(Message): unpacked_double: RepeatedScalarFieldContainer[float] unpacked_bool: RepeatedScalarFieldContainer[bool] unpacked_enum: RepeatedScalarFieldContainer[ForeignEnum] - - def __init__(self, - unpacked_int32: Optional[Iterable[int]] = ..., - unpacked_int64: Optional[Iterable[int]] = ..., - unpacked_uint32: Optional[Iterable[int]] = ..., - unpacked_uint64: Optional[Iterable[int]] = ..., - unpacked_sint32: Optional[Iterable[int]] = ..., - unpacked_sint64: Optional[Iterable[int]] = ..., - unpacked_fixed32: Optional[Iterable[int]] = ..., - unpacked_fixed64: Optional[Iterable[int]] = ..., - unpacked_sfixed32: Optional[Iterable[int]] = ..., - unpacked_sfixed64: Optional[Iterable[int]] = ..., - unpacked_float: Optional[Iterable[float]] = ..., - unpacked_double: Optional[Iterable[float]] = ..., - unpacked_bool: Optional[Iterable[bool]] = ..., - unpacked_enum: Optional[Iterable[ForeignEnum]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestUnpackedTypes: ... - + def __init__( + self, + unpacked_int32: Optional[Iterable[int]] = ..., + unpacked_int64: Optional[Iterable[int]] = ..., + unpacked_uint32: Optional[Iterable[int]] = ..., + unpacked_uint64: Optional[Iterable[int]] = ..., + unpacked_sint32: Optional[Iterable[int]] = ..., + unpacked_sint64: Optional[Iterable[int]] = ..., + unpacked_fixed32: Optional[Iterable[int]] = ..., + unpacked_fixed64: Optional[Iterable[int]] = ..., + unpacked_sfixed32: Optional[Iterable[int]] = ..., + unpacked_sfixed64: Optional[Iterable[int]] = ..., + unpacked_float: Optional[Iterable[float]] = ..., + unpacked_double: Optional[Iterable[float]] = ..., + unpacked_bool: Optional[Iterable[bool]] = ..., + unpacked_enum: Optional[Iterable[ForeignEnum]] = ..., + ) -> None: ... class TestPackedExtensions(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestPackedExtensions: ... - + def __init__(self,) -> None: ... class TestUnpackedExtensions(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestUnpackedExtensions: ... - + def __init__(self,) -> None: ... class TestDynamicExtensions(Message): class DynamicEnumType(int): @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestDynamicExtensions.DynamicEnumType: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestDynamicExtensions.DynamicEnumType]: ... - @classmethod - def items(cls) -> List[Tuple[bytes, - TestDynamicExtensions.DynamicEnumType]]: ... + def items(cls) -> List[Tuple[bytes, TestDynamicExtensions.DynamicEnumType]]: ... DYNAMIC_FOO: TestDynamicExtensions.DynamicEnumType DYNAMIC_BAR: TestDynamicExtensions.DynamicEnumType DYNAMIC_BAZ: TestDynamicExtensions.DynamicEnumType - class DynamicMessageType(Message): dynamic_field: int - - def __init__(self, - dynamic_field: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestDynamicExtensions.DynamicMessageType: ... + def __init__(self, dynamic_field: Optional[int] = ...) -> None: ... scalar_extension: int enum_extension: ForeignEnum dynamic_enum_extension: TestDynamicExtensions.DynamicEnumType repeated_extension: RepeatedScalarFieldContainer[Text] packed_extension: RepeatedScalarFieldContainer[int] - @property def message_extension(self) -> ForeignMessage: ... - @property - def dynamic_message_extension( - self) -> TestDynamicExtensions.DynamicMessageType: ... - - def __init__(self, - scalar_extension: Optional[int] = ..., - enum_extension: Optional[ForeignEnum] = ..., - dynamic_enum_extension: Optional[TestDynamicExtensions.DynamicEnumType] = ..., - message_extension: Optional[ForeignMessage] = ..., - dynamic_message_extension: Optional[TestDynamicExtensions.DynamicMessageType] = ..., - repeated_extension: Optional[Iterable[Text]] = ..., - packed_extension: Optional[Iterable[int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestDynamicExtensions: ... - + def dynamic_message_extension(self) -> TestDynamicExtensions.DynamicMessageType: ... + def __init__( + self, + scalar_extension: Optional[int] = ..., + enum_extension: Optional[ForeignEnum] = ..., + dynamic_enum_extension: Optional[TestDynamicExtensions.DynamicEnumType] = ..., + message_extension: Optional[ForeignMessage] = ..., + dynamic_message_extension: Optional[TestDynamicExtensions.DynamicMessageType] = ..., + repeated_extension: Optional[Iterable[Text]] = ..., + packed_extension: Optional[Iterable[int]] = ..., + ) -> None: ... class TestRepeatedScalarDifferentTagSizes(Message): repeated_fixed32: RepeatedScalarFieldContainer[int] @@ -1465,202 +905,98 @@ class TestRepeatedScalarDifferentTagSizes(Message): repeated_int64: RepeatedScalarFieldContainer[int] repeated_float: RepeatedScalarFieldContainer[float] repeated_uint64: RepeatedScalarFieldContainer[int] - - def __init__(self, - repeated_fixed32: Optional[Iterable[int]] = ..., - repeated_int32: Optional[Iterable[int]] = ..., - repeated_fixed64: Optional[Iterable[int]] = ..., - repeated_int64: Optional[Iterable[int]] = ..., - repeated_float: Optional[Iterable[float]] = ..., - repeated_uint64: Optional[Iterable[int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRepeatedScalarDifferentTagSizes: ... - + def __init__( + self, + repeated_fixed32: Optional[Iterable[int]] = ..., + repeated_int32: Optional[Iterable[int]] = ..., + repeated_fixed64: Optional[Iterable[int]] = ..., + repeated_int64: Optional[Iterable[int]] = ..., + repeated_float: Optional[Iterable[float]] = ..., + repeated_uint64: Optional[Iterable[int]] = ..., + ) -> None: ... class TestParsingMerge(Message): class RepeatedFieldsGenerator(Message): class Group1(Message): - @property def field1(self) -> TestAllTypes: ... - - def __init__(self, - field1: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestParsingMerge.RepeatedFieldsGenerator.Group1: ... - + def __init__(self, field1: Optional[TestAllTypes] = ...) -> None: ... class Group2(Message): - @property def field1(self) -> TestAllTypes: ... - - def __init__(self, - field1: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestParsingMerge.RepeatedFieldsGenerator.Group2: ... - + def __init__(self, field1: Optional[TestAllTypes] = ...) -> None: ... @property def field1(self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... - @property def field2(self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... - @property def field3(self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... - @property - def group1( - self) -> RepeatedCompositeFieldContainer[TestParsingMerge.RepeatedFieldsGenerator.Group1]: ... - + def group1(self) -> RepeatedCompositeFieldContainer[TestParsingMerge.RepeatedFieldsGenerator.Group1]: ... @property - def group2( - self) -> RepeatedCompositeFieldContainer[TestParsingMerge.RepeatedFieldsGenerator.Group2]: ... - + def group2(self) -> RepeatedCompositeFieldContainer[TestParsingMerge.RepeatedFieldsGenerator.Group2]: ... @property def ext1(self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... - @property def ext2(self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... - - def __init__(self, - field1: Optional[Iterable[TestAllTypes]] = ..., - field2: Optional[Iterable[TestAllTypes]] = ..., - field3: Optional[Iterable[TestAllTypes]] = ..., - group1: Optional[Iterable[TestParsingMerge.RepeatedFieldsGenerator.Group1]] = ..., - group2: Optional[Iterable[TestParsingMerge.RepeatedFieldsGenerator.Group2]] = ..., - ext1: Optional[Iterable[TestAllTypes]] = ..., - ext2: Optional[Iterable[TestAllTypes]] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestParsingMerge.RepeatedFieldsGenerator: ... - + def __init__( + self, + field1: Optional[Iterable[TestAllTypes]] = ..., + field2: Optional[Iterable[TestAllTypes]] = ..., + field3: Optional[Iterable[TestAllTypes]] = ..., + group1: Optional[Iterable[TestParsingMerge.RepeatedFieldsGenerator.Group1]] = ..., + group2: Optional[Iterable[TestParsingMerge.RepeatedFieldsGenerator.Group2]] = ..., + ext1: Optional[Iterable[TestAllTypes]] = ..., + ext2: Optional[Iterable[TestAllTypes]] = ..., + ) -> None: ... class OptionalGroup(Message): - @property def optional_group_all_types(self) -> TestAllTypes: ... - - def __init__(self, - optional_group_all_types: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestParsingMerge.OptionalGroup: ... - + def __init__(self, optional_group_all_types: Optional[TestAllTypes] = ...) -> None: ... class RepeatedGroup(Message): - @property def repeated_group_all_types(self) -> TestAllTypes: ... - - def __init__(self, - repeated_group_all_types: Optional[TestAllTypes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestParsingMerge.RepeatedGroup: ... - + def __init__(self, repeated_group_all_types: Optional[TestAllTypes] = ...) -> None: ... @property def required_all_types(self) -> TestAllTypes: ... - @property def optional_all_types(self) -> TestAllTypes: ... - @property - def repeated_all_types( - self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... - + def repeated_all_types(self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... @property def optionalgroup(self) -> TestParsingMerge.OptionalGroup: ... - @property - def repeatedgroup( - self) -> RepeatedCompositeFieldContainer[TestParsingMerge.RepeatedGroup]: ... - - def __init__(self, - required_all_types: TestAllTypes, - optional_all_types: Optional[TestAllTypes] = ..., - repeated_all_types: Optional[Iterable[TestAllTypes]] = ..., - optionalgroup: Optional[TestParsingMerge.OptionalGroup] = ..., - repeatedgroup: Optional[Iterable[TestParsingMerge.RepeatedGroup]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestParsingMerge: ... - + def repeatedgroup(self) -> RepeatedCompositeFieldContainer[TestParsingMerge.RepeatedGroup]: ... + def __init__( + self, + required_all_types: TestAllTypes, + optional_all_types: Optional[TestAllTypes] = ..., + repeated_all_types: Optional[Iterable[TestAllTypes]] = ..., + optionalgroup: Optional[TestParsingMerge.OptionalGroup] = ..., + repeatedgroup: Optional[Iterable[TestParsingMerge.RepeatedGroup]] = ..., + ) -> None: ... class TestCommentInjectionMessage(Message): a: Text - - def __init__(self, - a: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestCommentInjectionMessage: ... - + def __init__(self, a: Optional[Text] = ...) -> None: ... class FooRequest(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FooRequest: ... - + def __init__(self,) -> None: ... class FooResponse(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FooResponse: ... - + def __init__(self,) -> None: ... class FooClientMessage(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FooClientMessage: ... - + def __init__(self,) -> None: ... class FooServerMessage(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FooServerMessage: ... - + def __init__(self,) -> None: ... class BarRequest(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> BarRequest: ... - + def __init__(self,) -> None: ... class BarResponse(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> BarResponse: ... - + def __init__(self,) -> None: ... class TestJsonName(Message): field_name1: int @@ -1669,43 +1005,24 @@ class TestJsonName(Message): _field_name4: int FIELD_NAME5: int field_name6: int - - def __init__(self, - field_name1: Optional[int] = ..., - fieldName2: Optional[int] = ..., - FieldName3: Optional[int] = ..., - _field_name4: Optional[int] = ..., - FIELD_NAME5: Optional[int] = ..., - field_name6: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestJsonName: ... - + def __init__( + self, + field_name1: Optional[int] = ..., + fieldName2: Optional[int] = ..., + FieldName3: Optional[int] = ..., + _field_name4: Optional[int] = ..., + FIELD_NAME5: Optional[int] = ..., + field_name6: Optional[int] = ..., + ) -> None: ... class TestHugeFieldNumbers(Message): class OptionalGroup(Message): group_a: int - - def __init__(self, - group_a: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestHugeFieldNumbers.OptionalGroup: ... - + def __init__(self, group_a: Optional[int] = ...) -> None: ... class StringStringMapEntry(Message): key: Text value: Text - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString( - cls, s: bytes) -> TestHugeFieldNumbers.StringStringMapEntry: ... + def __init__(self, key: Optional[Text] = ..., value: Optional[Text] = ...) -> None: ... optional_int32: int fixed_32: int repeated_int32: RepeatedScalarFieldContainer[int] @@ -1716,39 +1033,31 @@ class TestHugeFieldNumbers(Message): oneof_uint32: int oneof_string: Text oneof_bytes: bytes - @property def optional_message(self) -> ForeignMessage: ... - @property def optionalgroup(self) -> TestHugeFieldNumbers.OptionalGroup: ... - @property def string_string_map(self) -> MutableMapping[Text, Text]: ... - @property def oneof_test_all_types(self) -> TestAllTypes: ... - - def __init__(self, - optional_int32: Optional[int] = ..., - fixed_32: Optional[int] = ..., - repeated_int32: Optional[Iterable[int]] = ..., - packed_int32: Optional[Iterable[int]] = ..., - optional_enum: Optional[ForeignEnum] = ..., - optional_string: Optional[Text] = ..., - optional_bytes: Optional[bytes] = ..., - optional_message: Optional[ForeignMessage] = ..., - optionalgroup: Optional[TestHugeFieldNumbers.OptionalGroup] = ..., - string_string_map: Optional[Mapping[Text, Text]] = ..., - oneof_uint32: Optional[int] = ..., - oneof_test_all_types: Optional[TestAllTypes] = ..., - oneof_string: Optional[Text] = ..., - oneof_bytes: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestHugeFieldNumbers: ... - + def __init__( + self, + optional_int32: Optional[int] = ..., + fixed_32: Optional[int] = ..., + repeated_int32: Optional[Iterable[int]] = ..., + packed_int32: Optional[Iterable[int]] = ..., + optional_enum: Optional[ForeignEnum] = ..., + optional_string: Optional[Text] = ..., + optional_bytes: Optional[bytes] = ..., + optional_message: Optional[ForeignMessage] = ..., + optionalgroup: Optional[TestHugeFieldNumbers.OptionalGroup] = ..., + string_string_map: Optional[Mapping[Text, Text]] = ..., + oneof_uint32: Optional[int] = ..., + oneof_test_all_types: Optional[TestAllTypes] = ..., + oneof_string: Optional[Text] = ..., + oneof_bytes: Optional[bytes] = ..., + ) -> None: ... class TestExtensionInsideTable(Message): field1: int @@ -1760,18 +1069,15 @@ class TestExtensionInsideTable(Message): field8: int field9: int field10: int - - def __init__(self, - field1: Optional[int] = ..., - field2: Optional[int] = ..., - field3: Optional[int] = ..., - field4: Optional[int] = ..., - field6: Optional[int] = ..., - field7: Optional[int] = ..., - field8: Optional[int] = ..., - field9: Optional[int] = ..., - field10: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestExtensionInsideTable: ... + def __init__( + self, + field1: Optional[int] = ..., + field2: Optional[int] = ..., + field3: Optional[int] = ..., + field4: Optional[int] = ..., + field6: Optional[int] = ..., + field7: Optional[int] = ..., + field8: Optional[int] = ..., + field9: Optional[int] = ..., + field10: Optional[int] = ..., + ) -> None: ... diff --git a/third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi b/third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi index 9464062ccafb..4fe5ea6ed874 100644 --- a/third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi @@ -1,66 +1,36 @@ -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.unittest_import_pb2 import ( - ImportMessage, -) -from google.protobuf.unittest_import_public_pb2 import ( - PublicImportMessage, -) -from typing import ( - Iterable, - List, - Optional, - Text, - Tuple, - cast, -) - +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from google.protobuf.unittest_import_pb2 import ImportMessage +from google.protobuf.unittest_import_public_pb2 import PublicImportMessage +from typing import Iterable, List, Optional, Text, Tuple, cast class ForeignEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> ForeignEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[ForeignEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, ForeignEnum]]: ... - FOREIGN_ZERO: ForeignEnum FOREIGN_FOO: ForeignEnum FOREIGN_BAR: ForeignEnum FOREIGN_BAZ: ForeignEnum - class TestAllTypes(Message): - class NestedEnum(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> TestAllTypes.NestedEnum: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[TestAllTypes.NestedEnum]: ... - @classmethod def items(cls) -> List[Tuple[bytes, TestAllTypes.NestedEnum]]: ... ZERO: TestAllTypes.NestedEnum @@ -68,16 +38,9 @@ class TestAllTypes(Message): BAR: TestAllTypes.NestedEnum BAZ: TestAllTypes.NestedEnum NEG: TestAllTypes.NestedEnum - class NestedMessage(Message): bb: int - - def __init__(self, - bb: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.NestedMessage: ... + def __init__(self, bb: Optional[int] = ...) -> None: ... optional_int32: int optional_int64: int optional_uint32: int @@ -119,102 +82,83 @@ class TestAllTypes(Message): oneof_uint32: int oneof_string: Text oneof_bytes: bytes - @property def optional_nested_message(self) -> TestAllTypes.NestedMessage: ... - @property def optional_foreign_message(self) -> ForeignMessage: ... - @property def optional_import_message(self) -> ImportMessage: ... - @property def optional_public_import_message(self) -> PublicImportMessage: ... - @property def optional_lazy_message(self) -> TestAllTypes.NestedMessage: ... - @property def optional_lazy_import_message(self) -> ImportMessage: ... - @property - def repeated_nested_message( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... - + def repeated_nested_message(self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... @property - def repeated_foreign_message( - self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... - + def repeated_foreign_message(self) -> RepeatedCompositeFieldContainer[ForeignMessage]: ... @property - def repeated_import_message( - self) -> RepeatedCompositeFieldContainer[ImportMessage]: ... - + def repeated_import_message(self) -> RepeatedCompositeFieldContainer[ImportMessage]: ... @property - def repeated_lazy_message( - self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... - + def repeated_lazy_message(self) -> RepeatedCompositeFieldContainer[TestAllTypes.NestedMessage]: ... @property def oneof_nested_message(self) -> TestAllTypes.NestedMessage: ... - - def __init__(self, - optional_int32: Optional[int] = ..., - optional_int64: Optional[int] = ..., - optional_uint32: Optional[int] = ..., - optional_uint64: Optional[int] = ..., - optional_sint32: Optional[int] = ..., - optional_sint64: Optional[int] = ..., - optional_fixed32: Optional[int] = ..., - optional_fixed64: Optional[int] = ..., - optional_sfixed32: Optional[int] = ..., - optional_sfixed64: Optional[int] = ..., - optional_float: Optional[float] = ..., - optional_double: Optional[float] = ..., - optional_bool: Optional[bool] = ..., - optional_string: Optional[Text] = ..., - optional_bytes: Optional[bytes] = ..., - optional_nested_message: Optional[TestAllTypes.NestedMessage] = ..., - optional_foreign_message: Optional[ForeignMessage] = ..., - optional_import_message: Optional[ImportMessage] = ..., - optional_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., - optional_foreign_enum: Optional[ForeignEnum] = ..., - optional_string_piece: Optional[Text] = ..., - optional_cord: Optional[Text] = ..., - optional_public_import_message: Optional[PublicImportMessage] = ..., - optional_lazy_message: Optional[TestAllTypes.NestedMessage] = ..., - optional_lazy_import_message: Optional[ImportMessage] = ..., - repeated_int32: Optional[Iterable[int]] = ..., - repeated_int64: Optional[Iterable[int]] = ..., - repeated_uint32: Optional[Iterable[int]] = ..., - repeated_uint64: Optional[Iterable[int]] = ..., - repeated_sint32: Optional[Iterable[int]] = ..., - repeated_sint64: Optional[Iterable[int]] = ..., - repeated_fixed32: Optional[Iterable[int]] = ..., - repeated_fixed64: Optional[Iterable[int]] = ..., - repeated_sfixed32: Optional[Iterable[int]] = ..., - repeated_sfixed64: Optional[Iterable[int]] = ..., - repeated_float: Optional[Iterable[float]] = ..., - repeated_double: Optional[Iterable[float]] = ..., - repeated_bool: Optional[Iterable[bool]] = ..., - repeated_string: Optional[Iterable[Text]] = ..., - repeated_bytes: Optional[Iterable[bytes]] = ..., - repeated_nested_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., - repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., - repeated_import_message: Optional[Iterable[ImportMessage]] = ..., - repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., - repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., - repeated_string_piece: Optional[Iterable[Text]] = ..., - repeated_cord: Optional[Iterable[Text]] = ..., - repeated_lazy_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., - oneof_uint32: Optional[int] = ..., - oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., - oneof_string: Optional[Text] = ..., - oneof_bytes: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes: ... - + def __init__( + self, + optional_int32: Optional[int] = ..., + optional_int64: Optional[int] = ..., + optional_uint32: Optional[int] = ..., + optional_uint64: Optional[int] = ..., + optional_sint32: Optional[int] = ..., + optional_sint64: Optional[int] = ..., + optional_fixed32: Optional[int] = ..., + optional_fixed64: Optional[int] = ..., + optional_sfixed32: Optional[int] = ..., + optional_sfixed64: Optional[int] = ..., + optional_float: Optional[float] = ..., + optional_double: Optional[float] = ..., + optional_bool: Optional[bool] = ..., + optional_string: Optional[Text] = ..., + optional_bytes: Optional[bytes] = ..., + optional_nested_message: Optional[TestAllTypes.NestedMessage] = ..., + optional_foreign_message: Optional[ForeignMessage] = ..., + optional_import_message: Optional[ImportMessage] = ..., + optional_nested_enum: Optional[TestAllTypes.NestedEnum] = ..., + optional_foreign_enum: Optional[ForeignEnum] = ..., + optional_string_piece: Optional[Text] = ..., + optional_cord: Optional[Text] = ..., + optional_public_import_message: Optional[PublicImportMessage] = ..., + optional_lazy_message: Optional[TestAllTypes.NestedMessage] = ..., + optional_lazy_import_message: Optional[ImportMessage] = ..., + repeated_int32: Optional[Iterable[int]] = ..., + repeated_int64: Optional[Iterable[int]] = ..., + repeated_uint32: Optional[Iterable[int]] = ..., + repeated_uint64: Optional[Iterable[int]] = ..., + repeated_sint32: Optional[Iterable[int]] = ..., + repeated_sint64: Optional[Iterable[int]] = ..., + repeated_fixed32: Optional[Iterable[int]] = ..., + repeated_fixed64: Optional[Iterable[int]] = ..., + repeated_sfixed32: Optional[Iterable[int]] = ..., + repeated_sfixed64: Optional[Iterable[int]] = ..., + repeated_float: Optional[Iterable[float]] = ..., + repeated_double: Optional[Iterable[float]] = ..., + repeated_bool: Optional[Iterable[bool]] = ..., + repeated_string: Optional[Iterable[Text]] = ..., + repeated_bytes: Optional[Iterable[bytes]] = ..., + repeated_nested_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., + repeated_foreign_message: Optional[Iterable[ForeignMessage]] = ..., + repeated_import_message: Optional[Iterable[ImportMessage]] = ..., + repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., + repeated_foreign_enum: Optional[Iterable[ForeignEnum]] = ..., + repeated_string_piece: Optional[Iterable[Text]] = ..., + repeated_cord: Optional[Iterable[Text]] = ..., + repeated_lazy_message: Optional[Iterable[TestAllTypes.NestedMessage]] = ..., + oneof_uint32: Optional[int] = ..., + oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., + oneof_string: Optional[Text] = ..., + oneof_bytes: Optional[bytes] = ..., + ) -> None: ... class TestPackedTypes(Message): packed_int32: RepeatedScalarFieldContainer[int] @@ -231,27 +175,23 @@ class TestPackedTypes(Message): packed_double: RepeatedScalarFieldContainer[float] packed_bool: RepeatedScalarFieldContainer[bool] packed_enum: RepeatedScalarFieldContainer[ForeignEnum] - - def __init__(self, - packed_int32: Optional[Iterable[int]] = ..., - packed_int64: Optional[Iterable[int]] = ..., - packed_uint32: Optional[Iterable[int]] = ..., - packed_uint64: Optional[Iterable[int]] = ..., - packed_sint32: Optional[Iterable[int]] = ..., - packed_sint64: Optional[Iterable[int]] = ..., - packed_fixed32: Optional[Iterable[int]] = ..., - packed_fixed64: Optional[Iterable[int]] = ..., - packed_sfixed32: Optional[Iterable[int]] = ..., - packed_sfixed64: Optional[Iterable[int]] = ..., - packed_float: Optional[Iterable[float]] = ..., - packed_double: Optional[Iterable[float]] = ..., - packed_bool: Optional[Iterable[bool]] = ..., - packed_enum: Optional[Iterable[ForeignEnum]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestPackedTypes: ... - + def __init__( + self, + packed_int32: Optional[Iterable[int]] = ..., + packed_int64: Optional[Iterable[int]] = ..., + packed_uint32: Optional[Iterable[int]] = ..., + packed_uint64: Optional[Iterable[int]] = ..., + packed_sint32: Optional[Iterable[int]] = ..., + packed_sint64: Optional[Iterable[int]] = ..., + packed_fixed32: Optional[Iterable[int]] = ..., + packed_fixed64: Optional[Iterable[int]] = ..., + packed_sfixed32: Optional[Iterable[int]] = ..., + packed_sfixed64: Optional[Iterable[int]] = ..., + packed_float: Optional[Iterable[float]] = ..., + packed_double: Optional[Iterable[float]] = ..., + packed_bool: Optional[Iterable[bool]] = ..., + packed_enum: Optional[Iterable[ForeignEnum]] = ..., + ) -> None: ... class TestUnpackedTypes(Message): repeated_int32: RepeatedScalarFieldContainer[int] @@ -268,65 +208,41 @@ class TestUnpackedTypes(Message): repeated_double: RepeatedScalarFieldContainer[float] repeated_bool: RepeatedScalarFieldContainer[bool] repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypes.NestedEnum] - - def __init__(self, - repeated_int32: Optional[Iterable[int]] = ..., - repeated_int64: Optional[Iterable[int]] = ..., - repeated_uint32: Optional[Iterable[int]] = ..., - repeated_uint64: Optional[Iterable[int]] = ..., - repeated_sint32: Optional[Iterable[int]] = ..., - repeated_sint64: Optional[Iterable[int]] = ..., - repeated_fixed32: Optional[Iterable[int]] = ..., - repeated_fixed64: Optional[Iterable[int]] = ..., - repeated_sfixed32: Optional[Iterable[int]] = ..., - repeated_sfixed64: Optional[Iterable[int]] = ..., - repeated_float: Optional[Iterable[float]] = ..., - repeated_double: Optional[Iterable[float]] = ..., - repeated_bool: Optional[Iterable[bool]] = ..., - repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestUnpackedTypes: ... - + def __init__( + self, + repeated_int32: Optional[Iterable[int]] = ..., + repeated_int64: Optional[Iterable[int]] = ..., + repeated_uint32: Optional[Iterable[int]] = ..., + repeated_uint64: Optional[Iterable[int]] = ..., + repeated_sint32: Optional[Iterable[int]] = ..., + repeated_sint64: Optional[Iterable[int]] = ..., + repeated_fixed32: Optional[Iterable[int]] = ..., + repeated_fixed64: Optional[Iterable[int]] = ..., + repeated_sfixed32: Optional[Iterable[int]] = ..., + repeated_sfixed64: Optional[Iterable[int]] = ..., + repeated_float: Optional[Iterable[float]] = ..., + repeated_double: Optional[Iterable[float]] = ..., + repeated_bool: Optional[Iterable[bool]] = ..., + repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., + ) -> None: ... class NestedTestAllTypes(Message): - @property def child(self) -> NestedTestAllTypes: ... - @property def payload(self) -> TestAllTypes: ... - @property - def repeated_child( - self) -> RepeatedCompositeFieldContainer[NestedTestAllTypes]: ... - - def __init__(self, - child: Optional[NestedTestAllTypes] = ..., - payload: Optional[TestAllTypes] = ..., - repeated_child: Optional[Iterable[NestedTestAllTypes]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> NestedTestAllTypes: ... - + def repeated_child(self) -> RepeatedCompositeFieldContainer[NestedTestAllTypes]: ... + def __init__( + self, + child: Optional[NestedTestAllTypes] = ..., + payload: Optional[TestAllTypes] = ..., + repeated_child: Optional[Iterable[NestedTestAllTypes]] = ..., + ) -> None: ... class ForeignMessage(Message): c: int - - def __init__(self, - c: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... - + def __init__(self, c: Optional[int] = ...) -> None: ... class TestEmptyMessage(Message): - - def __init__(self, - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEmptyMessage: ... + def __init__(self,) -> None: ... diff --git a/third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi b/third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi index 04623137f35b..f4be1b9d95e8 100644 --- a/third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi +++ b/third_party/2and3/google/protobuf/util/json_format_proto3_pb2.pyi @@ -1,30 +1,11 @@ -from google.protobuf.any_pb2 import ( - Any, -) -from google.protobuf.duration_pb2 import ( - Duration, -) -from google.protobuf.field_mask_pb2 import ( - FieldMask, -) -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer, -) -from google.protobuf.message import ( - Message, -) -from google.protobuf.struct_pb2 import ( - ListValue, - Struct, - Value, -) -from google.protobuf.timestamp_pb2 import ( - Timestamp, -) -from google.protobuf.unittest_pb2 import ( - TestAllExtensions, -) +from google.protobuf.any_pb2 import Any +from google.protobuf.duration_pb2 import Duration +from google.protobuf.field_mask_pb2 import FieldMask +from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer +from google.protobuf.message import Message +from google.protobuf.struct_pb2 import ListValue, Struct, Value +from google.protobuf.timestamp_pb2 import Timestamp +from google.protobuf.unittest_pb2 import TestAllExtensions from google.protobuf.wrappers_pb2 import ( BoolValue, BytesValue, @@ -36,50 +17,26 @@ from google.protobuf.wrappers_pb2 import ( UInt32Value, UInt64Value, ) -from typing import ( - Iterable, - List, - Mapping, - MutableMapping, - Optional, - Text, - Tuple, - cast, -) - +from typing import Iterable, List, Mapping, MutableMapping, Optional, Text, Tuple, cast class EnumType(int): - @classmethod def Name(cls, number: int) -> bytes: ... - @classmethod def Value(cls, name: bytes) -> EnumType: ... - @classmethod def keys(cls) -> List[bytes]: ... - @classmethod def values(cls) -> List[EnumType]: ... - @classmethod def items(cls) -> List[Tuple[bytes, EnumType]]: ... - FOO: EnumType BAR: EnumType - class MessageType(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> MessageType: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class TestMessage(Message): bool_value: bool @@ -102,558 +59,283 @@ class TestMessage(Message): repeated_string_value: RepeatedScalarFieldContainer[Text] repeated_bytes_value: RepeatedScalarFieldContainer[bytes] repeated_enum_value: RepeatedScalarFieldContainer[EnumType] - @property def message_value(self) -> MessageType: ... - @property - def repeated_message_value( - self) -> RepeatedCompositeFieldContainer[MessageType]: ... - - def __init__(self, - bool_value: Optional[bool] = ..., - int32_value: Optional[int] = ..., - int64_value: Optional[int] = ..., - uint32_value: Optional[int] = ..., - uint64_value: Optional[int] = ..., - float_value: Optional[float] = ..., - double_value: Optional[float] = ..., - string_value: Optional[Text] = ..., - bytes_value: Optional[bytes] = ..., - enum_value: Optional[EnumType] = ..., - message_value: Optional[MessageType] = ..., - repeated_bool_value: Optional[Iterable[bool]] = ..., - repeated_int32_value: Optional[Iterable[int]] = ..., - repeated_int64_value: Optional[Iterable[int]] = ..., - repeated_uint32_value: Optional[Iterable[int]] = ..., - repeated_uint64_value: Optional[Iterable[int]] = ..., - repeated_float_value: Optional[Iterable[float]] = ..., - repeated_double_value: Optional[Iterable[float]] = ..., - repeated_string_value: Optional[Iterable[Text]] = ..., - repeated_bytes_value: Optional[Iterable[bytes]] = ..., - repeated_enum_value: Optional[Iterable[EnumType]] = ..., - repeated_message_value: Optional[Iterable[MessageType]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessage: ... - + def repeated_message_value(self) -> RepeatedCompositeFieldContainer[MessageType]: ... + def __init__( + self, + bool_value: Optional[bool] = ..., + int32_value: Optional[int] = ..., + int64_value: Optional[int] = ..., + uint32_value: Optional[int] = ..., + uint64_value: Optional[int] = ..., + float_value: Optional[float] = ..., + double_value: Optional[float] = ..., + string_value: Optional[Text] = ..., + bytes_value: Optional[bytes] = ..., + enum_value: Optional[EnumType] = ..., + message_value: Optional[MessageType] = ..., + repeated_bool_value: Optional[Iterable[bool]] = ..., + repeated_int32_value: Optional[Iterable[int]] = ..., + repeated_int64_value: Optional[Iterable[int]] = ..., + repeated_uint32_value: Optional[Iterable[int]] = ..., + repeated_uint64_value: Optional[Iterable[int]] = ..., + repeated_float_value: Optional[Iterable[float]] = ..., + repeated_double_value: Optional[Iterable[float]] = ..., + repeated_string_value: Optional[Iterable[Text]] = ..., + repeated_bytes_value: Optional[Iterable[bytes]] = ..., + repeated_enum_value: Optional[Iterable[EnumType]] = ..., + repeated_message_value: Optional[Iterable[MessageType]] = ..., + ) -> None: ... class TestOneof(Message): oneof_int32_value: int oneof_string_value: Text oneof_bytes_value: bytes oneof_enum_value: EnumType - @property def oneof_message_value(self) -> MessageType: ... - - def __init__(self, - oneof_int32_value: Optional[int] = ..., - oneof_string_value: Optional[Text] = ..., - oneof_bytes_value: Optional[bytes] = ..., - oneof_enum_value: Optional[EnumType] = ..., - oneof_message_value: Optional[MessageType] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestOneof: ... - + def __init__( + self, + oneof_int32_value: Optional[int] = ..., + oneof_string_value: Optional[Text] = ..., + oneof_bytes_value: Optional[bytes] = ..., + oneof_enum_value: Optional[EnumType] = ..., + oneof_message_value: Optional[MessageType] = ..., + ) -> None: ... class TestMap(Message): - class BoolMapEntry(Message): key: bool value: int - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.BoolMapEntry: ... - + def __init__(self, key: Optional[bool] = ..., value: Optional[int] = ...) -> None: ... class Int32MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.Int32MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class Int64MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.Int64MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class Uint32MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.Uint32MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class Uint64MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.Uint64MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class StringMapEntry(Message): key: Text value: int - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap.StringMapEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[int] = ...) -> None: ... @property def bool_map(self) -> MutableMapping[bool, int]: ... - @property def int32_map(self) -> MutableMapping[int, int]: ... - @property def int64_map(self) -> MutableMapping[int, int]: ... - @property def uint32_map(self) -> MutableMapping[int, int]: ... - @property def uint64_map(self) -> MutableMapping[int, int]: ... - @property def string_map(self) -> MutableMapping[Text, int]: ... - - def __init__(self, - bool_map: Optional[Mapping[bool, int]] = ..., - int32_map: Optional[Mapping[int, int]] = ..., - int64_map: Optional[Mapping[int, int]] = ..., - uint32_map: Optional[Mapping[int, int]] = ..., - uint64_map: Optional[Mapping[int, int]] = ..., - string_map: Optional[Mapping[Text, int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMap: ... - + def __init__( + self, + bool_map: Optional[Mapping[bool, int]] = ..., + int32_map: Optional[Mapping[int, int]] = ..., + int64_map: Optional[Mapping[int, int]] = ..., + uint32_map: Optional[Mapping[int, int]] = ..., + uint64_map: Optional[Mapping[int, int]] = ..., + string_map: Optional[Mapping[Text, int]] = ..., + ) -> None: ... class TestNestedMap(Message): - class BoolMapEntry(Message): key: bool value: int - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.BoolMapEntry: ... - + def __init__(self, key: Optional[bool] = ..., value: Optional[int] = ...) -> None: ... class Int32MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Int32MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class Int64MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Int64MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class Uint32MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Uint32MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class Uint64MapEntry(Message): key: int value: int - - def __init__(self, - key: Optional[int] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Uint64MapEntry: ... - + def __init__(self, key: Optional[int] = ..., value: Optional[int] = ...) -> None: ... class StringMapEntry(Message): key: Text value: int - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.StringMapEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[int] = ...) -> None: ... class MapMapEntry(Message): key: Text - @property def value(self) -> TestNestedMap: ... - - def __init__(self, - key: Optional[Text] = ..., - value: Optional[TestNestedMap] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.MapMapEntry: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[TestNestedMap] = ...) -> None: ... @property def bool_map(self) -> MutableMapping[bool, int]: ... - @property def int32_map(self) -> MutableMapping[int, int]: ... - @property def int64_map(self) -> MutableMapping[int, int]: ... - @property def uint32_map(self) -> MutableMapping[int, int]: ... - @property def uint64_map(self) -> MutableMapping[int, int]: ... - @property def string_map(self) -> MutableMapping[Text, int]: ... - @property def map_map(self) -> MutableMapping[Text, TestNestedMap]: ... - - def __init__(self, - bool_map: Optional[Mapping[bool, int]] = ..., - int32_map: Optional[Mapping[int, int]] = ..., - int64_map: Optional[Mapping[int, int]] = ..., - uint32_map: Optional[Mapping[int, int]] = ..., - uint64_map: Optional[Mapping[int, int]] = ..., - string_map: Optional[Mapping[Text, int]] = ..., - map_map: Optional[Mapping[Text, TestNestedMap]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap: ... - + def __init__( + self, + bool_map: Optional[Mapping[bool, int]] = ..., + int32_map: Optional[Mapping[int, int]] = ..., + int64_map: Optional[Mapping[int, int]] = ..., + uint32_map: Optional[Mapping[int, int]] = ..., + uint64_map: Optional[Mapping[int, int]] = ..., + string_map: Optional[Mapping[Text, int]] = ..., + map_map: Optional[Mapping[Text, TestNestedMap]] = ..., + ) -> None: ... class TestWrapper(Message): - @property def bool_value(self) -> BoolValue: ... - @property def int32_value(self) -> Int32Value: ... - @property def int64_value(self) -> Int64Value: ... - @property def uint32_value(self) -> UInt32Value: ... - @property def uint64_value(self) -> UInt64Value: ... - @property def float_value(self) -> FloatValue: ... - @property def double_value(self) -> DoubleValue: ... - @property def string_value(self) -> StringValue: ... - @property def bytes_value(self) -> BytesValue: ... - @property - def repeated_bool_value( - self) -> RepeatedCompositeFieldContainer[BoolValue]: ... - + def repeated_bool_value(self) -> RepeatedCompositeFieldContainer[BoolValue]: ... @property - def repeated_int32_value( - self) -> RepeatedCompositeFieldContainer[Int32Value]: ... - + def repeated_int32_value(self) -> RepeatedCompositeFieldContainer[Int32Value]: ... @property - def repeated_int64_value( - self) -> RepeatedCompositeFieldContainer[Int64Value]: ... - + def repeated_int64_value(self) -> RepeatedCompositeFieldContainer[Int64Value]: ... @property - def repeated_uint32_value( - self) -> RepeatedCompositeFieldContainer[UInt32Value]: ... - + def repeated_uint32_value(self) -> RepeatedCompositeFieldContainer[UInt32Value]: ... @property - def repeated_uint64_value( - self) -> RepeatedCompositeFieldContainer[UInt64Value]: ... - + def repeated_uint64_value(self) -> RepeatedCompositeFieldContainer[UInt64Value]: ... @property - def repeated_float_value( - self) -> RepeatedCompositeFieldContainer[FloatValue]: ... - + def repeated_float_value(self) -> RepeatedCompositeFieldContainer[FloatValue]: ... @property - def repeated_double_value( - self) -> RepeatedCompositeFieldContainer[DoubleValue]: ... - + def repeated_double_value(self) -> RepeatedCompositeFieldContainer[DoubleValue]: ... @property - def repeated_string_value( - self) -> RepeatedCompositeFieldContainer[StringValue]: ... - + def repeated_string_value(self) -> RepeatedCompositeFieldContainer[StringValue]: ... @property - def repeated_bytes_value( - self) -> RepeatedCompositeFieldContainer[BytesValue]: ... - - def __init__(self, - bool_value: Optional[BoolValue] = ..., - int32_value: Optional[Int32Value] = ..., - int64_value: Optional[Int64Value] = ..., - uint32_value: Optional[UInt32Value] = ..., - uint64_value: Optional[UInt64Value] = ..., - float_value: Optional[FloatValue] = ..., - double_value: Optional[DoubleValue] = ..., - string_value: Optional[StringValue] = ..., - bytes_value: Optional[BytesValue] = ..., - repeated_bool_value: Optional[Iterable[BoolValue]] = ..., - repeated_int32_value: Optional[Iterable[Int32Value]] = ..., - repeated_int64_value: Optional[Iterable[Int64Value]] = ..., - repeated_uint32_value: Optional[Iterable[UInt32Value]] = ..., - repeated_uint64_value: Optional[Iterable[UInt64Value]] = ..., - repeated_float_value: Optional[Iterable[FloatValue]] = ..., - repeated_double_value: Optional[Iterable[DoubleValue]] = ..., - repeated_string_value: Optional[Iterable[StringValue]] = ..., - repeated_bytes_value: Optional[Iterable[BytesValue]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestWrapper: ... - + def repeated_bytes_value(self) -> RepeatedCompositeFieldContainer[BytesValue]: ... + def __init__( + self, + bool_value: Optional[BoolValue] = ..., + int32_value: Optional[Int32Value] = ..., + int64_value: Optional[Int64Value] = ..., + uint32_value: Optional[UInt32Value] = ..., + uint64_value: Optional[UInt64Value] = ..., + float_value: Optional[FloatValue] = ..., + double_value: Optional[DoubleValue] = ..., + string_value: Optional[StringValue] = ..., + bytes_value: Optional[BytesValue] = ..., + repeated_bool_value: Optional[Iterable[BoolValue]] = ..., + repeated_int32_value: Optional[Iterable[Int32Value]] = ..., + repeated_int64_value: Optional[Iterable[Int64Value]] = ..., + repeated_uint32_value: Optional[Iterable[UInt32Value]] = ..., + repeated_uint64_value: Optional[Iterable[UInt64Value]] = ..., + repeated_float_value: Optional[Iterable[FloatValue]] = ..., + repeated_double_value: Optional[Iterable[DoubleValue]] = ..., + repeated_string_value: Optional[Iterable[StringValue]] = ..., + repeated_bytes_value: Optional[Iterable[BytesValue]] = ..., + ) -> None: ... class TestTimestamp(Message): - @property def value(self) -> Timestamp: ... - @property def repeated_value(self) -> RepeatedCompositeFieldContainer[Timestamp]: ... - - def __init__(self, - value: Optional[Timestamp] = ..., - repeated_value: Optional[Iterable[Timestamp]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestTimestamp: ... - + def __init__(self, value: Optional[Timestamp] = ..., repeated_value: Optional[Iterable[Timestamp]] = ...) -> None: ... class TestDuration(Message): - @property def value(self) -> Duration: ... - @property def repeated_value(self) -> RepeatedCompositeFieldContainer[Duration]: ... - - def __init__(self, - value: Optional[Duration] = ..., - repeated_value: Optional[Iterable[Duration]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestDuration: ... - + def __init__(self, value: Optional[Duration] = ..., repeated_value: Optional[Iterable[Duration]] = ...) -> None: ... class TestFieldMask(Message): - @property def value(self) -> FieldMask: ... - - def __init__(self, - value: Optional[FieldMask] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestFieldMask: ... - + def __init__(self, value: Optional[FieldMask] = ...) -> None: ... class TestStruct(Message): - @property def value(self) -> Struct: ... - @property def repeated_value(self) -> RepeatedCompositeFieldContainer[Struct]: ... - - def __init__(self, - value: Optional[Struct] = ..., - repeated_value: Optional[Iterable[Struct]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestStruct: ... - + def __init__(self, value: Optional[Struct] = ..., repeated_value: Optional[Iterable[Struct]] = ...) -> None: ... class TestAny(Message): - @property def value(self) -> Any: ... - @property def repeated_value(self) -> RepeatedCompositeFieldContainer[Any]: ... - - def __init__(self, - value: Optional[Any] = ..., - repeated_value: Optional[Iterable[Any]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAny: ... - + def __init__(self, value: Optional[Any] = ..., repeated_value: Optional[Iterable[Any]] = ...) -> None: ... class TestValue(Message): - @property def value(self) -> Value: ... - @property def repeated_value(self) -> RepeatedCompositeFieldContainer[Value]: ... - - def __init__(self, - value: Optional[Value] = ..., - repeated_value: Optional[Iterable[Value]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestValue: ... - + def __init__(self, value: Optional[Value] = ..., repeated_value: Optional[Iterable[Value]] = ...) -> None: ... class TestListValue(Message): - @property def value(self) -> ListValue: ... - @property def repeated_value(self) -> RepeatedCompositeFieldContainer[ListValue]: ... - - def __init__(self, - value: Optional[ListValue] = ..., - repeated_value: Optional[Iterable[ListValue]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestListValue: ... - + def __init__(self, value: Optional[ListValue] = ..., repeated_value: Optional[Iterable[ListValue]] = ...) -> None: ... class TestBoolValue(Message): - class BoolMapEntry(Message): key: bool value: int - - def __init__(self, - key: Optional[bool] = ..., - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestBoolValue.BoolMapEntry: ... + def __init__(self, key: Optional[bool] = ..., value: Optional[int] = ...) -> None: ... bool_value: bool - @property def bool_map(self) -> MutableMapping[bool, int]: ... - - def __init__(self, - bool_value: Optional[bool] = ..., - bool_map: Optional[Mapping[bool, int]] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestBoolValue: ... - + def __init__(self, bool_value: Optional[bool] = ..., bool_map: Optional[Mapping[bool, int]] = ...) -> None: ... class TestCustomJsonName(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestCustomJsonName: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class TestExtensions(Message): - @property def extensions(self) -> TestAllExtensions: ... - - def __init__(self, - extensions: Optional[TestAllExtensions] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestExtensions: ... - + def __init__(self, extensions: Optional[TestAllExtensions] = ...) -> None: ... class TestEnumValue(Message): enum_value1: EnumType enum_value2: EnumType enum_value3: EnumType - - def __init__(self, - enum_value1: Optional[EnumType] = ..., - enum_value2: Optional[EnumType] = ..., - enum_value3: Optional[EnumType] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumValue: ... + def __init__( + self, enum_value1: Optional[EnumType] = ..., enum_value2: Optional[EnumType] = ..., enum_value3: Optional[EnumType] = ... + ) -> None: ... diff --git a/third_party/2and3/google/protobuf/wrappers_pb2.pyi b/third_party/2and3/google/protobuf/wrappers_pb2.pyi index 6ff865d34c06..342d0e043d2f 100644 --- a/third_party/2and3/google/protobuf/wrappers_pb2.pyi +++ b/third_party/2and3/google/protobuf/wrappers_pb2.pyi @@ -1,106 +1,38 @@ -from google.protobuf.message import ( - Message, -) -from typing import ( - Optional, - Text, -) - +from google.protobuf.message import Message +from typing import Optional, Text class DoubleValue(Message): value: float - - def __init__(self, - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> DoubleValue: ... - + def __init__(self, value: Optional[float] = ...) -> None: ... class FloatValue(Message): value: float - - def __init__(self, - value: Optional[float] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FloatValue: ... - + def __init__(self, value: Optional[float] = ...) -> None: ... class Int64Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Int64Value: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class UInt64Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> UInt64Value: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class Int32Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Int32Value: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class UInt32Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> UInt32Value: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class BoolValue(Message): value: bool - - def __init__(self, - value: Optional[bool] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> BoolValue: ... - + def __init__(self, value: Optional[bool] = ...) -> None: ... class StringValue(Message): value: Text - - def __init__(self, - value: Optional[Text] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> StringValue: ... - + def __init__(self, value: Optional[Text] = ...) -> None: ... class BytesValue(Message): value: bytes - - def __init__(self, - value: Optional[bytes] = ..., - ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> BytesValue: ... + def __init__(self, value: Optional[bytes] = ...) -> None: ... diff --git a/third_party/2and3/jinja2/filters.pyi b/third_party/2and3/jinja2/filters.pyi index 44b7bb57e371..8f0fb210aa4d 100644 --- a/third_party/2and3/jinja2/filters.pyi +++ b/third_party/2and3/jinja2/filters.pyi @@ -37,7 +37,9 @@ def do_batch(value, linecount, fill_with: Optional[Any] = ...): ... def do_round(value, precision: int = ..., method: str = ...): ... def do_groupby(environment, value, attribute): ... -_GroupTuple = NamedTuple("_GroupTuple", [("grouper", Any), ("list", Any)]) +class _GroupTuple(NamedTuple): + grouper: Any + list: Any def do_sum(environment, iterable, attribute: Optional[Any] = ..., start: int = ...): ... def do_list(value): ... diff --git a/third_party/2and3/maxminddb/__init__.pyi b/third_party/2and3/maxminddb/__init__.pyi new file mode 100644 index 000000000000..fe20a1f42cd1 --- /dev/null +++ b/third_party/2and3/maxminddb/__init__.pyi @@ -0,0 +1,7 @@ +from typing import Text + +from maxminddb import reader + +def open_database(database: Text, mode: int = ...) -> reader.Reader: ... + +def Reader(database: Text) -> reader.Reader: ... diff --git a/third_party/3/maxminddb/compat.pyi b/third_party/2and3/maxminddb/compat.pyi similarity index 85% rename from third_party/3/maxminddb/compat.pyi rename to third_party/2and3/maxminddb/compat.pyi index 236b0797ea94..ca8e3ab2c78f 100644 --- a/third_party/3/maxminddb/compat.pyi +++ b/third_party/2and3/maxminddb/compat.pyi @@ -1,5 +1,3 @@ -# Stubs for maxminddb.compat (Python 3) - from ipaddress import IPv4Address, IPv6Address from typing import Any diff --git a/third_party/3/maxminddb/const.pyi b/third_party/2and3/maxminddb/const.pyi similarity index 76% rename from third_party/3/maxminddb/const.pyi rename to third_party/2and3/maxminddb/const.pyi index 36d11a7fa55f..e1cff069a10a 100644 --- a/third_party/3/maxminddb/const.pyi +++ b/third_party/2and3/maxminddb/const.pyi @@ -1,5 +1,3 @@ -# Stubs for maxminddb.const (Python 3) - MODE_AUTO: int = ... MODE_MMAP_EXT: int = ... MODE_MMAP: int = ... diff --git a/third_party/3/maxminddb/decoder.pyi b/third_party/2and3/maxminddb/decoder.pyi similarity index 83% rename from third_party/3/maxminddb/decoder.pyi rename to third_party/2and3/maxminddb/decoder.pyi index 1b7aa6e154a6..e2bc38adb604 100644 --- a/third_party/3/maxminddb/decoder.pyi +++ b/third_party/2and3/maxminddb/decoder.pyi @@ -1,5 +1,3 @@ -# Stubs for maxminddb.decoder (Python 3) - from typing import Any, Tuple class Decoder: diff --git a/third_party/3/maxminddb/errors.pyi b/third_party/2and3/maxminddb/errors.pyi similarity index 52% rename from third_party/3/maxminddb/errors.pyi rename to third_party/2and3/maxminddb/errors.pyi index 46b1f5aee972..e98b5560d027 100644 --- a/third_party/3/maxminddb/errors.pyi +++ b/third_party/2and3/maxminddb/errors.pyi @@ -1,3 +1 @@ -# Stubs for maxminddb.errors (Python 3) - class InvalidDatabaseError(RuntimeError): ... diff --git a/third_party/3/maxminddb/extension.pyi b/third_party/2and3/maxminddb/extension.pyi similarity index 80% rename from third_party/3/maxminddb/extension.pyi rename to third_party/2and3/maxminddb/extension.pyi index 24fb851803f3..de4423c34ac6 100644 --- a/third_party/3/maxminddb/extension.pyi +++ b/third_party/2and3/maxminddb/extension.pyi @@ -1,6 +1,4 @@ -# Stubs for maxminddb.extension (Python 3) - -from typing import Any, Mapping, Sequence +from typing import Any, Mapping, Sequence, Text from maxminddb.errors import InvalidDatabaseError as InvalidDatabaseError @@ -21,9 +19,9 @@ class extension: @property def ip_version(self) -> int: ... @property - def database_type(self) -> str: ... + def database_type(self) -> Text: ... @property - def languages(self) -> Sequence[str]: ... + def languages(self) -> Sequence[Text]: ... @property def binary_format_major_version(self) -> int: ... @property @@ -31,5 +29,5 @@ class extension: @property def build_epoch(self) -> int: ... @property - def description(self) -> Mapping[str, str]: ... + def description(self) -> Mapping[Text, Text]: ... def __init__(self, **kwargs: Any) -> None: ... diff --git a/third_party/3/maxminddb/reader.pyi b/third_party/2and3/maxminddb/reader.pyi similarity index 66% rename from third_party/3/maxminddb/reader.pyi rename to third_party/2and3/maxminddb/reader.pyi index 47e7f6493a8f..882a49876184 100644 --- a/third_party/3/maxminddb/reader.pyi +++ b/third_party/2and3/maxminddb/reader.pyi @@ -1,16 +1,14 @@ -# Stubs for maxminddb.reader (Python 3) - from ipaddress import IPv4Address, IPv6Address from types import TracebackType -from typing import Any, Mapping, Optional, Sequence, Tuple, Type, Union +from typing import Any, Mapping, Optional, Sequence, Text, Tuple, Type, Union class Reader: closed: bool = ... def __init__(self, database: bytes, mode: int = ...) -> None: ... def metadata(self) -> Metadata: ... - def get(self, ip_address: Union[str, IPv4Address, IPv6Address]) -> Optional[Any]: ... - def get_with_prefix_len(self, ip_address: Union[str, IPv4Address, IPv6Address]) -> Tuple[Optional[Any], int]: ... + def get(self, ip_address: Union[Text, IPv4Address, IPv6Address]) -> Optional[Any]: ... + def get_with_prefix_len(self, ip_address: Union[Text, IPv4Address, IPv6Address]) -> Tuple[Optional[Any], int]: ... def close(self) -> None: ... def __enter__(self) -> Reader: ... def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = ..., exc_tb: Optional[TracebackType] = ...) -> None: ... @@ -19,12 +17,12 @@ class Metadata: node_count: int = ... record_size: int = ... ip_version: int = ... - database_type: str = ... - languages: Sequence[str] = ... + database_type: Text = ... + languages: Sequence[Text] = ... binary_format_major_version: int = ... binary_format_minor_version: int = ... build_epoch: int = ... - description: Mapping[str, str] = ... + description: Mapping[Text, Text] = ... def __init__(self, **kwargs: Any) -> None: ... @property def node_byte_size(self) -> int: ... diff --git a/third_party/2and3/mock.pyi b/third_party/2and3/mock.pyi index b4c4ce38aab9..396d806b1633 100644 --- a/third_party/2and3/mock.pyi +++ b/third_party/2and3/mock.pyi @@ -98,6 +98,8 @@ class MagicMixin: NonCallableMagicMock = Any MagicMock = Any +if sys.version_info >= (3, 8): + AsyncMock = Any class MagicProxy: name: Any diff --git a/third_party/2and3/pymysql/cursors.pyi b/third_party/2and3/pymysql/cursors.pyi index e08008541503..48119ccd7780 100644 --- a/third_party/2and3/pymysql/cursors.pyi +++ b/third_party/2and3/pymysql/cursors.pyi @@ -1,7 +1,9 @@ -from typing import Union, Tuple, Any, Dict, Optional, Text, Iterator, List +from typing import Any, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union + from .connections import Connection Gen = Union[Tuple[Any, ...], Dict[str, Any]] +_SelfT = TypeVar("_SelfT") class Cursor: connection: Connection @@ -26,6 +28,8 @@ class Cursor: def fetchall(self) -> Optional[Tuple[Gen, ...]]: ... def scroll(self, value: int, mode: str = ...): ... def __iter__(self): ... + def __enter__(self: _SelfT) -> _SelfT: ... + def __exit__(self, *exc_info: Any) -> None: ... class DictCursor(Cursor): def fetchone(self) -> Optional[Dict[str, Any]]: ... diff --git a/third_party/2and3/requests/models.pyi b/third_party/2and3/requests/models.pyi index adc64318f57a..ee98344c4ddd 100644 --- a/third_party/2and3/requests/models.pyi +++ b/third_party/2and3/requests/models.pyi @@ -118,6 +118,8 @@ class Response: def __enter__(self) -> Response: ... def __exit__(self, *args: Any) -> None: ... @property + def next(self) -> Optional[PreparedRequest]: ... + @property def ok(self) -> bool: ... @property def is_redirect(self) -> bool: ... diff --git a/third_party/2and3/typing_extensions.pyi b/third_party/2and3/typing_extensions.pyi index ef36d125cf7e..edf40d67569f 100644 --- a/third_party/2and3/typing_extensions.pyi +++ b/third_party/2and3/typing_extensions.pyi @@ -12,7 +12,7 @@ from typing import overload as overload from typing import Text as Text from typing import Type as Type from typing import TYPE_CHECKING as TYPE_CHECKING -from typing import TypeVar, Any, Mapping, ItemsView, KeysView, ValuesView, Dict, Type +from typing import TypeVar, Any, Mapping, ItemsView, KeysView, Optional, ValuesView, Dict, Type _T = TypeVar('_T') _F = TypeVar('_F', bound=Callable[..., Any]) @@ -59,3 +59,11 @@ if sys.version_info >= (3, 5): if sys.version_info >= (3, 6): from typing import AsyncGenerator as AsyncGenerator + +def get_type_hints( + obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ..., + include_extras: bool = ... +) -> Dict[str, Any]: ... + +Annotated: _SpecialForm = ... +_AnnotatedAlias: Any = ... # undocumented diff --git a/third_party/2and3/werkzeug/middleware/proxy_fix.pyi b/third_party/2and3/werkzeug/middleware/proxy_fix.pyi index 46aec1528360..764fc6f077ac 100644 --- a/third_party/2and3/werkzeug/middleware/proxy_fix.pyi +++ b/third_party/2and3/werkzeug/middleware/proxy_fix.pyi @@ -20,4 +20,4 @@ class ProxyFix(object): x_prefix: int = ..., ) -> None: ... def get_remote_addr(self, forwarded_for: Iterable[str]) -> Optional[str]: ... - def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> WSGIApplication: ... + def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ... diff --git a/third_party/2and3/werkzeug/urls.pyi b/third_party/2and3/werkzeug/urls.pyi index e0b13069a76c..2853e46e112d 100644 --- a/third_party/2and3/werkzeug/urls.pyi +++ b/third_party/2and3/werkzeug/urls.pyi @@ -1,12 +1,11 @@ -from collections import namedtuple -from typing import Any, Optional, Text - - -_URLTuple = namedtuple( - '_URLTuple', - ['scheme', 'netloc', 'path', 'query', 'fragment'] -) +from typing import Any, NamedTuple, Optional, Text +class _URLTuple(NamedTuple): + scheme: Any + netloc: Any + path: Any + query: Any + fragment: Any class BaseURL(_URLTuple): def replace(self, **kwargs): ... diff --git a/third_party/3/contextvars.pyi b/third_party/3/contextvars.pyi index ab2ae9e5fabf..a90c2a8b5f65 100644 --- a/third_party/3/contextvars.pyi +++ b/third_party/3/contextvars.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar, Union +from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar _T = TypeVar('_T') diff --git a/third_party/3/maxminddb/__init__.pyi b/third_party/3/maxminddb/__init__.pyi deleted file mode 100644 index 040872fed4ec..000000000000 --- a/third_party/3/maxminddb/__init__.pyi +++ /dev/null @@ -1,9 +0,0 @@ -# Stubs for maxminddb (Python 3) - -from typing import Any - -from maxminddb import reader - -def open_database(database: str, mode: int = ...) -> reader.Reader: ... - -def Reader(database: str) -> reader.Reader: ... diff --git a/third_party/3/pkg_resources/__init__.pyi b/third_party/3/pkg_resources/__init__.pyi index 55914e12bae0..0b6eb3af0758 100644 --- a/third_party/3/pkg_resources/__init__.pyi +++ b/third_party/3/pkg_resources/__init__.pyi @@ -1,6 +1,6 @@ # Stubs for pkg_resources (Python 3.4) -from typing import Any, Callable, Dict, IO, Iterable, Generator, Optional, Sequence, Tuple, List, Union, TypeVar, overload +from typing import Any, Callable, Dict, IO, Iterable, Generator, Optional, Sequence, Tuple, List, Set, Union, TypeVar, overload from abc import ABCMeta import importlib.abc import types @@ -202,7 +202,19 @@ class IMetadataProvider: class ResolutionError(Exception): ... class DistributionNotFound(ResolutionError): ... -class VersionConflict(ResolutionError): ... + +class VersionConflict(ResolutionError): + @property + def dist(self) -> Any: ... + @property + def req(self) -> Any: ... + def report(self) -> str: ... + def with_context(self, required_by: Dict[str, Any]) -> VersionConflict: ... + +class ContextualVersionConflict(VersionConflict): + @property + def required_by(self) -> Set[Any]: ... + class UnknownExtra(ResolutionError): ... class ExtractionError(Exception):