From 7710e925ca8bd2b3b425bec7550895296758736f Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Mon, 7 Oct 2019 11:05:19 -0400 Subject: [PATCH 01/59] Add `data` to UserList class, fix UserDict.data type (#3316) --- stdlib/2/UserDict.pyi | 2 +- stdlib/2/UserList.pyi | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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: ... From 6e4708ebf3a482aa8d524196712c37c9fd645953 Mon Sep 17 00:00:00 2001 From: Rafi Blecher Date: Mon, 7 Oct 2019 13:21:31 -0700 Subject: [PATCH 02/59] Add type stub for decorator lib (#3038) --- third_party/2and3/decorator.pyi | 83 +++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 third_party/2and3/decorator.pyi diff --git a/third_party/2and3/decorator.pyi b/third_party/2and3/decorator.pyi new file mode 100644 index 000000000000..18c919f87ddd --- /dev/null +++ b/third_party/2and3/decorator.pyi @@ -0,0 +1,83 @@ +import sys +from typing import Any, Callable, Dict, List, NamedTuple, Optional, Pattern, Text, Tuple, TypeVar + +_C = TypeVar("_C", bound=Callable[..., Any]) +_Func = TypeVar("_Func", bound=Callable[..., Any]) + +def get_init(cls): ... + +if sys.version_info >= (3,): + from inspect import iscoroutinefunction as iscoroutinefunction + from inspect import getfullargspec as getfullargspec +else: + 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]), + ]) + 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[[_C], _C]: ... + +class ContextManager(_GeneratorContextManager[Any]): + def __call__(self, func: _C) -> _C: ... + +def contextmanager(func: _C) -> _C: ... +def dispatch_on(*dispatch_args: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ... From a6f146e6517cb3c2b27396eabd80f4c223c1308a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Tue, 8 Oct 2019 10:30:00 +0200 Subject: [PATCH 03/59] Fix return type of werkzeug's ProxyFix (#3320) --- third_party/2and3/werkzeug/middleware/proxy_fix.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]: ... From 256b3ce8aba6080f9a1c90c8c264e93e49e754cd Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 8 Oct 2019 16:59:32 +0200 Subject: [PATCH 04/59] Remove a bunch of unused imports (#3323) --- stdlib/2/os/path.pyi | 5 +---- stdlib/2/os2emxpath.pyi | 5 +---- stdlib/2and3/macpath.pyi | 5 +---- stdlib/2and3/ntpath.pyi | 5 +---- stdlib/2and3/posixpath.pyi | 5 +---- stdlib/3.7/contextvars.pyi | 2 +- stdlib/3/_imp.pyi | 1 - stdlib/3/_importlib_modulespec.pyi | 1 - stdlib/3/_operator.pyi | 1 - stdlib/3/asyncio/coroutines.pyi | 2 +- stdlib/3/asyncio/futures.pyi | 2 +- stdlib/3/asyncio/locks.pyi | 2 +- stdlib/3/asyncio/queues.pyi | 2 -- stdlib/3/asyncio/tasks.pyi | 6 +++--- stdlib/3/asyncio/transports.pyi | 2 +- stdlib/3/email/__init__.pyi | 3 +-- stdlib/3/email/feedparser.pyi | 1 - stdlib/3/email/message.pyi | 1 - stdlib/3/email/parser.pyi | 2 +- stdlib/3/email/policy.pyi | 1 - stdlib/3/encodings/__init__.pyi | 5 +---- stdlib/3/functools.pyi | 1 - stdlib/3/heapq.pyi | 1 - stdlib/3/html/parser.pyi | 1 - stdlib/3/http/cookies.pyi | 2 +- stdlib/3/importlib/__init__.pyi | 1 - stdlib/3/importlib/machinery.pyi | 3 +-- stdlib/3/io.pyi | 1 - stdlib/3/json/decoder.pyi | 1 - stdlib/3/msvcrt.pyi | 2 -- stdlib/3/multiprocessing/__init__.pyi | 5 +---- stdlib/3/multiprocessing/context.pyi | 5 +---- stdlib/3/multiprocessing/dummy/__init__.pyi | 6 +----- stdlib/3/multiprocessing/dummy/connection.pyi | 2 +- stdlib/3/multiprocessing/pool.pyi | 6 +----- stdlib/3/os/__init__.pyi | 2 +- stdlib/3/os/path.pyi | 5 +---- stdlib/3/posix.pyi | 2 +- stdlib/3/smtplib.pyi | 5 +---- stdlib/3/stat.pyi | 1 - stdlib/3/string.pyi | 2 +- stdlib/3/subprocess.pyi | 6 +----- stdlib/3/unittest/loader.pyi | 1 - stdlib/3/unittest/result.pyi | 2 +- stdlib/3/unittest/runner.pyi | 1 - stdlib/3/urllib/parse.pyi | 1 - third_party/3/contextvars.pyi | 2 +- 47 files changed, 31 insertions(+), 95 deletions(-) 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/2and3/macpath.pyi b/stdlib/2and3/macpath.pyi index c0bf57658ed7..42409c0e8721 100644 --- a/stdlib/2and3/macpath.pyi +++ b/stdlib/2and3/macpath.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/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/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/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/_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/asyncio/coroutines.pyi b/stdlib/3/asyncio/coroutines.pyi index 981ccd5a0018..480093273e8d 100644 --- a/stdlib/3/asyncio/coroutines.pyi +++ b/stdlib/3/asyncio/coroutines.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Generator, List, TypeVar +from typing import Any, Callable, List, TypeVar __all__: List[str] diff --git a/stdlib/3/asyncio/futures.pyi b/stdlib/3/asyncio/futures.pyi index 37bd02c30fcd..4ebaa339ed92 100644 --- a/stdlib/3/asyncio/futures.pyi +++ b/stdlib/3/asyncio/futures.pyi @@ -1,5 +1,5 @@ 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, diff --git a/stdlib/3/asyncio/locks.pyi b/stdlib/3/asyncio/locks.pyi index 56b8a672718a..3e30cc528533 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, List, Type, TypeVar, Union, Optional, Awaitable from .coroutines import coroutine from .events import AbstractEventLoop diff --git a/stdlib/3/asyncio/queues.pyi b/stdlib/3/asyncio/queues.pyi index 243a74d54201..cae88d10cea1 100644 --- a/stdlib/3/asyncio/queues.pyi +++ b/stdlib/3/asyncio/queues.pyi @@ -1,7 +1,5 @@ -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] diff --git a/stdlib/3/asyncio/tasks.pyi b/stdlib/3/asyncio/tasks.pyi index 05b590eb0430..d848abb39e53 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 diff --git a/stdlib/3/asyncio/transports.pyi b/stdlib/3/asyncio/transports.pyi index ea6ab4adb67b..b2ee08a9c42f 100644 --- a/stdlib/3/asyncio/transports.pyi +++ b/stdlib/3/asyncio/transports.pyi @@ -1,5 +1,5 @@ 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] 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..8cd037eabc35 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 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/functools.pyi b/stdlib/3/functools.pyi index ce89e7173154..f1e43a5bb2f8 100644 --- a/stdlib/3/functools.pyi +++ b/stdlib/3/functools.pyi @@ -1,4 +1,3 @@ -import sys from typing import Any, Callable, Generic, Dict, Iterable, Mapping, Optional, Sequence, Tuple, Type, TypeVar, NamedTuple, Union, overload _AnyCallable = Callable[..., Any] 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..874b85057bc5 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: ... 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/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/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..f99720f46ed1 100644 --- a/stdlib/3/multiprocessing/__init__.pyi +++ b/stdlib/3/multiprocessing/__init__.pyi @@ -1,9 +1,6 @@ # Stubs for multiprocessing -from typing import ( - Any, Callable, ContextManager, Iterable, Mapping, Optional, Dict, List, - Union, Sequence, Tuple, Type, overload -) +from typing import Any, Callable, Iterable, Mapping, Optional, List, Union, Sequence, Tuple, Type, overload from ctypes import _CData from logging import Logger diff --git a/stdlib/3/multiprocessing/context.pyi b/stdlib/3/multiprocessing/context.pyi index 2cdeb07d14cc..8486626ca253 100644 --- a/stdlib/3/multiprocessing/context.pyi +++ b/stdlib/3/multiprocessing/context.pyi @@ -5,10 +5,7 @@ import multiprocessing from multiprocessing import synchronize from multiprocessing import queues 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] 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/pool.pyi b/stdlib/3/multiprocessing/pool.pyi index 3782a3f1dc4b..479c4f21834d 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') diff --git a/stdlib/3/os/__init__.pyi b/stdlib/3/os/__init__.pyi index 085000a0922f..e94c36efe08b 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 ) 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/posix.pyi b/stdlib/3/posix.pyi index 83537cfbc650..fe9782354c94 100644 --- a/stdlib/3/posix.pyi +++ b/stdlib/3/posix.pyi @@ -3,7 +3,7 @@ # 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 diff --git a/stdlib/3/smtplib.pyi b/stdlib/3/smtplib.pyi index d13439b385d5..803b010bd7a0 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] diff --git a/stdlib/3/stat.pyi b/stdlib/3/stat.pyi index c45a06863e2f..74bc444154c1 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: ... diff --git a/stdlib/3/string.pyi b/stdlib/3/string.pyi index 92fc03611db6..c5b1ff9f8c22 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 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/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/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/parse.pyi b/stdlib/3/urllib/parse.pyi index 952d3cf9e346..7252b227663a 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] 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') From d82d3396e7c42f262e4af37a6606bf992ab0e9cb Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 8 Oct 2019 17:42:36 +0200 Subject: [PATCH 05/59] Minor flake8 improvements (#3324) * Update flake8-bugbear * Remove unnecessary comment * Add a comment about an upcoming fix --- .flake8 | 4 +--- requirements-tests-py3.txt | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) 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/requirements-tests-py3.txt b/requirements-tests-py3.txt index 34c3a46716aa..e5e3ba7da6d9 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 From 4027add6b3fa1e34b8bf67070dabba15b1e22443 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Wed, 9 Oct 2019 00:06:38 +0530 Subject: [PATCH 06/59] __init__.pyi: Add missing methods on pkg_resources.VersionConflict (#3318) --- third_party/3/pkg_resources/__init__.pyi | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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): From 50961d45a1e4ed477044dce5df580132beaad42d Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 8 Oct 2019 22:59:07 -0700 Subject: [PATCH 07/59] protobuf: Add Message.FromString static method. (#3327) --- third_party/2and3/google/protobuf/message.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third_party/2and3/google/protobuf/message.pyi b/third_party/2and3/google/protobuf/message.pyi index 4bf8cabfb282..c00c878fbbb0 100644 --- a/third_party/2and3/google/protobuf/message.pyi +++ b/third_party/2and3/google/protobuf/message.pyi @@ -1,4 +1,4 @@ -from typing import Any, Sequence, Optional, Tuple +from typing import Any, Sequence, Optional, Tuple, Type, TypeVar from .descriptor import ( DescriptorBase, @@ -13,6 +13,8 @@ class _ExtensionDict: def __getitem__(self, extension_handle: DescriptorBase) -> Any: ... def __setitem__(self, extension_handle: DescriptorBase, value: Any) -> None: ... +_T = TypeVar("_T") + class Message: DESCRIPTOR: Any def __deepcopy__(self, memo=...): ... @@ -31,6 +33,8 @@ class Message: def HasExtension(self, extension_handle): ... def ClearExtension(self, extension_handle): ... def ByteSize(self) -> int: ... + @classmethod + def FromString(cls: Type[_T], s: Any) -> _T: ... @property def Extensions(self) -> _ExtensionDict: ... From 3ee8fc2242ce2dee0861ae53bb01b1c24c64c794 Mon Sep 17 00:00:00 2001 From: robertschweizer Date: Wed, 9 Oct 2019 08:38:46 +0200 Subject: [PATCH 08/59] Add missing Optional types in urllib.parse (#3263) None values are accepted, and interpreted as empty (byte) strings by some urllib.parse functions. --- stdlib/3/urllib/parse.pyi | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/stdlib/3/urllib/parse.pyi b/stdlib/3/urllib/parse.pyi index 7252b227663a..b08ca0937c2c 100644 --- a/stdlib/3/urllib/parse.pyi +++ b/stdlib/3/urllib/parse.pyi @@ -80,9 +80,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 @@ -106,7 +106,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]]]], @@ -120,21 +120,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: ... From 824e94a933b94d2401c4039f6cabe8f1c73ae4d0 Mon Sep 17 00:00:00 2001 From: wouter bolsterlee Date: Wed, 9 Oct 2019 08:44:41 +0200 Subject: [PATCH 09/59] Make 2-arg iter() retrun type match passed callable's return type (#3326) This is a continuation of #3291, which was the initial fix for #3201. The 2-arg version of iter() turns a callable into an iterator. The changes made in #3291 introduce an Any return type for both the callable's return type and the iterator's type, while in reality the return type of the function is always the same as the iterator's type. --- stdlib/2/__builtin__.pyi | 2 +- stdlib/2and3/builtins.pyi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 966e150897eb..166e4e3d9df9 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -1193,7 +1193,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: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 966e150897eb..166e4e3d9df9 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -1193,7 +1193,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: ... From 0914d50b498c38dfc86337f40d4327592aded8a8 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Wed, 9 Oct 2019 15:58:37 +0100 Subject: [PATCH 10/59] Fix the signature of decorator.contextmanager (#3330) --- third_party/2and3/decorator.pyi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/decorator.pyi b/third_party/2and3/decorator.pyi index 18c919f87ddd..ee090a6b9d68 100644 --- a/third_party/2and3/decorator.pyi +++ b/third_party/2and3/decorator.pyi @@ -1,8 +1,9 @@ import sys -from typing import Any, Callable, Dict, List, NamedTuple, Optional, Pattern, Text, Tuple, TypeVar +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): ... @@ -76,8 +77,8 @@ class FunctionMaker(object): def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ... def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[_C], _C]: ... -class ContextManager(_GeneratorContextManager[Any]): +class ContextManager(_GeneratorContextManager[_T]): def __call__(self, func: _C) -> _C: ... -def contextmanager(func: _C) -> _C: ... +def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... def dispatch_on(*dispatch_args: Any) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ... From 3a2fdfd45de3cbf9db4217c741cfb3ec10dd896c Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Wed, 9 Oct 2019 16:20:36 +0100 Subject: [PATCH 11/59] Make it explicit that the cryptography stubs are incomplete (#3331) --- third_party/2and3/cryptography/__init__.pyi | 3 +++ third_party/2and3/cryptography/hazmat/__init__.pyi | 3 +++ third_party/2and3/cryptography/hazmat/primitives/__init__.pyi | 3 +++ .../cryptography/hazmat/primitives/asymmetric/__init__.pyi | 3 +++ 4 files changed, 12 insertions(+) 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: ... From bd7222c39669cd166f9885318b3ede779e7c2edc Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Wed, 9 Oct 2019 22:31:30 +0530 Subject: [PATCH 12/59] models.pyi: Add missing requests.Respons.next() (#3328) Closes: #3207 --- third_party/2and3/requests/models.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/2and3/requests/models.pyi b/third_party/2and3/requests/models.pyi index adc64318f57a..ae62c79af800 100644 --- a/third_party/2and3/requests/models.pyi +++ b/third_party/2and3/requests/models.pyi @@ -117,6 +117,7 @@ class Response: def __iter__(self) -> Iterator[bytes]: ... def __enter__(self) -> Response: ... def __exit__(self, *args: Any) -> None: ... + def next(self) -> Optional[PreparedRequest]: ... @property def ok(self) -> bool: ... @property From 07c8675ba506986afad92bcdf1733000872a606b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 9 Oct 2019 19:27:18 +0200 Subject: [PATCH 13/59] Remove unused # type: ignore comments (#3325) --- stdlib/2/UserString.pyi | 2 +- stdlib/2/__builtin__.pyi | 17 ++++++----------- stdlib/2and3/builtins.pyi | 17 ++++++----------- stdlib/3/configparser.pyi | 2 +- stdlib/3/enum.pyi | 4 +--- stdlib/3/multiprocessing/context.pyi | 8 ++++---- third_party/2/enum.pyi | 4 +--- 7 files changed, 20 insertions(+), 34 deletions(-) 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 166e4e3d9df9..22299e34a707 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -1160,20 +1160,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]: ... @@ -1383,7 +1378,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: diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 166e4e3d9df9..22299e34a707 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -1160,20 +1160,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]: ... @@ -1383,7 +1378,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: 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/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/multiprocessing/context.pyi b/stdlib/3/multiprocessing/context.pyi index 8486626ca253..3059e88ce3f3 100644 --- a/stdlib/3/multiprocessing/context.pyi +++ b/stdlib/3/multiprocessing/context.pyi @@ -128,19 +128,19 @@ class DefaultContext(object): if sys.platform != 'win32': # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class ForkProcess(Any): # type: ignore + class ForkProcess(Any): _start_method: str @staticmethod def _Popen(process_obj: Any) -> Any: ... # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class SpawnProcess(Any): # type: ignore + class SpawnProcess(Any): _start_method: str @staticmethod def _Popen(process_obj: Any) -> SpawnProcess: ... # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class ForkServerProcess(Any): # type: ignore + class ForkServerProcess(Any): _start_method: str @staticmethod def _Popen(process_obj: Any) -> Any: ... @@ -158,7 +158,7 @@ if sys.platform != 'win32': Process: Type[ForkServerProcess] else: # TODO: type should be BaseProcess once a stub in multiprocessing.process exists - class SpawnProcess(Any): # type: ignore + class SpawnProcess(Any): _start_method: str @staticmethod # TODO: type should be BaseProcess once a stub in multiprocessing.process exists 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: ... From f0ccb325aa787ca0a539ef9914276b2c3148327a Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Wed, 9 Oct 2019 10:38:59 -0700 Subject: [PATCH 14/59] Mark some urllib.parse return fields optional (#3332) Per the urllib.parse documentation, username, password, hostname, and port will be set to None if not set in the parsed URL. The same is true for urlparse in Python 2 according to its documentation. --- stdlib/2/urlparse.pyi | 10 +++++----- stdlib/3/urllib/parse.pyi | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stdlib/2/urlparse.pyi b/stdlib/2/urlparse.pyi index fb5909503290..f1d1e3f2816d 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,13 +17,13 @@ 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( diff --git a/stdlib/3/urllib/parse.pyi b/stdlib/3/urllib/parse.pyi index b08ca0937c2c..7f8120ad4aa8 100644 --- a/stdlib/3/urllib/parse.pyi +++ b/stdlib/3/urllib/parse.pyi @@ -25,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): ... From 57384ce0338e32763f148e3f493f78631c9b0740 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Thu, 10 Oct 2019 05:28:42 +0300 Subject: [PATCH 15/59] Revised stubs for geoip2 third party library (#3317) --- stdlib/3/ipaddress.pyi | 20 +-- tests/check_consistent.py | 1 + third_party/2/ipaddress.pyi | 149 ++++++++++++++++++ third_party/2and3/geoip2/__init__.pyi | 0 third_party/2and3/geoip2/database.pyi | 22 +++ third_party/2and3/geoip2/errors.pyi | 18 +++ third_party/2and3/geoip2/mixins.pyi | 3 + third_party/2and3/geoip2/models.pyi | 65 ++++++++ third_party/2and3/geoip2/records.pyi | 83 ++++++++++ third_party/2and3/maxminddb/__init__.pyi | 7 + third_party/{3 => 2and3}/maxminddb/compat.pyi | 2 - third_party/{3 => 2and3}/maxminddb/const.pyi | 2 - .../{3 => 2and3}/maxminddb/decoder.pyi | 2 - third_party/{3 => 2and3}/maxminddb/errors.pyi | 2 - .../{3 => 2and3}/maxminddb/extension.pyi | 10 +- third_party/{3 => 2and3}/maxminddb/reader.pyi | 14 +- third_party/3/maxminddb/__init__.pyi | 9 -- 17 files changed, 368 insertions(+), 41 deletions(-) create mode 100644 third_party/2/ipaddress.pyi create mode 100644 third_party/2and3/geoip2/__init__.pyi create mode 100644 third_party/2and3/geoip2/database.pyi create mode 100644 third_party/2and3/geoip2/errors.pyi create mode 100644 third_party/2and3/geoip2/mixins.pyi create mode 100644 third_party/2and3/geoip2/models.pyi create mode 100644 third_party/2and3/geoip2/records.pyi create mode 100644 third_party/2and3/maxminddb/__init__.pyi rename third_party/{3 => 2and3}/maxminddb/compat.pyi (85%) rename third_party/{3 => 2and3}/maxminddb/const.pyi (76%) rename third_party/{3 => 2and3}/maxminddb/decoder.pyi (83%) rename third_party/{3 => 2and3}/maxminddb/errors.pyi (52%) rename third_party/{3 => 2and3}/maxminddb/extension.pyi (80%) rename third_party/{3 => 2and3}/maxminddb/reader.pyi (66%) delete mode 100644 third_party/3/maxminddb/__init__.pyi 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/tests/check_consistent.py b/tests/check_consistent.py index 161cea2d84b7..afe81869bf6e 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -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/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/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/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/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: ... From 1a932ce26abd65a8a23b438fbd8b738d88930d9b Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Thu, 10 Oct 2019 15:54:44 +0530 Subject: [PATCH 16/59] message.pyi: Change HeaderType to Any (#2924) Fixes #2863 --- stdlib/3/email/message.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/email/message.pyi b/stdlib/3/email/message.pyi index 8cd037eabc35..36b2fdc65200 100644 --- a/stdlib/3/email/message.pyi +++ b/stdlib/3/email/message.pyi @@ -15,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] @@ -33,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]: ... From eca93753ee7a0146c48db10a0b201d9c7dbfe153 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 10 Oct 2019 16:45:06 +0100 Subject: [PATCH 17/59] Update the signature of decorator.decorator (#3336) Nothing prevents a decorator defined using `@decorator` from changing the signature of the decorated function. For example, this example changes the return type to `str`: ``` from decorator import decorator @decorator def stringify(f, *args, **kwargs) -> str: return str(f(*args, **kwargs)) ``` The old signature caused false positives in internal Dropbox code. I couldn't come up with a signature that would produce better types with mypy while not generating false positives. --- third_party/2and3/decorator.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/2and3/decorator.pyi b/third_party/2and3/decorator.pyi index ee090a6b9d68..3443cd78b8d0 100644 --- a/third_party/2and3/decorator.pyi +++ b/third_party/2and3/decorator.pyi @@ -75,7 +75,7 @@ class FunctionMaker(object): ) -> Callable[..., Any]: ... def decorate(func: _Func, caller: Callable[..., Any], extras: Any = ...) -> _Func: ... -def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[_C], _C]: ... +def decorator(caller: Callable[..., Any], _func: Optional[Callable[..., Any]] = ...) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ... class ContextManager(_GeneratorContextManager[_T]): def __call__(self, func: _C) -> _C: ... From fc23c8274f6fd3595037a5b8d771f2ac382a9f2c Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 10 Oct 2019 09:07:53 -0700 Subject: [PATCH 18/59] protobuf: Tighten annotations for MergeFromString and ParseFromString. (#3333) --- third_party/2and3/google/protobuf/message.pyi | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/google/protobuf/message.pyi b/third_party/2and3/google/protobuf/message.pyi index c00c878fbbb0..2265e0356ff4 100644 --- a/third_party/2and3/google/protobuf/message.pyi +++ b/third_party/2and3/google/protobuf/message.pyi @@ -1,4 +1,6 @@ -from typing import Any, Sequence, Optional, Tuple, Type, TypeVar +import sys + +from typing import Any, Sequence, Optional, Tuple, Type, TypeVar, Union from .descriptor import ( DescriptorBase, @@ -15,6 +17,11 @@ class _ExtensionDict: _T = TypeVar("_T") +if sys.version_info < (3,): + _Serialized = Union[bytes, buffer, unicode] +else: + _Serialized = bytes + class Message: DESCRIPTOR: Any def __deepcopy__(self, memo=...): ... @@ -25,8 +32,8 @@ 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]]: ... From d0beab9b8ee75435258a2e41e88571d70d88a8b2 Mon Sep 17 00:00:00 2001 From: Martin DeMello Date: Thu, 10 Oct 2019 20:13:20 -0700 Subject: [PATCH 19/59] Fix an argument to csv.DictReader() (#3339) From the Lib/csv.py source, 'f' is passed directly to _csv.reader, which expects Iterable[Text] --- stdlib/2and3/csv.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: ... From 8a7d61741dddffe2b2c8a9978303be4aa4905d13 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Oct 2019 05:51:27 +0200 Subject: [PATCH 20/59] Python3.8 additions and changes (#3337) * Add as_integer_ratio() to a few types * Add dirs_exist_ok to copytree() * int, float, complex accept __index__ args Also fix complex.__init__ argument names * Add __reversed__ to dict et al. * Python 3.8 date(time) arithmetic fixes * Add CodeType.replace() --- stdlib/2/__builtin__.pyi | 24 ++++++++++++++++-------- stdlib/2and3/builtins.pyi | 24 ++++++++++++++++-------- stdlib/2and3/datetime.pyi | 33 ++++++++++++++++++++++++--------- stdlib/2and3/fractions.pyi | 4 +++- stdlib/2and3/shutil.pyi | 12 +++++++++++- stdlib/3/types.pyi | 21 +++++++++++++++++++++ stdlib/3/typing.pyi | 6 ++++++ 7 files changed, 97 insertions(+), 27 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 22299e34a707..ebbf032d6bbe 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -17,6 +17,11 @@ 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: ... @@ -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): diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index 22299e34a707..ebbf032d6bbe 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -17,6 +17,11 @@ 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: ... @@ -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): diff --git a/stdlib/2and3/datetime.pyi b/stdlib/2and3/datetime.pyi index df3fda4a3ae4..c462962e4673 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 @@ -68,7 +67,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 @@ -227,8 +229,16 @@ class datetime(date): def today(cls) -> datetime: ... @classmethod def fromordinal(cls, n: int) -> datetime: ... - @classmethod - def now(cls, tz: Optional[_tzinfo] = ...) -> datetime: ... + 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: ... if sys.version_info >= (3, 6): @@ -261,7 +271,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 +291,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/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/shutil.pyi b/stdlib/2and3/shutil.pyi index 98761d046f76..81ef46f565f2 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]], diff --git a/stdlib/3/types.pyi b/stdlib/3/types.pyi index 61f87832ad9e..e1270afa5dc2 100644 --- a/stdlib/3/types.pyi +++ b/stdlib/3/types.pyi @@ -72,6 +72,27 @@ class CodeType: 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..e6aa5465d735 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -339,6 +339,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 +353,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 +365,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]): From d41bcd39e13271463014adde80f290194764bbca Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Oct 2019 05:51:49 +0200 Subject: [PATCH 21/59] Add assorted annotations (#3335) * Add assorted annotations * Fix type of Purpose items --- stdlib/2and3/ssl.pyi | 20 +++++++++----------- stdlib/3/http/client.pyi | 18 +++++++++++------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/stdlib/2and3/ssl.pyi b/stdlib/2and3/ssl.pyi index 3e358f356004..62a1cbf38d28 100644 --- a/stdlib/2and3/ssl.pyi +++ b/stdlib/2and3/ssl.pyi @@ -181,8 +181,8 @@ if sys.version_info < (3,): 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 @@ -208,17 +208,15 @@ class SSLSocket(socket.socket): def version(self) -> Optional[str]: ... def pending(self) -> int: ... - 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 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 From 9b0922166ab16f995c7a7c407bb077e3f9484a25 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Oct 2019 05:51:56 +0200 Subject: [PATCH 22/59] Allow callables in _SourceObjectType (Python 2) (#3338) This is important because mypy doesn't generally think functions are compatible with `FunctionType`, so `inspect.getsource` on arbitrary functions is rejected by the current annotations. --- stdlib/2/inspect.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2/inspect.pyi b/stdlib/2/inspect.pyi index 67be3a41a7c9..b1acc30407cb 100644 --- a/stdlib/2/inspect.pyi +++ b/stdlib/2/inspect.pyi @@ -52,7 +52,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: ... From 036abc7fda9290e29d978d62b00e03b67a2a6fd1 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 10 Oct 2019 23:28:28 -0700 Subject: [PATCH 23/59] protobuf: Narrow type of Message.FromString. (#3340) Remove unnecessary definitions in sub-classes. --- third_party/2and3/google/protobuf/any_pb2.pyi | 4 +- .../2and3/google/protobuf/any_test_pb2.pyi | 4 +- third_party/2and3/google/protobuf/api_pb2.pyi | 10 +- .../google/protobuf/compiler/plugin_pb2.pyi | 14 +- .../2and3/google/protobuf/descriptor_pb2.pyi | 93 +---- .../2and3/google/protobuf/duration_pb2.pyi | 4 +- .../2and3/google/protobuf/empty_pb2.pyi | 4 +- .../2and3/google/protobuf/field_mask_pb2.pyi | 4 +- .../protobuf/map_proto2_unittest_pb2.pyi | 73 +--- .../google/protobuf/map_unittest_pb2.pyi | 168 +------- third_party/2and3/google/protobuf/message.pyi | 2 +- .../google/protobuf/source_context_pb2.pyi | 4 +- .../2and3/google/protobuf/struct_pb2.pyi | 13 +- .../protobuf/test_messages_proto2_pb2.pyi | 164 +------- .../protobuf/test_messages_proto3_pb2.pyi | 131 +----- .../2and3/google/protobuf/timestamp_pb2.pyi | 4 +- .../2and3/google/protobuf/type_pb2.pyi | 16 +- .../google/protobuf/unittest_arena_pb2.pyi | 7 +- .../protobuf/unittest_custom_options_pb2.pyi | 89 +--- .../google/protobuf/unittest_import_pb2.pyi | 4 +- .../protobuf/unittest_import_public_pb2.pyi | 4 +- .../google/protobuf/unittest_mset_pb2.pyi | 16 +- .../unittest_mset_wire_format_pb2.pyi | 7 +- .../protobuf/unittest_no_arena_import_pb2.pyi | 4 +- .../google/protobuf/unittest_no_arena_pb2.pyi | 82 +--- .../unittest_no_generic_services_pb2.pyi | 4 +- .../2and3/google/protobuf/unittest_pb2.pyi | 388 +----------------- .../protobuf/unittest_proto3_arena_pb2.pyi | 63 +-- .../protobuf/util/json_format_proto3_pb2.pyi | 95 +---- .../2and3/google/protobuf/wrappers_pb2.pyi | 28 +- 30 files changed, 30 insertions(+), 1473 deletions(-) diff --git a/third_party/2and3/google/protobuf/any_pb2.pyi b/third_party/2and3/google/protobuf/any_pb2.pyi index c2a7295a9725..667acf070209 100644 --- a/third_party/2and3/google/protobuf/any_pb2.pyi +++ b/third_party/2and3/google/protobuf/any_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -17,6 +18,3 @@ class Any(Message, well_known_types.Any_): type_url: Optional[Text] = ..., value: Optional[bytes] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Any: ... diff --git a/third_party/2and3/google/protobuf/any_test_pb2.pyi b/third_party/2and3/google/protobuf/any_test_pb2.pyi index d352badb3418..f1ac04db8471 100644 --- a/third_party/2and3/google/protobuf/any_test_pb2.pyi +++ b/third_party/2and3/google/protobuf/any_test_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.any_pb2 import ( Any, ) @@ -27,6 +28,3 @@ class TestAny(Message): any_value: Optional[Any] = ..., repeated_any_value: Optional[Iterable[Any]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestAny: ... diff --git a/third_party/2and3/google/protobuf/api_pb2.pyi b/third_party/2and3/google/protobuf/api_pb2.pyi index 36468780e0e5..6f4d791f4ac0 100644 --- a/third_party/2and3/google/protobuf/api_pb2.pyi +++ b/third_party/2and3/google/protobuf/api_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, ) @@ -45,9 +46,6 @@ class Api(Message): syntax: Optional[Syntax] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Api: ... - class Method(Message): name: Text @@ -70,9 +68,6 @@ class Method(Message): syntax: Optional[Syntax] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Method: ... - class Mixin(Message): name: Text @@ -82,6 +77,3 @@ class Mixin(Message): name: Optional[Text] = ..., root: Optional[Text] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Mixin: ... diff --git a/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi b/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi index d1037fa3a483..63667b05cb49 100644 --- a/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi +++ b/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.descriptor_pb2 import ( FileDescriptorProto, ) @@ -28,9 +29,6 @@ class Version(Message): suffix: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Version: ... - class CodeGeneratorRequest(Message): file_to_generate: RepeatedScalarFieldContainer[Text] @@ -49,9 +47,6 @@ class CodeGeneratorRequest(Message): compiler_version: Optional[Version] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CodeGeneratorRequest: ... - class CodeGeneratorResponse(Message): @@ -66,10 +61,6 @@ class CodeGeneratorResponse(Message): content: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CodeGeneratorResponse.File: ... - error: Text - @property def file(self) -> RepeatedCompositeFieldContainer[CodeGeneratorResponse.File]: ... @@ -77,6 +68,3 @@ class CodeGeneratorResponse(Message): error: Optional[Text] = ..., file: Optional[Iterable[CodeGeneratorResponse.File]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> CodeGeneratorResponse: ... diff --git a/third_party/2and3/google/protobuf/descriptor_pb2.pyi b/third_party/2and3/google/protobuf/descriptor_pb2.pyi index d0fbcdc2f865..540f7218cbd2 100644 --- a/third_party/2and3/google/protobuf/descriptor_pb2.pyi +++ b/third_party/2and3/google/protobuf/descriptor_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer, @@ -24,9 +25,6 @@ class FileDescriptorSet(Message): file: Optional[Iterable[FileDescriptorProto]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FileDescriptorSet: ... - class FileDescriptorProto(Message): name: Text @@ -73,9 +71,6 @@ class FileDescriptorProto(Message): syntax: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FileDescriptorProto: ... - class DescriptorProto(Message): @@ -92,9 +87,6 @@ class DescriptorProto(Message): options: Optional[ExtensionRangeOptions] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> DescriptorProto.ExtensionRange: ... - class ReservedRange(Message): start: int end: int @@ -104,11 +96,6 @@ class DescriptorProto(Message): end: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> DescriptorProto.ReservedRange: ... - name: Text - reserved_name: RepeatedScalarFieldContainer[Text] - @property def field( self) -> RepeatedCompositeFieldContainer[FieldDescriptorProto]: ... @@ -153,9 +140,6 @@ class DescriptorProto(Message): reserved_name: Optional[Iterable[Text]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> DescriptorProto: ... - class ExtensionRangeOptions(Message): @@ -167,9 +151,6 @@ class ExtensionRangeOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ExtensionRangeOptions: ... - class FieldDescriptorProto(Message): @@ -253,9 +234,6 @@ class FieldDescriptorProto(Message): options: Optional[FieldOptions] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FieldDescriptorProto: ... - class OneofDescriptorProto(Message): name: Text @@ -268,9 +246,6 @@ class OneofDescriptorProto(Message): options: Optional[OneofOptions] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> OneofDescriptorProto: ... - class EnumDescriptorProto(Message): @@ -283,12 +258,6 @@ class EnumDescriptorProto(Message): end: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> EnumDescriptorProto.EnumReservedRange: ... - name: Text - reserved_name: RepeatedScalarFieldContainer[Text] - @property def value( self) -> RepeatedCompositeFieldContainer[EnumValueDescriptorProto]: ... @@ -308,9 +277,6 @@ class EnumDescriptorProto(Message): reserved_name: Optional[Iterable[Text]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> EnumDescriptorProto: ... - class EnumValueDescriptorProto(Message): name: Text @@ -325,9 +291,6 @@ class EnumValueDescriptorProto(Message): options: Optional[EnumValueOptions] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> EnumValueDescriptorProto: ... - class ServiceDescriptorProto(Message): name: Text @@ -345,9 +308,6 @@ class ServiceDescriptorProto(Message): options: Optional[ServiceOptions] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ServiceDescriptorProto: ... - class MethodDescriptorProto(Message): name: Text @@ -368,9 +328,6 @@ class MethodDescriptorProto(Message): server_streaming: Optional[bool] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MethodDescriptorProto: ... - class FileOptions(Message): @@ -438,9 +395,6 @@ class FileOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FileOptions: ... - class MessageOptions(Message): message_set_wire_format: bool @@ -460,9 +414,6 @@ class MessageOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MessageOptions: ... - class FieldOptions(Message): @@ -526,9 +477,6 @@ class FieldOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FieldOptions: ... - class OneofOptions(Message): @@ -540,9 +488,6 @@ class OneofOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> OneofOptions: ... - class EnumOptions(Message): allow_alias: bool @@ -558,9 +503,6 @@ class EnumOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> EnumOptions: ... - class EnumValueOptions(Message): deprecated: bool @@ -574,9 +516,6 @@ class EnumValueOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> EnumValueOptions: ... - class ServiceOptions(Message): deprecated: bool @@ -590,9 +529,6 @@ class ServiceOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ServiceOptions: ... - class MethodOptions(Message): @@ -628,9 +564,6 @@ class MethodOptions(Message): uninterpreted_option: Optional[Iterable[UninterpretedOption]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MethodOptions: ... - class UninterpretedOption(Message): @@ -643,15 +576,6 @@ class UninterpretedOption(Message): is_extension: bool, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> UninterpretedOption.NamePart: ... - 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]: ... @@ -666,9 +590,6 @@ class UninterpretedOption(Message): aggregate_value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> UninterpretedOption: ... - class SourceCodeInfo(Message): @@ -687,9 +608,6 @@ class SourceCodeInfo(Message): leading_detached_comments: Optional[Iterable[Text]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> SourceCodeInfo.Location: ... - @property def location( self) -> RepeatedCompositeFieldContainer[SourceCodeInfo.Location]: ... @@ -698,9 +616,6 @@ class SourceCodeInfo(Message): location: Optional[Iterable[SourceCodeInfo.Location]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> SourceCodeInfo: ... - class GeneratedCodeInfo(Message): @@ -717,9 +632,6 @@ class GeneratedCodeInfo(Message): end: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> GeneratedCodeInfo.Annotation: ... - @property def annotation( self) -> RepeatedCompositeFieldContainer[GeneratedCodeInfo.Annotation]: ... @@ -727,6 +639,3 @@ class GeneratedCodeInfo(Message): def __init__(self, annotation: Optional[Iterable[GeneratedCodeInfo.Annotation]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> GeneratedCodeInfo: ... diff --git a/third_party/2and3/google/protobuf/duration_pb2.pyi b/third_party/2and3/google/protobuf/duration_pb2.pyi index 378c2e57ce01..b617ac7a892e 100644 --- a/third_party/2and3/google/protobuf/duration_pb2.pyi +++ b/third_party/2and3/google/protobuf/duration_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -16,6 +17,3 @@ class Duration(Message, well_known_types.Duration): seconds: Optional[int] = ..., nanos: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Duration: ... diff --git a/third_party/2and3/google/protobuf/empty_pb2.pyi b/third_party/2and3/google/protobuf/empty_pb2.pyi index 295ebfa938be..e14a141ece64 100644 --- a/third_party/2and3/google/protobuf/empty_pb2.pyi +++ b/third_party/2and3/google/protobuf/empty_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -7,6 +8,3 @@ class Empty(Message): def __init__(self, ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Empty: ... diff --git a/third_party/2and3/google/protobuf/field_mask_pb2.pyi b/third_party/2and3/google/protobuf/field_mask_pb2.pyi index 1c96a02bbe1e..140824322a31 100644 --- a/third_party/2and3/google/protobuf/field_mask_pb2.pyi +++ b/third_party/2and3/google/protobuf/field_mask_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedScalarFieldContainer, ) @@ -19,6 +20,3 @@ class FieldMask(Message, well_known_types.FieldMask): def __init__(self, paths: Optional[Iterable[Text]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> FieldMask: ... 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..9a589625f4db 100644 --- a/third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/map_proto2_unittest_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -69,9 +70,6 @@ class TestEnumMap(Message): value: Optional[Proto2MapEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEnumMap.KnownMapFieldEntry: ... - class UnknownMapFieldEntry(Message): key: int value: Proto2MapEnum @@ -81,9 +79,6 @@ class TestEnumMap(Message): value: Optional[Proto2MapEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEnumMap.UnknownMapFieldEntry: ... - @property def known_map_field(self) -> MutableMapping[int, Proto2MapEnum]: ... @@ -95,9 +90,6 @@ class TestEnumMap(Message): unknown_map_field: Optional[Mapping[int, Proto2MapEnum]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEnumMap: ... - class TestEnumMapPlusExtra(Message): @@ -110,9 +102,6 @@ class TestEnumMapPlusExtra(Message): value: Optional[Proto2MapEnumPlusExtra] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEnumMapPlusExtra.KnownMapFieldEntry: ... - class UnknownMapFieldEntry(Message): key: int value: Proto2MapEnumPlusExtra @@ -122,9 +111,6 @@ class TestEnumMapPlusExtra(Message): value: Optional[Proto2MapEnumPlusExtra] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEnumMapPlusExtra.UnknownMapFieldEntry: ... - @property def known_map_field(self) -> MutableMapping[int, Proto2MapEnumPlusExtra]: ... @@ -136,9 +122,6 @@ class TestEnumMapPlusExtra(Message): unknown_map_field: Optional[Mapping[int, Proto2MapEnumPlusExtra]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEnumMapPlusExtra: ... - class TestImportEnumMap(Message): @@ -151,9 +134,6 @@ class TestImportEnumMap(Message): value: Optional[ImportEnumForMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestImportEnumMap.ImportEnumAmpEntry: ... - @property def import_enum_amp(self) -> MutableMapping[int, ImportEnumForMap]: ... @@ -161,9 +141,6 @@ class TestImportEnumMap(Message): import_enum_amp: Optional[Mapping[int, ImportEnumForMap]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestImportEnumMap: ... - class TestIntIntMap(Message): @@ -176,9 +153,6 @@ class TestIntIntMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestIntIntMap.MEntry: ... - @property def m(self) -> MutableMapping[int, int]: ... @@ -186,9 +160,6 @@ class TestIntIntMap(Message): m: Optional[Mapping[int, int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestIntIntMap: ... - class TestMaps(Message): @@ -203,9 +174,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MInt32Entry: ... - class MInt64Entry(Message): key: int @@ -217,9 +185,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MInt64Entry: ... - class MUint32Entry(Message): key: int @@ -231,9 +196,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MUint32Entry: ... - class MUint64Entry(Message): key: int @@ -245,9 +207,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MUint64Entry: ... - class MSint32Entry(Message): key: int @@ -259,9 +218,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSint32Entry: ... - class MSint64Entry(Message): key: int @@ -273,9 +229,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSint64Entry: ... - class MFixed32Entry(Message): key: int @@ -287,9 +240,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MFixed32Entry: ... - class MFixed64Entry(Message): key: int @@ -301,9 +251,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MFixed64Entry: ... - class MSfixed32Entry(Message): key: int @@ -315,9 +262,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSfixed32Entry: ... - class MSfixed64Entry(Message): key: int @@ -329,9 +273,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MSfixed64Entry: ... - class MBoolEntry(Message): key: bool @@ -343,9 +284,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MBoolEntry: ... - class MStringEntry(Message): key: Text @@ -357,9 +295,6 @@ class TestMaps(Message): value: Optional[TestIntIntMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps.MStringEntry: ... - @property def m_int32(self) -> MutableMapping[int, TestIntIntMap]: ... @@ -411,9 +346,6 @@ class TestMaps(Message): m_string: Optional[Mapping[Text, TestIntIntMap]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMaps: ... - class TestSubmessageMaps(Message): @@ -423,6 +355,3 @@ class TestSubmessageMaps(Message): def __init__(self, m: Optional[TestMaps] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestSubmessageMaps: ... diff --git a/third_party/2and3/google/protobuf/map_unittest_pb2.pyi b/third_party/2and3/google/protobuf/map_unittest_pb2.pyi index 25058bbde6d4..cf65da3dcf07 100644 --- a/third_party/2and3/google/protobuf/map_unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/map_unittest_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -54,9 +55,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32Int32Entry: ... - class MapInt64Int64Entry(Message): key: int value: int @@ -66,9 +64,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt64Int64Entry: ... - class MapUint32Uint32Entry(Message): key: int value: int @@ -78,9 +73,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapUint32Uint32Entry: ... - class MapUint64Uint64Entry(Message): key: int value: int @@ -90,9 +82,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapUint64Uint64Entry: ... - class MapSint32Sint32Entry(Message): key: int value: int @@ -102,9 +91,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSint32Sint32Entry: ... - class MapSint64Sint64Entry(Message): key: int value: int @@ -114,9 +100,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSint64Sint64Entry: ... - class MapFixed32Fixed32Entry(Message): key: int value: int @@ -126,9 +109,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapFixed32Fixed32Entry: ... - class MapFixed64Fixed64Entry(Message): key: int value: int @@ -138,9 +118,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapFixed64Fixed64Entry: ... - class MapSfixed32Sfixed32Entry(Message): key: int value: int @@ -150,9 +127,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSfixed32Sfixed32Entry: ... - class MapSfixed64Sfixed64Entry(Message): key: int value: int @@ -162,9 +136,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapSfixed64Sfixed64Entry: ... - class MapInt32FloatEntry(Message): key: int value: float @@ -174,9 +145,6 @@ class TestMap(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32FloatEntry: ... - class MapInt32DoubleEntry(Message): key: int value: float @@ -186,9 +154,6 @@ class TestMap(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32DoubleEntry: ... - class MapBoolBoolEntry(Message): key: bool value: bool @@ -198,9 +163,6 @@ class TestMap(Message): value: Optional[bool] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapBoolBoolEntry: ... - class MapStringStringEntry(Message): key: Text value: Text @@ -210,9 +172,6 @@ class TestMap(Message): value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapStringStringEntry: ... - class MapInt32BytesEntry(Message): key: int value: bytes @@ -222,9 +181,6 @@ class TestMap(Message): value: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32BytesEntry: ... - class MapInt32EnumEntry(Message): key: int value: MapEnum @@ -234,9 +190,6 @@ class TestMap(Message): value: Optional[MapEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32EnumEntry: ... - class MapInt32ForeignMessageEntry(Message): key: int @@ -248,9 +201,6 @@ class TestMap(Message): value: Optional[ForeignMessage1] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32ForeignMessageEntry: ... - class MapStringForeignMessageEntry(Message): key: Text @@ -262,10 +212,6 @@ class TestMap(Message): value: Optional[ForeignMessage1] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestMap.MapStringForeignMessageEntry: ... - class MapInt32AllTypesEntry(Message): key: int @@ -277,9 +223,6 @@ class TestMap(Message): value: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.MapInt32AllTypesEntry: ... - @property def map_int32_int32(self) -> MutableMapping[int, int]: ... @@ -361,9 +304,6 @@ class TestMap(Message): map_int32_all_types: Optional[Mapping[int, TestAllTypes]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap: ... - class TestMapSubmessage(Message): @@ -374,9 +314,6 @@ class TestMapSubmessage(Message): test_map: Optional[TestMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMapSubmessage: ... - class TestMessageMap(Message): @@ -391,9 +328,6 @@ class TestMessageMap(Message): value: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMessageMap.MapInt32MessageEntry: ... - @property def map_int32_message(self) -> MutableMapping[int, TestAllTypes]: ... @@ -401,9 +335,6 @@ class TestMessageMap(Message): map_int32_message: Optional[Mapping[int, TestAllTypes]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMessageMap: ... - class TestSameTypeMap(Message): @@ -416,9 +347,6 @@ class TestSameTypeMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestSameTypeMap.Map1Entry: ... - class Map2Entry(Message): key: int value: int @@ -428,9 +356,6 @@ class TestSameTypeMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestSameTypeMap.Map2Entry: ... - @property def map1(self) -> MutableMapping[int, int]: ... @@ -442,9 +367,6 @@ class TestSameTypeMap(Message): map2: Optional[Mapping[int, int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestSameTypeMap: ... - class TestRequiredMessageMap(Message): @@ -459,10 +381,6 @@ class TestRequiredMessageMap(Message): value: Optional[TestRequired] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestRequiredMessageMap.MapFieldEntry: ... - @property def map_field(self) -> MutableMapping[int, TestRequired]: ... @@ -470,9 +388,6 @@ class TestRequiredMessageMap(Message): map_field: Optional[Mapping[int, TestRequired]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRequiredMessageMap: ... - class TestArenaMap(Message): @@ -485,9 +400,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32Int32Entry: ... - class MapInt64Int64Entry(Message): key: int value: int @@ -497,9 +409,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt64Int64Entry: ... - class MapUint32Uint32Entry(Message): key: int value: int @@ -509,9 +418,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapUint32Uint32Entry: ... - class MapUint64Uint64Entry(Message): key: int value: int @@ -521,9 +427,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapUint64Uint64Entry: ... - class MapSint32Sint32Entry(Message): key: int value: int @@ -533,9 +436,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapSint32Sint32Entry: ... - class MapSint64Sint64Entry(Message): key: int value: int @@ -545,9 +445,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapSint64Sint64Entry: ... - class MapFixed32Fixed32Entry(Message): key: int value: int @@ -557,9 +454,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapFixed32Fixed32Entry: ... - class MapFixed64Fixed64Entry(Message): key: int value: int @@ -569,9 +463,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapFixed64Fixed64Entry: ... - class MapSfixed32Sfixed32Entry(Message): key: int value: int @@ -581,10 +472,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapSfixed32Sfixed32Entry: ... - class MapSfixed64Sfixed64Entry(Message): key: int value: int @@ -594,10 +481,6 @@ class TestArenaMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapSfixed64Sfixed64Entry: ... - class MapInt32FloatEntry(Message): key: int value: float @@ -607,9 +490,6 @@ class TestArenaMap(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32FloatEntry: ... - class MapInt32DoubleEntry(Message): key: int value: float @@ -619,9 +499,6 @@ class TestArenaMap(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32DoubleEntry: ... - class MapBoolBoolEntry(Message): key: bool value: bool @@ -631,9 +508,6 @@ class TestArenaMap(Message): value: Optional[bool] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapBoolBoolEntry: ... - class MapStringStringEntry(Message): key: Text value: Text @@ -643,9 +517,6 @@ class TestArenaMap(Message): value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapStringStringEntry: ... - class MapInt32BytesEntry(Message): key: int value: bytes @@ -655,9 +526,6 @@ class TestArenaMap(Message): value: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32BytesEntry: ... - class MapInt32EnumEntry(Message): key: int value: MapEnum @@ -667,9 +535,6 @@ class TestArenaMap(Message): value: Optional[MapEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap.MapInt32EnumEntry: ... - class MapInt32ForeignMessageEntry(Message): key: int @@ -681,10 +546,6 @@ class TestArenaMap(Message): value: Optional[ForeignMessage1] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapInt32ForeignMessageEntry: ... - class MapInt32ForeignMessageNoArenaEntry(Message): key: int @@ -696,10 +557,6 @@ class TestArenaMap(Message): value: Optional[ForeignMessage] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestArenaMap.MapInt32ForeignMessageNoArenaEntry: ... - @property def map_int32_int32(self) -> MutableMapping[int, int]: ... @@ -777,9 +634,6 @@ class TestArenaMap(Message): map_int32_foreign_message_no_arena: Optional[Mapping[int, ForeignMessage]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestArenaMap: ... - class MessageContainingEnumCalledType(Message): @@ -813,10 +667,6 @@ class MessageContainingEnumCalledType(Message): value: Optional[MessageContainingEnumCalledType] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> MessageContainingEnumCalledType.TypeEntry: ... - @property def type(self) -> MutableMapping[Text, MessageContainingEnumCalledType]: ... @@ -825,9 +675,6 @@ class MessageContainingEnumCalledType(Message): type: Optional[Mapping[Text, MessageContainingEnumCalledType]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MessageContainingEnumCalledType: ... - class MessageContainingMapCalledEntry(Message): @@ -840,10 +687,6 @@ class MessageContainingMapCalledEntry(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> MessageContainingMapCalledEntry.EntryEntry: ... - @property def entry(self) -> MutableMapping[int, int]: ... @@ -851,9 +694,6 @@ class MessageContainingMapCalledEntry(Message): entry: Optional[Mapping[int, int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MessageContainingMapCalledEntry: ... - class TestRecursiveMapMessage(Message): @@ -868,15 +708,9 @@ class TestRecursiveMapMessage(Message): value: Optional[TestRecursiveMapMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRecursiveMapMessage.AEntry: ... - @property def a(self) -> MutableMapping[Text, TestRecursiveMapMessage]: ... def __init__(self, a: Optional[Mapping[Text, TestRecursiveMapMessage]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestRecursiveMapMessage: ... diff --git a/third_party/2and3/google/protobuf/message.pyi b/third_party/2and3/google/protobuf/message.pyi index 2265e0356ff4..59a0b5bd37bc 100644 --- a/third_party/2and3/google/protobuf/message.pyi +++ b/third_party/2and3/google/protobuf/message.pyi @@ -41,7 +41,7 @@ class Message: def ClearExtension(self, extension_handle): ... def ByteSize(self) -> int: ... @classmethod - def FromString(cls: Type[_T], s: Any) -> _T: ... + def FromString(cls: Type[_T], s: _Serialized) -> _T: ... @property def Extensions(self) -> _ExtensionDict: ... diff --git a/third_party/2and3/google/protobuf/source_context_pb2.pyi b/third_party/2and3/google/protobuf/source_context_pb2.pyi index 527ac1a4f8c0..50c08501db2c 100644 --- a/third_party/2and3/google/protobuf/source_context_pb2.pyi +++ b/third_party/2and3/google/protobuf/source_context_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -13,6 +14,3 @@ class SourceContext(Message): def __init__(self, file_name: Optional[Text] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> SourceContext: ... diff --git a/third_party/2and3/google/protobuf/struct_pb2.pyi b/third_party/2and3/google/protobuf/struct_pb2.pyi index 21afcc71b393..84bf41d3e751 100644 --- a/third_party/2and3/google/protobuf/struct_pb2.pyi +++ b/third_party/2and3/google/protobuf/struct_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, ) @@ -50,9 +51,6 @@ class Struct(Message, well_known_types.Struct): value: Optional[Value] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Struct.FieldsEntry: ... - @property def fields(self) -> MutableMapping[Text, Value]: ... @@ -60,9 +58,6 @@ class Struct(Message, well_known_types.Struct): fields: Optional[Mapping[Text, Value]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Struct: ... - class _Value(Message): null_value: NullValue @@ -85,9 +80,6 @@ class _Value(Message): list_value: Optional[ListValue] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> _Value: ... - Value = _Value @@ -100,6 +92,3 @@ class ListValue(Message, well_known_types.ListValue): def __init__(self, values: Optional[Iterable[Value]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ListValue: ... 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..812227b0042d 100644 --- a/third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi +++ b/third_party/2and3/google/protobuf/test_messages_proto2_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer, @@ -75,9 +76,6 @@ class TestAllTypesProto2(Message): corecursive: Optional[TestAllTypesProto2] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2.NestedMessage: ... - class MapInt32Int32Entry(Message): key: int value: int @@ -87,10 +85,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt32Int32Entry: ... - class MapInt64Int64Entry(Message): key: int value: int @@ -100,10 +94,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt64Int64Entry: ... - class MapUint32Uint32Entry(Message): key: int value: int @@ -113,10 +103,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapUint32Uint32Entry: ... - class MapUint64Uint64Entry(Message): key: int value: int @@ -126,10 +112,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapUint64Uint64Entry: ... - class MapSint32Sint32Entry(Message): key: int value: int @@ -139,10 +121,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSint32Sint32Entry: ... - class MapSint64Sint64Entry(Message): key: int value: int @@ -152,10 +130,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSint64Sint64Entry: ... - class MapFixed32Fixed32Entry(Message): key: int value: int @@ -165,10 +139,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapFixed32Fixed32Entry: ... - class MapFixed64Fixed64Entry(Message): key: int value: int @@ -178,10 +148,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapFixed64Fixed64Entry: ... - class MapSfixed32Sfixed32Entry(Message): key: int value: int @@ -191,10 +157,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSfixed32Sfixed32Entry: ... - class MapSfixed64Sfixed64Entry(Message): key: int value: int @@ -204,10 +166,6 @@ class TestAllTypesProto2(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapSfixed64Sfixed64Entry: ... - class MapInt32FloatEntry(Message): key: int value: float @@ -217,10 +175,6 @@ class TestAllTypesProto2(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt32FloatEntry: ... - class MapInt32DoubleEntry(Message): key: int value: float @@ -230,10 +184,6 @@ class TestAllTypesProto2(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapInt32DoubleEntry: ... - class MapBoolBoolEntry(Message): key: bool value: bool @@ -243,9 +193,6 @@ class TestAllTypesProto2(Message): value: Optional[bool] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2.MapBoolBoolEntry: ... - class MapStringStringEntry(Message): key: Text value: Text @@ -255,10 +202,6 @@ class TestAllTypesProto2(Message): value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringStringEntry: ... - class MapStringBytesEntry(Message): key: Text value: bytes @@ -268,10 +211,6 @@ class TestAllTypesProto2(Message): value: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringBytesEntry: ... - class MapStringNestedMessageEntry(Message): key: Text @@ -283,10 +222,6 @@ class TestAllTypesProto2(Message): value: Optional[TestAllTypesProto2.NestedMessage] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringNestedMessageEntry: ... - class MapStringForeignMessageEntry(Message): key: Text @@ -298,10 +233,6 @@ class TestAllTypesProto2(Message): value: Optional[ForeignMessageProto2] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringForeignMessageEntry: ... - class MapStringNestedEnumEntry(Message): key: Text value: TestAllTypesProto2.NestedEnum @@ -311,10 +242,6 @@ class TestAllTypesProto2(Message): value: Optional[TestAllTypesProto2.NestedEnum] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringNestedEnumEntry: ... - class MapStringForeignEnumEntry(Message): key: Text value: ForeignEnumProto2 @@ -324,10 +251,6 @@ class TestAllTypesProto2(Message): value: Optional[ForeignEnumProto2] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MapStringForeignEnumEntry: ... - class Data(Message): group_int32: int group_uint32: int @@ -337,18 +260,11 @@ class TestAllTypesProto2(Message): group_uint32: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2.Data: ... - class MessageSetCorrect(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MessageSetCorrect: ... - class MessageSetCorrectExtension1(Message): bytes: Text @@ -356,10 +272,6 @@ class TestAllTypesProto2(Message): bytes: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: builtins.bytes) -> TestAllTypesProto2.MessageSetCorrectExtension1: ... - class MessageSetCorrectExtension2(Message): i: int @@ -367,74 +279,6 @@ class TestAllTypesProto2(Message): i: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestAllTypesProto2.MessageSetCorrectExtension2: ... - optional_int32: int - optional_int64: int - optional_uint32: int - optional_uint64: int - optional_sint32: int - optional_sint64: int - optional_fixed32: int - optional_fixed64: int - optional_sfixed32: int - optional_sfixed64: int - optional_float: float - optional_double: float - optional_bool: bool - optional_string: Text - optional_bytes: bytes - optional_nested_enum: TestAllTypesProto2.NestedEnum - optional_foreign_enum: ForeignEnumProto2 - optional_string_piece: Text - optional_cord: Text - repeated_int32: RepeatedScalarFieldContainer[int] - repeated_int64: RepeatedScalarFieldContainer[int] - repeated_uint32: RepeatedScalarFieldContainer[int] - repeated_uint64: RepeatedScalarFieldContainer[int] - repeated_sint32: RepeatedScalarFieldContainer[int] - repeated_sint64: RepeatedScalarFieldContainer[int] - repeated_fixed32: RepeatedScalarFieldContainer[int] - repeated_fixed64: RepeatedScalarFieldContainer[int] - repeated_sfixed32: RepeatedScalarFieldContainer[int] - repeated_sfixed64: RepeatedScalarFieldContainer[int] - repeated_float: RepeatedScalarFieldContainer[float] - repeated_double: RepeatedScalarFieldContainer[float] - repeated_bool: RepeatedScalarFieldContainer[bool] - repeated_string: RepeatedScalarFieldContainer[Text] - repeated_bytes: RepeatedScalarFieldContainer[bytes] - repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypesProto2.NestedEnum] - repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnumProto2] - repeated_string_piece: RepeatedScalarFieldContainer[Text] - repeated_cord: RepeatedScalarFieldContainer[Text] - oneof_uint32: int - oneof_string: Text - oneof_bytes: bytes - oneof_bool: bool - oneof_uint64: int - oneof_float: float - oneof_double: float - oneof_enum: TestAllTypesProto2.NestedEnum - fieldname1: int - field_name2: int - _field_name3: int - field__name4_: int - field0name5: int - field_0_name6: int - fieldName7: int - FieldName8: int - field_Name9: int - Field_Name10: int - FIELD_NAME11: int - FIELD_name12: int - __field_name13: int - __Field_name14: int - field__name15: int - field__Name16: int - field_name17__: int - Field_name18__: int - @property def optional_nested_message(self) -> TestAllTypesProto2.NestedMessage: ... @@ -612,9 +456,6 @@ class TestAllTypesProto2(Message): Field_name18__: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto2: ... - class ForeignMessageProto2(Message): c: int @@ -622,6 +463,3 @@ class ForeignMessageProto2(Message): def __init__(self, c: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ForeignMessageProto2: ... 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..bd23e3798de6 100644 --- a/third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi +++ b/third_party/2and3/google/protobuf/test_messages_proto3_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.any_pb2 import ( Any, ) @@ -99,9 +100,6 @@ class TestAllTypesProto3(Message): corecursive: Optional[TestAllTypesProto3] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.NestedMessage: ... - class MapInt32Int32Entry(Message): key: int value: int @@ -111,9 +109,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt32Int32Entry: ... - class MapInt64Int64Entry(Message): key: int value: int @@ -123,9 +118,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt64Int64Entry: ... - class MapUint32Uint32Entry(Message): key: int value: int @@ -135,9 +127,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapUint32Uint32Entry: ... - class MapUint64Uint64Entry(Message): key: int value: int @@ -147,9 +136,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapUint64Uint64Entry: ... - class MapSint32Sint32Entry(Message): key: int value: int @@ -159,9 +145,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSint32Sint32Entry: ... - class MapSint64Sint64Entry(Message): key: int value: int @@ -171,9 +154,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSint64Sint64Entry: ... - class MapFixed32Fixed32Entry(Message): key: int value: int @@ -183,9 +163,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapFixed32Fixed32Entry: ... - class MapFixed64Fixed64Entry(Message): key: int value: int @@ -195,9 +172,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapFixed64Fixed64Entry: ... - class MapSfixed32Sfixed32Entry(Message): key: int value: int @@ -207,9 +181,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSfixed32Sfixed32Entry: ... - class MapSfixed64Sfixed64Entry(Message): key: int value: int @@ -219,9 +190,6 @@ class TestAllTypesProto3(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapSfixed64Sfixed64Entry: ... - class MapInt32FloatEntry(Message): key: int value: float @@ -231,9 +199,6 @@ class TestAllTypesProto3(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt32FloatEntry: ... - class MapInt32DoubleEntry(Message): key: int value: float @@ -243,9 +208,6 @@ class TestAllTypesProto3(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapInt32DoubleEntry: ... - class MapBoolBoolEntry(Message): key: bool value: bool @@ -255,9 +217,6 @@ class TestAllTypesProto3(Message): value: Optional[bool] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapBoolBoolEntry: ... - class MapStringStringEntry(Message): key: Text value: Text @@ -267,9 +226,6 @@ class TestAllTypesProto3(Message): value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringStringEntry: ... - class MapStringBytesEntry(Message): key: Text value: bytes @@ -279,9 +235,6 @@ class TestAllTypesProto3(Message): value: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringBytesEntry: ... - class MapStringNestedMessageEntry(Message): key: Text @@ -293,9 +246,6 @@ class TestAllTypesProto3(Message): value: Optional[TestAllTypesProto3.NestedMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringNestedMessageEntry: ... - class MapStringForeignMessageEntry(Message): key: Text @@ -307,9 +257,6 @@ class TestAllTypesProto3(Message): value: Optional[ForeignMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringForeignMessageEntry: ... - class MapStringNestedEnumEntry(Message): key: Text value: TestAllTypesProto3.NestedEnum @@ -319,9 +266,6 @@ class TestAllTypesProto3(Message): value: Optional[TestAllTypesProto3.NestedEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringNestedEnumEntry: ... - class MapStringForeignEnumEntry(Message): key: Text value: ForeignEnum @@ -331,73 +275,6 @@ class TestAllTypesProto3(Message): value: Optional[ForeignEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3.MapStringForeignEnumEntry: ... - optional_int32: int - optional_int64: int - optional_uint32: int - optional_uint64: int - optional_sint32: int - optional_sint64: int - optional_fixed32: int - optional_fixed64: int - optional_sfixed32: int - optional_sfixed64: int - optional_float: float - optional_double: float - optional_bool: bool - optional_string: Text - optional_bytes: bytes - optional_nested_enum: TestAllTypesProto3.NestedEnum - optional_foreign_enum: ForeignEnum - optional_string_piece: Text - optional_cord: Text - repeated_int32: RepeatedScalarFieldContainer[int] - repeated_int64: RepeatedScalarFieldContainer[int] - repeated_uint32: RepeatedScalarFieldContainer[int] - repeated_uint64: RepeatedScalarFieldContainer[int] - repeated_sint32: RepeatedScalarFieldContainer[int] - repeated_sint64: RepeatedScalarFieldContainer[int] - repeated_fixed32: RepeatedScalarFieldContainer[int] - repeated_fixed64: RepeatedScalarFieldContainer[int] - repeated_sfixed32: RepeatedScalarFieldContainer[int] - repeated_sfixed64: RepeatedScalarFieldContainer[int] - repeated_float: RepeatedScalarFieldContainer[float] - repeated_double: RepeatedScalarFieldContainer[float] - repeated_bool: RepeatedScalarFieldContainer[bool] - repeated_string: RepeatedScalarFieldContainer[Text] - repeated_bytes: RepeatedScalarFieldContainer[bytes] - repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypesProto3.NestedEnum] - repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] - repeated_string_piece: RepeatedScalarFieldContainer[Text] - repeated_cord: RepeatedScalarFieldContainer[Text] - oneof_uint32: int - oneof_string: Text - oneof_bytes: bytes - oneof_bool: bool - oneof_uint64: int - oneof_float: float - oneof_double: float - oneof_enum: TestAllTypesProto3.NestedEnum - fieldname1: int - field_name2: int - _field_name3: int - field__name4_: int - field0name5: int - field_0_name6: int - fieldName7: int - FieldName8: int - field_Name9: int - Field_Name10: int - FIELD_NAME11: int - FIELD_name12: int - __field_name13: int - __Field_name14: int - field__name15: int - field__Name16: int - field_name17__: int - Field_name18__: int - @property def optional_nested_message(self) -> TestAllTypesProto3.NestedMessage: ... @@ -685,9 +562,6 @@ class TestAllTypesProto3(Message): Field_name18__: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypesProto3: ... - class ForeignMessage(Message): c: int @@ -695,6 +569,3 @@ class ForeignMessage(Message): def __init__(self, c: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... diff --git a/third_party/2and3/google/protobuf/timestamp_pb2.pyi b/third_party/2and3/google/protobuf/timestamp_pb2.pyi index 77ae3055c095..308b17aefbf7 100644 --- a/third_party/2and3/google/protobuf/timestamp_pb2.pyi +++ b/third_party/2and3/google/protobuf/timestamp_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -16,6 +17,3 @@ class Timestamp(Message, well_known_types.Timestamp): seconds: Optional[int] = ..., nanos: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Timestamp: ... diff --git a/third_party/2and3/google/protobuf/type_pb2.pyi b/third_party/2and3/google/protobuf/type_pb2.pyi index e3ff9b101d19..ad63ce0f8566 100644 --- a/third_party/2and3/google/protobuf/type_pb2.pyi +++ b/third_party/2and3/google/protobuf/type_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.any_pb2 import ( Any, ) @@ -66,9 +67,6 @@ class Type(Message): syntax: Optional[Syntax] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Type: ... - class Field(Message): @@ -154,9 +152,6 @@ class Field(Message): default_value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Field: ... - class Enum(Message): name: Text @@ -179,9 +174,6 @@ class Enum(Message): syntax: Optional[Syntax] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Enum: ... - class EnumValue(Message): name: Text @@ -196,9 +188,6 @@ class EnumValue(Message): options: Optional[Iterable[Option]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> EnumValue: ... - class Option(Message): name: Text @@ -210,6 +199,3 @@ class Option(Message): name: Optional[Text] = ..., value: Optional[Any] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> Option: ... diff --git a/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi b/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi index 89d6042be384..7940f644d34d 100644 --- a/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, ) @@ -20,9 +21,6 @@ class NestedMessage(Message): d: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> NestedMessage: ... - class ArenaMessage(Message): @@ -38,6 +36,3 @@ class ArenaMessage(Message): repeated_nested_message: Optional[Iterable[NestedMessage]] = ..., repeated_import_no_arena_message: Optional[Iterable[ImportNoArenaNestedMessage]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ArenaMessage: ... 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..245cb1819eb9 100644 --- a/third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_custom_options_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.descriptor_pb2 import ( FileOptions, ) @@ -90,45 +91,30 @@ class TestMessageWithCustomOptions(Message): oneof_field: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMessageWithCustomOptions: ... - class CustomOptionFooRequest(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooRequest: ... - class CustomOptionFooResponse(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooResponse: ... - class CustomOptionFooClientMessage(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooClientMessage: ... - class CustomOptionFooServerMessage(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CustomOptionFooServerMessage: ... - class DummyMessageContainingEnum(Message): @@ -155,63 +141,42 @@ class DummyMessageContainingEnum(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> DummyMessageContainingEnum: ... - class DummyMessageInvalidAsOptionType(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> DummyMessageInvalidAsOptionType: ... - class CustomOptionMinIntegerValues(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CustomOptionMinIntegerValues: ... - class CustomOptionMaxIntegerValues(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CustomOptionMaxIntegerValues: ... - class CustomOptionOtherValues(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> CustomOptionOtherValues: ... - class SettingRealsFromPositiveInts(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> SettingRealsFromPositiveInts: ... - class SettingRealsFromNegativeInts(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> SettingRealsFromNegativeInts: ... - class ComplexOptionType1(Message): foo: int @@ -226,9 +191,6 @@ class ComplexOptionType1(Message): foo4: Optional[Iterable[int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ComplexOptionType1: ... - class ComplexOptionType2(Message): @@ -239,11 +201,6 @@ class ComplexOptionType2(Message): waldo: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> ComplexOptionType2.ComplexOptionType4: ... - baz: int - @property def bar(self) -> ComplexOptionType1: ... @@ -261,9 +218,6 @@ class ComplexOptionType2(Message): barney: Optional[Iterable[ComplexOptionType2.ComplexOptionType4]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ComplexOptionType2: ... - class ComplexOptionType3(Message): @@ -274,11 +228,6 @@ class ComplexOptionType3(Message): plugh: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> ComplexOptionType3.ComplexOptionType5: ... - qux: int - @property def complexoptiontype5(self) -> ComplexOptionType3.ComplexOptionType5: ... @@ -287,9 +236,6 @@ class ComplexOptionType3(Message): complexoptiontype5: Optional[ComplexOptionType3.ComplexOptionType5] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ComplexOptionType3: ... - class ComplexOpt6(Message): xyzzy: int @@ -298,27 +244,18 @@ class ComplexOpt6(Message): xyzzy: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ComplexOpt6: ... - class VariousComplexOptions(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> VariousComplexOptions: ... - class AggregateMessageSet(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> AggregateMessageSet: ... - class AggregateMessageSetElement(Message): s: Text @@ -327,9 +264,6 @@ class AggregateMessageSetElement(Message): s: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> AggregateMessageSetElement: ... - class Aggregate(Message): i: int @@ -352,9 +286,6 @@ class Aggregate(Message): mset: Optional[AggregateMessageSet] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Aggregate: ... - class AggregateMessage(Message): fieldname: int @@ -363,9 +294,6 @@ class AggregateMessage(Message): fieldname: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> AggregateMessage: ... - class NestedOptionType(Message): @@ -394,15 +322,9 @@ class NestedOptionType(Message): nested_field: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> NestedOptionType.NestedMessage: ... - def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> NestedOptionType: ... - class OldOptionType(Message): @@ -429,9 +351,6 @@ class OldOptionType(Message): value: OldOptionType.TestEnum, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> OldOptionType: ... - class NewOptionType(Message): @@ -459,14 +378,8 @@ class NewOptionType(Message): value: NewOptionType.TestEnum, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> NewOptionType: ... - class TestMessageWithRequiredEnumOption(Message): def __init__(self, ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageWithRequiredEnumOption: ... diff --git a/third_party/2and3/google/protobuf/unittest_import_pb2.pyi b/third_party/2and3/google/protobuf/unittest_import_pb2.pyi index 92f191473ea5..a42387ae1ba0 100644 --- a/third_party/2and3/google/protobuf/unittest_import_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_import_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -61,6 +62,3 @@ class ImportMessage(Message): def __init__(self, d: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ImportMessage: ... 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..2207c11041ae 100644 --- a/third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_import_public_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -12,6 +13,3 @@ class PublicImportMessage(Message): def __init__(self, e: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> PublicImportMessage: ... diff --git a/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi b/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi index 63663207bda0..f30569d69bfa 100644 --- a/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, ) @@ -24,9 +25,6 @@ class TestMessageSetContainer(Message): message_set: Optional[TestMessageSet] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMessageSetContainer: ... - class TestMessageSetExtension1(Message): i: int @@ -35,9 +33,6 @@ class TestMessageSetExtension1(Message): i: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMessageSetExtension1: ... - class TestMessageSetExtension2(Message): str: Text @@ -46,9 +41,6 @@ class TestMessageSetExtension2(Message): bytes: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: builtins.bytes) -> TestMessageSetExtension2: ... - class RawMessageSet(Message): @@ -61,15 +53,9 @@ class RawMessageSet(Message): message: bytes, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> RawMessageSet.Item: ... - @property def item(self) -> RepeatedCompositeFieldContainer[RawMessageSet.Item]: ... def __init__(self, item: Optional[Iterable[RawMessageSet.Item]] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> RawMessageSet: ... 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..2855d035e7b1 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,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -11,9 +12,6 @@ class TestMessageSet(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMessageSet: ... - class TestMessageSetWireFormatContainer(Message): @@ -23,6 +21,3 @@ class TestMessageSetWireFormatContainer(Message): def __init__(self, message_set: Optional[TestMessageSet] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessageSetWireFormatContainer: ... 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..7bca5da7082a 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,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -12,6 +13,3 @@ class ImportNoArenaNestedMessage(Message): def __init__(self, d: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> ImportNoArenaNestedMessage: ... 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..8185f2cfccf8 100644 --- a/third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_no_arena_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer, @@ -78,9 +79,6 @@ class TestAllTypes(Message): bb: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.NestedMessage: ... - class OptionalGroup(Message): a: int @@ -88,9 +86,6 @@ class TestAllTypes(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.OptionalGroup: ... - class RepeatedGroup(Message): a: int @@ -98,72 +93,6 @@ class TestAllTypes(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.RepeatedGroup: ... - optional_int32: int - optional_int64: int - optional_uint32: int - optional_uint64: int - optional_sint32: int - optional_sint64: int - optional_fixed32: int - optional_fixed64: int - optional_sfixed32: int - optional_sfixed64: int - optional_float: float - optional_double: float - optional_bool: bool - optional_string: Text - optional_bytes: bytes - optional_nested_enum: TestAllTypes.NestedEnum - optional_foreign_enum: ForeignEnum - optional_import_enum: ImportEnum - optional_string_piece: Text - optional_cord: Text - repeated_int32: RepeatedScalarFieldContainer[int] - repeated_int64: RepeatedScalarFieldContainer[int] - repeated_uint32: RepeatedScalarFieldContainer[int] - repeated_uint64: RepeatedScalarFieldContainer[int] - repeated_sint32: RepeatedScalarFieldContainer[int] - repeated_sint64: RepeatedScalarFieldContainer[int] - repeated_fixed32: RepeatedScalarFieldContainer[int] - repeated_fixed64: RepeatedScalarFieldContainer[int] - repeated_sfixed32: RepeatedScalarFieldContainer[int] - repeated_sfixed64: RepeatedScalarFieldContainer[int] - repeated_float: RepeatedScalarFieldContainer[float] - repeated_double: RepeatedScalarFieldContainer[float] - repeated_bool: RepeatedScalarFieldContainer[bool] - repeated_string: RepeatedScalarFieldContainer[Text] - repeated_bytes: RepeatedScalarFieldContainer[bytes] - repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypes.NestedEnum] - repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] - repeated_import_enum: RepeatedScalarFieldContainer[ImportEnum] - repeated_string_piece: RepeatedScalarFieldContainer[Text] - repeated_cord: RepeatedScalarFieldContainer[Text] - default_int32: int - default_int64: int - default_uint32: int - default_uint64: int - default_sint32: int - default_sint64: int - default_fixed32: int - default_fixed64: int - default_sfixed32: int - default_sfixed64: int - default_float: float - default_double: float - default_bool: bool - default_string: Text - default_bytes: bytes - default_nested_enum: TestAllTypes.NestedEnum - default_foreign_enum: ForeignEnum - default_import_enum: ImportEnum - default_string_piece: Text - default_cord: Text - oneof_uint32: int - oneof_string: Text - oneof_bytes: bytes - @property def optionalgroup(self) -> TestAllTypes.OptionalGroup: ... @@ -287,9 +216,6 @@ class TestAllTypes(Message): lazy_oneof_nested_message: Optional[TestAllTypes.NestedMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes: ... - class ForeignMessage(Message): c: int @@ -298,9 +224,6 @@ class ForeignMessage(Message): c: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... - class TestNoArenaMessage(Message): @@ -310,6 +233,3 @@ class TestNoArenaMessage(Message): def __init__(self, arena_message: Optional[ArenaMessage] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestNoArenaMessage: ... 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..a791742c0559 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,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -35,6 +36,3 @@ class TestMessage(Message): def __init__(self, a: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestMessage: ... diff --git a/third_party/2and3/google/protobuf/unittest_pb2.pyi b/third_party/2and3/google/protobuf/unittest_pb2.pyi index 7f052577d350..5ff590577699 100644 --- a/third_party/2and3/google/protobuf/unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer, @@ -124,9 +125,6 @@ class TestAllTypes(Message): bb: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.NestedMessage: ... - class OptionalGroup(Message): a: int @@ -134,9 +132,6 @@ class TestAllTypes(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.OptionalGroup: ... - class RepeatedGroup(Message): a: int @@ -144,72 +139,6 @@ class TestAllTypes(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.RepeatedGroup: ... - optional_int32: int - optional_int64: int - optional_uint32: int - optional_uint64: int - optional_sint32: int - optional_sint64: int - optional_fixed32: int - optional_fixed64: int - optional_sfixed32: int - optional_sfixed64: int - optional_float: float - optional_double: float - optional_bool: bool - optional_string: Text - optional_bytes: bytes - optional_nested_enum: TestAllTypes.NestedEnum - optional_foreign_enum: ForeignEnum - optional_import_enum: ImportEnum - optional_string_piece: Text - optional_cord: Text - repeated_int32: RepeatedScalarFieldContainer[int] - repeated_int64: RepeatedScalarFieldContainer[int] - repeated_uint32: RepeatedScalarFieldContainer[int] - repeated_uint64: RepeatedScalarFieldContainer[int] - repeated_sint32: RepeatedScalarFieldContainer[int] - repeated_sint64: RepeatedScalarFieldContainer[int] - repeated_fixed32: RepeatedScalarFieldContainer[int] - repeated_fixed64: RepeatedScalarFieldContainer[int] - repeated_sfixed32: RepeatedScalarFieldContainer[int] - repeated_sfixed64: RepeatedScalarFieldContainer[int] - repeated_float: RepeatedScalarFieldContainer[float] - repeated_double: RepeatedScalarFieldContainer[float] - repeated_bool: RepeatedScalarFieldContainer[bool] - repeated_string: RepeatedScalarFieldContainer[Text] - repeated_bytes: RepeatedScalarFieldContainer[bytes] - repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypes.NestedEnum] - repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] - repeated_import_enum: RepeatedScalarFieldContainer[ImportEnum] - repeated_string_piece: RepeatedScalarFieldContainer[Text] - repeated_cord: RepeatedScalarFieldContainer[Text] - default_int32: int - default_int64: int - default_uint32: int - default_uint64: int - default_sint32: int - default_sint64: int - default_fixed32: int - default_fixed64: int - default_sfixed32: int - default_sfixed64: int - default_float: float - default_double: float - default_bool: bool - default_string: Text - default_bytes: bytes - default_nested_enum: TestAllTypes.NestedEnum - default_foreign_enum: ForeignEnum - default_import_enum: ImportEnum - default_string_piece: Text - default_cord: Text - oneof_uint32: int - oneof_string: Text - oneof_bytes: bytes - @property def optionalgroup(self) -> TestAllTypes.OptionalGroup: ... @@ -329,9 +258,6 @@ class TestAllTypes(Message): oneof_bytes: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes: ... - class NestedTestAllTypes(Message): @@ -351,9 +277,6 @@ class NestedTestAllTypes(Message): repeated_child: Optional[Iterable[NestedTestAllTypes]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> NestedTestAllTypes: ... - class TestDeprecatedFields(Message): deprecated_int32: int @@ -364,18 +287,12 @@ class TestDeprecatedFields(Message): deprecated_int32_in_oneof: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestDeprecatedFields: ... - class TestDeprecatedMessage(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestDeprecatedMessage: ... - class ForeignMessage(Message): c: int @@ -386,27 +303,18 @@ class ForeignMessage(Message): d: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... - class TestReservedFields(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestReservedFields: ... - class TestAllExtensions(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllExtensions: ... - class OptionalGroup_extension(Message): a: int @@ -415,9 +323,6 @@ class OptionalGroup_extension(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> OptionalGroup_extension: ... - class RepeatedGroup_extension(Message): a: int @@ -426,9 +331,6 @@ class RepeatedGroup_extension(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> RepeatedGroup_extension: ... - class TestGroup(Message): class OptionalGroup(Message): @@ -438,10 +340,6 @@ class TestGroup(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestGroup.OptionalGroup: ... - optional_foreign_enum: ForeignEnum - @property def optionalgroup(self) -> TestGroup.OptionalGroup: ... @@ -450,18 +348,12 @@ class TestGroup(Message): optional_foreign_enum: Optional[ForeignEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestGroup: ... - class TestGroupExtension(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestGroupExtension: ... - class TestNestedExtension(Message): class OptionalGroup_extension(Message): @@ -471,16 +363,9 @@ class TestNestedExtension(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestNestedExtension.OptionalGroup_extension: ... - def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedExtension: ... - class TestRequired(Message): a: int @@ -553,9 +438,6 @@ class TestRequired(Message): dummy32: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRequired: ... - class TestRequiredForeign(Message): dummy: int @@ -573,9 +455,6 @@ class TestRequiredForeign(Message): dummy: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRequiredForeign: ... - class TestRequiredMessage(Message): @@ -595,9 +474,6 @@ class TestRequiredMessage(Message): repeated_message: Optional[Iterable[TestRequired]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRequiredMessage: ... - class TestForeignNested(Message): @@ -608,36 +484,24 @@ class TestForeignNested(Message): foreign_nested: Optional[TestAllTypes.NestedMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestForeignNested: ... - class TestEmptyMessage(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEmptyMessage: ... - class TestEmptyMessageWithExtensions(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEmptyMessageWithExtensions: ... - class TestMultipleExtensionRanges(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMultipleExtensionRanges: ... - class TestReallyLargeTagNumber(Message): a: int @@ -648,9 +512,6 @@ class TestReallyLargeTagNumber(Message): bb: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestReallyLargeTagNumber: ... - class TestRecursiveMessage(Message): i: int @@ -663,9 +524,6 @@ class TestRecursiveMessage(Message): i: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRecursiveMessage: ... - class TestMutualRecursionA(Message): class SubMessage(Message): @@ -677,9 +535,6 @@ class TestMutualRecursionA(Message): b: Optional[TestMutualRecursionB] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionA.SubMessage: ... - class SubGroup(Message): @property @@ -693,9 +548,6 @@ class TestMutualRecursionA(Message): not_in_this_scc: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionA.SubGroup: ... - @property def bb(self) -> TestMutualRecursionB: ... @@ -707,9 +559,6 @@ class TestMutualRecursionA(Message): subgroup: Optional[TestMutualRecursionA.SubGroup] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionA: ... - class TestMutualRecursionB(Message): optional_int32: int @@ -722,9 +571,6 @@ class TestMutualRecursionB(Message): optional_int32: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMutualRecursionB: ... - class TestIsInitialized(Message): class SubMessage(Message): @@ -735,10 +581,6 @@ class TestIsInitialized(Message): i: int, ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestIsInitialized.SubMessage.SubGroup: ... - @property def subgroup(self) -> TestIsInitialized.SubMessage.SubGroup: ... @@ -746,9 +588,6 @@ class TestIsInitialized(Message): subgroup: Optional[TestIsInitialized.SubMessage.SubGroup] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestIsInitialized.SubMessage: ... - @property def sub_message(self) -> TestIsInitialized.SubMessage: ... @@ -756,9 +595,6 @@ class TestIsInitialized(Message): sub_message: Optional[TestIsInitialized.SubMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestIsInitialized: ... - class TestDupFieldNumber(Message): class Foo(Message): @@ -768,9 +604,6 @@ class TestDupFieldNumber(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestDupFieldNumber.Foo: ... - class Bar(Message): a: int @@ -778,10 +611,6 @@ class TestDupFieldNumber(Message): a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestDupFieldNumber.Bar: ... - a: int - @property def foo(self) -> TestDupFieldNumber.Foo: ... @@ -794,9 +623,6 @@ class TestDupFieldNumber(Message): bar: Optional[TestDupFieldNumber.Bar] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestDupFieldNumber: ... - class TestEagerMessage(Message): @@ -807,9 +633,6 @@ class TestEagerMessage(Message): sub_message: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestEagerMessage: ... - class TestLazyMessage(Message): @@ -820,9 +643,6 @@ class TestLazyMessage(Message): sub_message: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestLazyMessage: ... - class TestNestedMessageHasBits(Message): class NestedMessage(Message): @@ -837,10 +657,6 @@ class TestNestedMessageHasBits(Message): nestedmessage_repeated_foreignmessage: Optional[Iterable[ForeignMessage]] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestNestedMessageHasBits.NestedMessage: ... - @property def optional_nested_message( self) -> TestNestedMessageHasBits.NestedMessage: ... @@ -849,9 +665,6 @@ class TestNestedMessageHasBits(Message): optional_nested_message: Optional[TestNestedMessageHasBits.NestedMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMessageHasBits: ... - class TestCamelCaseFieldNames(Message): PrimitiveField: int @@ -887,9 +700,6 @@ class TestCamelCaseFieldNames(Message): RepeatedCordField: Optional[Iterable[Text]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestCamelCaseFieldNames: ... - class TestFieldOrderings(Message): class NestedMessage(Message): @@ -901,12 +711,6 @@ class TestFieldOrderings(Message): bb: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestFieldOrderings.NestedMessage: ... - my_string: Text - my_int: int - my_float: float - @property def optional_nested_message(self) -> TestFieldOrderings.NestedMessage: ... @@ -917,9 +721,6 @@ class TestFieldOrderings(Message): optional_nested_message: Optional[TestFieldOrderings.NestedMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestFieldOrderings: ... - class TestExtensionOrderings1(Message): my_string: Text @@ -928,9 +729,6 @@ class TestExtensionOrderings1(Message): my_string: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestExtensionOrderings1: ... - class TestExtensionOrderings2(Message): class TestExtensionOrderings3(Message): @@ -940,18 +738,10 @@ class TestExtensionOrderings2(Message): my_string: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestExtensionOrderings2.TestExtensionOrderings3: ... - my_string: Text - def __init__(self, my_string: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestExtensionOrderings2: ... - class TestExtremeDefaultValues(Message): escaped_bytes: bytes @@ -1012,9 +802,6 @@ class TestExtremeDefaultValues(Message): replacement_string: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestExtremeDefaultValues: ... - class SparseEnumMessage(Message): sparse_enum: TestSparseEnum @@ -1023,9 +810,6 @@ class SparseEnumMessage(Message): sparse_enum: Optional[TestSparseEnum] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> SparseEnumMessage: ... - class OneString(Message): data: Text @@ -1034,9 +818,6 @@ class OneString(Message): data: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> OneString: ... - class MoreString(Message): data: RepeatedScalarFieldContainer[Text] @@ -1045,9 +826,6 @@ class MoreString(Message): data: Optional[Iterable[Text]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MoreString: ... - class OneBytes(Message): data: bytes @@ -1056,9 +834,6 @@ class OneBytes(Message): data: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> OneBytes: ... - class MoreBytes(Message): data: RepeatedScalarFieldContainer[bytes] @@ -1067,9 +842,6 @@ class MoreBytes(Message): data: Optional[Iterable[bytes]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MoreBytes: ... - class Int32Message(Message): data: int @@ -1078,9 +850,6 @@ class Int32Message(Message): data: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Int32Message: ... - class Uint32Message(Message): data: int @@ -1089,9 +858,6 @@ class Uint32Message(Message): data: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Uint32Message: ... - class Int64Message(Message): data: int @@ -1100,9 +866,6 @@ class Int64Message(Message): data: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Int64Message: ... - class Uint64Message(Message): data: int @@ -1111,9 +874,6 @@ class Uint64Message(Message): data: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Uint64Message: ... - class BoolMessage(Message): data: bool @@ -1122,9 +882,6 @@ class BoolMessage(Message): data: Optional[bool] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> BoolMessage: ... - class TestOneof(Message): class FooGroup(Message): @@ -1136,11 +893,6 @@ class TestOneof(Message): b: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestOneof.FooGroup: ... - foo_int: int - foo_string: Text - @property def foo_message(self) -> TestAllTypes: ... @@ -1154,9 +906,6 @@ class TestOneof(Message): foogroup: Optional[TestOneof.FooGroup] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestOneof: ... - class TestOneofBackwardsCompatible(Message): class FooGroup(Message): @@ -1168,12 +917,6 @@ class TestOneofBackwardsCompatible(Message): b: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestOneofBackwardsCompatible.FooGroup: ... - foo_int: int - foo_string: Text - @property def foo_message(self) -> TestAllTypes: ... @@ -1187,9 +930,6 @@ class TestOneofBackwardsCompatible(Message): foogroup: Optional[TestOneofBackwardsCompatible.FooGroup] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestOneofBackwardsCompatible: ... - class TestOneof2(Message): class NestedEnum(int): @@ -1220,9 +960,6 @@ class TestOneof2(Message): b: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestOneof2.FooGroup: ... - class NestedMessage(Message): qux_int: int corge_int: RepeatedScalarFieldContainer[int] @@ -1232,23 +969,6 @@ class TestOneof2(Message): corge_int: Optional[Iterable[int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestOneof2.NestedMessage: ... - foo_int: int - foo_string: Text - foo_cord: Text - foo_string_piece: Text - foo_bytes: bytes - foo_enum: TestOneof2.NestedEnum - bar_int: int - bar_string: Text - bar_cord: Text - bar_string_piece: Text - bar_bytes: bytes - bar_enum: TestOneof2.NestedEnum - baz_int: int - baz_string: Text - @property def foo_message(self) -> TestOneof2.NestedMessage: ... @@ -1278,9 +998,6 @@ class TestOneof2(Message): baz_string: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestOneof2: ... - class TestRequiredOneof(Message): class NestedMessage(Message): @@ -1290,11 +1007,6 @@ class TestRequiredOneof(Message): required_double: float, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRequiredOneof.NestedMessage: ... - foo_int: int - foo_string: Text - @property def foo_message(self) -> TestRequiredOneof.NestedMessage: ... @@ -1304,9 +1016,6 @@ class TestRequiredOneof(Message): foo_message: Optional[TestRequiredOneof.NestedMessage] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRequiredOneof: ... - class TestPackedTypes(Message): packed_int32: RepeatedScalarFieldContainer[int] @@ -1341,9 +1050,6 @@ class TestPackedTypes(Message): packed_enum: Optional[Iterable[ForeignEnum]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestPackedTypes: ... - class TestUnpackedTypes(Message): unpacked_int32: RepeatedScalarFieldContainer[int] @@ -1378,27 +1084,18 @@ class TestUnpackedTypes(Message): unpacked_enum: Optional[Iterable[ForeignEnum]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestUnpackedTypes: ... - class TestPackedExtensions(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestPackedExtensions: ... - class TestUnpackedExtensions(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestUnpackedExtensions: ... - class TestDynamicExtensions(Message): class DynamicEnumType(int): @@ -1428,15 +1125,6 @@ class TestDynamicExtensions(Message): dynamic_field: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestDynamicExtensions.DynamicMessageType: ... - 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: ... @@ -1454,9 +1142,6 @@ class TestDynamicExtensions(Message): packed_extension: Optional[Iterable[int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestDynamicExtensions: ... - class TestRepeatedScalarDifferentTagSizes(Message): repeated_fixed32: RepeatedScalarFieldContainer[int] @@ -1475,9 +1160,6 @@ class TestRepeatedScalarDifferentTagSizes(Message): repeated_uint64: Optional[Iterable[int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestRepeatedScalarDifferentTagSizes: ... - class TestParsingMerge(Message): class RepeatedFieldsGenerator(Message): @@ -1490,10 +1172,6 @@ class TestParsingMerge(Message): field1: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestParsingMerge.RepeatedFieldsGenerator.Group1: ... - class Group2(Message): @property @@ -1503,10 +1181,6 @@ class TestParsingMerge(Message): field1: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestParsingMerge.RepeatedFieldsGenerator.Group2: ... - @property def field1(self) -> RepeatedCompositeFieldContainer[TestAllTypes]: ... @@ -1540,10 +1214,6 @@ class TestParsingMerge(Message): ext2: Optional[Iterable[TestAllTypes]] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestParsingMerge.RepeatedFieldsGenerator: ... - class OptionalGroup(Message): @property @@ -1553,9 +1223,6 @@ class TestParsingMerge(Message): optional_group_all_types: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestParsingMerge.OptionalGroup: ... - class RepeatedGroup(Message): @property @@ -1565,9 +1232,6 @@ class TestParsingMerge(Message): repeated_group_all_types: Optional[TestAllTypes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestParsingMerge.RepeatedGroup: ... - @property def required_all_types(self) -> TestAllTypes: ... @@ -1593,9 +1257,6 @@ class TestParsingMerge(Message): repeatedgroup: Optional[Iterable[TestParsingMerge.RepeatedGroup]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestParsingMerge: ... - class TestCommentInjectionMessage(Message): a: Text @@ -1604,63 +1265,42 @@ class TestCommentInjectionMessage(Message): a: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestCommentInjectionMessage: ... - class FooRequest(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FooRequest: ... - class FooResponse(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FooResponse: ... - class FooClientMessage(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FooClientMessage: ... - class FooServerMessage(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FooServerMessage: ... - class BarRequest(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> BarRequest: ... - class BarResponse(Message): def __init__(self, ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> BarResponse: ... - class TestJsonName(Message): field_name1: int @@ -1679,9 +1319,6 @@ class TestJsonName(Message): field_name6: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestJsonName: ... - class TestHugeFieldNumbers(Message): class OptionalGroup(Message): @@ -1691,9 +1328,6 @@ class TestHugeFieldNumbers(Message): group_a: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestHugeFieldNumbers.OptionalGroup: ... - class StringStringMapEntry(Message): key: Text value: Text @@ -1703,20 +1337,6 @@ class TestHugeFieldNumbers(Message): value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString( - cls, s: bytes) -> TestHugeFieldNumbers.StringStringMapEntry: ... - optional_int32: int - fixed_32: int - repeated_int32: RepeatedScalarFieldContainer[int] - packed_int32: RepeatedScalarFieldContainer[int] - optional_enum: ForeignEnum - optional_string: Text - optional_bytes: bytes - oneof_uint32: int - oneof_string: Text - oneof_bytes: bytes - @property def optional_message(self) -> ForeignMessage: ... @@ -1746,9 +1366,6 @@ class TestHugeFieldNumbers(Message): oneof_bytes: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestHugeFieldNumbers: ... - class TestExtensionInsideTable(Message): field1: int @@ -1772,6 +1389,3 @@ class TestExtensionInsideTable(Message): field9: Optional[int] = ..., field10: Optional[int] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestExtensionInsideTable: ... 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..32da8d4f25b1 100644 --- a/third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_proto3_arena_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.internal.containers import ( RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer, @@ -76,50 +77,6 @@ class TestAllTypes(Message): bb: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes.NestedMessage: ... - optional_int32: int - optional_int64: int - optional_uint32: int - optional_uint64: int - optional_sint32: int - optional_sint64: int - optional_fixed32: int - optional_fixed64: int - optional_sfixed32: int - optional_sfixed64: int - optional_float: float - optional_double: float - optional_bool: bool - optional_string: Text - optional_bytes: bytes - optional_nested_enum: TestAllTypes.NestedEnum - optional_foreign_enum: ForeignEnum - optional_string_piece: Text - optional_cord: Text - repeated_int32: RepeatedScalarFieldContainer[int] - repeated_int64: RepeatedScalarFieldContainer[int] - repeated_uint32: RepeatedScalarFieldContainer[int] - repeated_uint64: RepeatedScalarFieldContainer[int] - repeated_sint32: RepeatedScalarFieldContainer[int] - repeated_sint64: RepeatedScalarFieldContainer[int] - repeated_fixed32: RepeatedScalarFieldContainer[int] - repeated_fixed64: RepeatedScalarFieldContainer[int] - repeated_sfixed32: RepeatedScalarFieldContainer[int] - repeated_sfixed64: RepeatedScalarFieldContainer[int] - repeated_float: RepeatedScalarFieldContainer[float] - repeated_double: RepeatedScalarFieldContainer[float] - repeated_bool: RepeatedScalarFieldContainer[bool] - repeated_string: RepeatedScalarFieldContainer[Text] - repeated_bytes: RepeatedScalarFieldContainer[bytes] - repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypes.NestedEnum] - repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] - repeated_string_piece: RepeatedScalarFieldContainer[Text] - repeated_cord: RepeatedScalarFieldContainer[Text] - oneof_uint32: int - oneof_string: Text - oneof_bytes: bytes - @property def optional_nested_message(self) -> TestAllTypes.NestedMessage: ... @@ -212,9 +169,6 @@ class TestAllTypes(Message): oneof_bytes: Optional[bytes] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAllTypes: ... - class TestPackedTypes(Message): packed_int32: RepeatedScalarFieldContainer[int] @@ -249,9 +203,6 @@ class TestPackedTypes(Message): packed_enum: Optional[Iterable[ForeignEnum]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestPackedTypes: ... - class TestUnpackedTypes(Message): repeated_int32: RepeatedScalarFieldContainer[int] @@ -286,9 +237,6 @@ class TestUnpackedTypes(Message): repeated_nested_enum: Optional[Iterable[TestAllTypes.NestedEnum]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestUnpackedTypes: ... - class NestedTestAllTypes(Message): @@ -308,9 +256,6 @@ class NestedTestAllTypes(Message): repeated_child: Optional[Iterable[NestedTestAllTypes]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> NestedTestAllTypes: ... - class ForeignMessage(Message): c: int @@ -319,14 +264,8 @@ class ForeignMessage(Message): c: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> ForeignMessage: ... - class TestEmptyMessage(Message): def __init__(self, ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEmptyMessage: ... 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..bda01700081e 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,3 +1,4 @@ + from google.protobuf.any_pb2 import ( Any, ) @@ -77,9 +78,6 @@ class MessageType(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> MessageType: ... - class TestMessage(Message): bool_value: bool @@ -135,9 +133,6 @@ class TestMessage(Message): repeated_message_value: Optional[Iterable[MessageType]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMessage: ... - class TestOneof(Message): oneof_int32_value: int @@ -156,9 +151,6 @@ class TestOneof(Message): oneof_message_value: Optional[MessageType] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestOneof: ... - class TestMap(Message): @@ -171,9 +163,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.BoolMapEntry: ... - class Int32MapEntry(Message): key: int value: int @@ -183,9 +172,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.Int32MapEntry: ... - class Int64MapEntry(Message): key: int value: int @@ -195,9 +181,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.Int64MapEntry: ... - class Uint32MapEntry(Message): key: int value: int @@ -207,9 +190,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.Uint32MapEntry: ... - class Uint64MapEntry(Message): key: int value: int @@ -219,9 +199,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.Uint64MapEntry: ... - class StringMapEntry(Message): key: Text value: int @@ -231,9 +208,6 @@ class TestMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap.StringMapEntry: ... - @property def bool_map(self) -> MutableMapping[bool, int]: ... @@ -261,9 +235,6 @@ class TestMap(Message): string_map: Optional[Mapping[Text, int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestMap: ... - class TestNestedMap(Message): @@ -276,9 +247,6 @@ class TestNestedMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.BoolMapEntry: ... - class Int32MapEntry(Message): key: int value: int @@ -288,9 +256,6 @@ class TestNestedMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Int32MapEntry: ... - class Int64MapEntry(Message): key: int value: int @@ -300,9 +265,6 @@ class TestNestedMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Int64MapEntry: ... - class Uint32MapEntry(Message): key: int value: int @@ -312,9 +274,6 @@ class TestNestedMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Uint32MapEntry: ... - class Uint64MapEntry(Message): key: int value: int @@ -324,9 +283,6 @@ class TestNestedMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.Uint64MapEntry: ... - class StringMapEntry(Message): key: Text value: int @@ -336,9 +292,6 @@ class TestNestedMap(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.StringMapEntry: ... - class MapMapEntry(Message): key: Text @@ -350,9 +303,6 @@ class TestNestedMap(Message): value: Optional[TestNestedMap] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap.MapMapEntry: ... - @property def bool_map(self) -> MutableMapping[bool, int]: ... @@ -384,9 +334,6 @@ class TestNestedMap(Message): map_map: Optional[Mapping[Text, TestNestedMap]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestNestedMap: ... - class TestWrapper(Message): @@ -474,9 +421,6 @@ class TestWrapper(Message): repeated_bytes_value: Optional[Iterable[BytesValue]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestWrapper: ... - class TestTimestamp(Message): @@ -491,9 +435,6 @@ class TestTimestamp(Message): repeated_value: Optional[Iterable[Timestamp]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestTimestamp: ... - class TestDuration(Message): @@ -508,9 +449,6 @@ class TestDuration(Message): repeated_value: Optional[Iterable[Duration]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestDuration: ... - class TestFieldMask(Message): @@ -521,9 +459,6 @@ class TestFieldMask(Message): value: Optional[FieldMask] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestFieldMask: ... - class TestStruct(Message): @@ -538,9 +473,6 @@ class TestStruct(Message): repeated_value: Optional[Iterable[Struct]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestStruct: ... - class TestAny(Message): @@ -555,9 +487,6 @@ class TestAny(Message): repeated_value: Optional[Iterable[Any]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestAny: ... - class TestValue(Message): @@ -572,9 +501,6 @@ class TestValue(Message): repeated_value: Optional[Iterable[Value]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestValue: ... - class TestListValue(Message): @@ -589,9 +515,6 @@ class TestListValue(Message): repeated_value: Optional[Iterable[ListValue]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestListValue: ... - class TestBoolValue(Message): @@ -604,10 +527,6 @@ class TestBoolValue(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestBoolValue.BoolMapEntry: ... - bool_value: bool - @property def bool_map(self) -> MutableMapping[bool, int]: ... @@ -616,9 +535,6 @@ class TestBoolValue(Message): bool_map: Optional[Mapping[bool, int]] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestBoolValue: ... - class TestCustomJsonName(Message): value: int @@ -627,9 +543,6 @@ class TestCustomJsonName(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestCustomJsonName: ... - class TestExtensions(Message): @@ -640,9 +553,6 @@ class TestExtensions(Message): extensions: Optional[TestAllExtensions] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> TestExtensions: ... - class TestEnumValue(Message): enum_value1: EnumType @@ -654,6 +564,3 @@ class TestEnumValue(Message): enum_value2: Optional[EnumType] = ..., enum_value3: Optional[EnumType] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> TestEnumValue: ... diff --git a/third_party/2and3/google/protobuf/wrappers_pb2.pyi b/third_party/2and3/google/protobuf/wrappers_pb2.pyi index 6ff865d34c06..1e70f817eb71 100644 --- a/third_party/2and3/google/protobuf/wrappers_pb2.pyi +++ b/third_party/2and3/google/protobuf/wrappers_pb2.pyi @@ -1,3 +1,4 @@ + from google.protobuf.message import ( Message, ) @@ -14,9 +15,6 @@ class DoubleValue(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> DoubleValue: ... - class FloatValue(Message): value: float @@ -25,9 +23,6 @@ class FloatValue(Message): value: Optional[float] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> FloatValue: ... - class Int64Value(Message): value: int @@ -36,9 +31,6 @@ class Int64Value(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Int64Value: ... - class UInt64Value(Message): value: int @@ -47,9 +39,6 @@ class UInt64Value(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> UInt64Value: ... - class Int32Value(Message): value: int @@ -58,9 +47,6 @@ class Int32Value(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> Int32Value: ... - class UInt32Value(Message): value: int @@ -69,9 +55,6 @@ class UInt32Value(Message): value: Optional[int] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> UInt32Value: ... - class BoolValue(Message): value: bool @@ -80,9 +63,6 @@ class BoolValue(Message): value: Optional[bool] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> BoolValue: ... - class StringValue(Message): value: Text @@ -91,9 +71,6 @@ class StringValue(Message): value: Optional[Text] = ..., ) -> None: ... - @classmethod - def FromString(cls, s: bytes) -> StringValue: ... - class BytesValue(Message): value: bytes @@ -101,6 +78,3 @@ class BytesValue(Message): def __init__(self, value: Optional[bytes] = ..., ) -> None: ... - - @classmethod - def FromString(cls, s: bytes) -> BytesValue: ... From bb12f3bdead33689f3766040e1179fa5f3276f11 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Oct 2019 14:39:25 +0200 Subject: [PATCH 24/59] Fix argument type for logging.Formatter.formatTime (#3343) datefmt can be None - that's what the default value is: https://docs.python.org/3/library/logging.html#logging.Formatter.formatTime --- stdlib/2and3/logging/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 6a92ae6295dbc4517abc375830d123c65f1b2cc4 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Fri, 11 Oct 2019 14:56:19 +0200 Subject: [PATCH 25/59] Change type for urllib headers from Mapping to email.message.Message (#3345) Also remove override of 'headers' in HTTPError Closes #3344 --- stdlib/3/urllib/error.pyi | 1 - stdlib/3/urllib/response.pyi | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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 From 61d5f76a1d37ed505766ecfeef6bccd15e955305 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Oct 2019 19:48:48 +0200 Subject: [PATCH 26/59] find_loader() can return None (#3341) --- stdlib/2and3/pkgutil.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/2and3/pkgutil.pyi b/stdlib/2and3/pkgutil.pyi index c7bad4221839..122dff0004a2 100644 --- a/stdlib/2and3/pkgutil.pyi +++ b/stdlib/2and3/pkgutil.pyi @@ -24,7 +24,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 From 6354bc8a102358f7fb549a78934aa65697d5de6e Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Fri, 11 Oct 2019 20:45:43 -0400 Subject: [PATCH 27/59] Ensurepip stubs (#3349) --- stdlib/2and3/ensurepip/__init__.pyi | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 stdlib/2and3/ensurepip/__init__.pyi 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: ... From 583784d94cb77c8561c72396d8329fee145d9489 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sat, 12 Oct 2019 19:15:44 +0200 Subject: [PATCH 28/59] Add missing exception to smtplib (#3348) Improve a few other types --- stdlib/3/smtplib.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/3/smtplib.pyi b/stdlib/3/smtplib.pyi index 803b010bd7a0..60e3a35b83ba 100644 --- a/stdlib/3/smtplib.pyi +++ b/stdlib/3/smtplib.pyi @@ -17,6 +17,7 @@ bCRLF: bytes OLDSTYLE_AUTH: Pattern[str] class SMTPException(OSError): ... +class SMTPNotSupportedError(SMTPException): ... class SMTPServerDisconnected(SMTPException): ... class SMTPResponseException(SMTPException): @@ -53,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] @@ -73,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: ... @@ -116,6 +117,7 @@ class SMTP: def quit(self) -> _Reply: ... class SMTP_SSL(SMTP): + default_port: int = ... keyfile: Optional[str] certfile: Optional[str] context: SSLContext From 8ec25708d9806488d36820b2497718103c59fe55 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sat, 12 Oct 2019 10:18:34 -0700 Subject: [PATCH 29/59] Update 'format' README section -- don't imply it is executable (#3350) --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 From 62bbdf856cb0b4d0742427c822d26340ab0eecd2 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sat, 12 Oct 2019 19:36:56 +0200 Subject: [PATCH 30/59] Add several Python 3.8 annotations (#3347) --- stdlib/2and3/ctypes/__init__.pyi | 11 +++++++++-- stdlib/2and3/datetime.pyi | 25 ++++++++++++++----------- stdlib/2and3/math.pyi | 16 ++++++++++++++-- stdlib/2and3/mmap.pyi | 26 ++++++++++++++++++++++++++ stdlib/3/_ast.pyi | 3 +++ stdlib/3/ast.pyi | 28 +++++++++++++++++++--------- stdlib/3/functools.pyi | 13 +++++++++---- stdlib/3/gc.pyi | 8 ++++++-- stdlib/3/gettext.pyi | 6 ++++++ stdlib/3/gzip.pyi | 6 +++++- stdlib/3/typing.pyi | 5 ++++- 11 files changed, 115 insertions(+), 32 deletions(-) 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 c462962e4673..772b8398f2c7 100644 --- a/stdlib/2and3/datetime.pyi +++ b/stdlib/2and3/datetime.pyi @@ -37,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: ... @@ -114,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: ... @@ -222,13 +225,13 @@ 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: ... + def fromordinal(cls: Type[_S], n: int) -> _S: ... if sys.version_info >= (3, 8): @classmethod def now(cls: Type[_S], tz: Optional[_tzinfo] = ...) -> _S: ... @@ -240,7 +243,7 @@ class datetime(date): @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: ... @@ -249,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: ... 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..d6cb4c1bd1ee 100644 --- a/stdlib/2and3/mmap.pyi +++ b/stdlib/2and3/mmap.pyi @@ -51,6 +51,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 +73,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/3/_ast.pyi b/stdlib/3/_ast.pyi index df2bf9a28633..7bc4e0f45ead 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 diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi index 8e89b2486d94..c278d80df23f 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, Tuple, 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, 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, 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/functools.pyi b/stdlib/3/functools.pyi index f1e43a5bb2f8..afffb3a41d30 100644 --- a/stdlib/3/functools.pyi +++ b/stdlib/3/functools.pyi @@ -1,9 +1,11 @@ +import sys from typing import Any, Callable, Generic, Dict, Iterable, Mapping, Optional, Sequence, Tuple, Type, TypeVar, NamedTuple, Union, overload _AnyCallable = Callable[..., Any] _T = TypeVar("_T") _S = TypeVar("_S") + @overload def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ... @@ -25,10 +27,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/typing.pyi b/stdlib/3/typing.pyi index e6aa5465d735..fb58a337276c 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -611,7 +611,10 @@ class NamedTuple(Tuple[Any, ...]): @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) From 91b72d49c7bb198a3c6f733dcc8a5f6919e0d14a Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Sun, 13 Oct 2019 00:57:50 +0530 Subject: [PATCH 31/59] typing.pyi: Remove verbose and rename from NamedTuple (#3352) Closes #3235 --- stdlib/2/typing.pyi | 4 ++-- stdlib/3/typing.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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/3/typing.pyi b/stdlib/3/typing.pyi index fb58a337276c..6c8e5125f080 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -605,8 +605,8 @@ 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: ... From 2bd1b75641e3b1cd812e6ad4cbbe02663d6e3cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E8=91=89?= Date: Sun, 13 Oct 2019 18:20:02 +0800 Subject: [PATCH 32/59] Extract asyncio exceptions into a separate module (Python 3.8) (#3356) --- stdlib/3/asyncio/__init__.pyi | 28 +++++++++++++++++++++++----- stdlib/3/asyncio/events.pyi | 3 +++ stdlib/3/asyncio/exceptions.pyi | 17 +++++++++++++++++ stdlib/3/asyncio/futures.pyi | 9 +++++---- stdlib/3/asyncio/streams.pyi | 15 ++++++++------- 5 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 stdlib/3/asyncio/exceptions.pyi diff --git a/stdlib/3/asyncio/__init__.pyi b/stdlib/3/asyncio/__init__.pyi index 885dfce099d3..cada742b4795 100644 --- a/stdlib/3/asyncio/__init__.pyi +++ b/stdlib/3/asyncio/__init__.pyi @@ -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,27 @@ DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy] # TODO: AbstractChildWatcher (UNIX only) +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, + ) + __all__: List[str] diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 66f7c9f9e134..e766d9b0813a 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -303,3 +303,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..645481a0a5f4 --- /dev/null +++ b/stdlib/3/asyncio/exceptions.pyi @@ -0,0 +1,17 @@ +import sys +from typing import List, 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: ... + + __all__: List[str] diff --git a/stdlib/3/asyncio/futures.pyi b/stdlib/3/asyncio/futures.pyi index 4ebaa339ed92..5ce41c23dcb2 100644 --- a/stdlib/3/asyncio/futures.pyi +++ b/stdlib/3/asyncio/futures.pyi @@ -2,12 +2,15 @@ import sys 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 @@ -16,8 +19,6 @@ __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/streams.pyi b/stdlib/3/asyncio/streams.pyi index 68271c0fe2a1..e1ce96404045 100644 --- a/stdlib/3/asyncio/streams.pyi +++ b/stdlib/3/asyncio/streams.pyi @@ -11,14 +11,15 @@ _ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Await __all__: List[str] -class IncompleteReadError(EOFError): - expected: Optional[int] - partial: bytes - def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... +if sys.version_info < (3, 8): + 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( From de26a3d109dad3cd6103bf782b7a6b6bb947ddca Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sun, 13 Oct 2019 21:51:43 +0200 Subject: [PATCH 33/59] Remove raise statements from function bodies (#3355) While it may eventually be useful to mark the exceptions that can be raised from a function or method, the semantics are currently undefined and unclear. --- stdlib/2/_collections.pyi | 12 ++--- stdlib/2/_hotshot.pyi | 20 ++------ stdlib/2/_socket.pyi | 10 ++-- stdlib/2/_sre.pyi | 22 ++++---- stdlib/2/heapq.pyi | 6 +-- stdlib/2/posix.pyi | 15 ++---- stdlib/2/signal.pyi | 9 ++-- stdlib/2/string.pyi | 5 +- stdlib/2/strop.pyi | 83 ++++++++----------------------- stdlib/2/sys.pyi | 6 +-- stdlib/2/thread.pyi | 6 +-- stdlib/2and3/_heapq.pyi | 6 +-- stdlib/3/_tracemalloc.pyi | 14 +----- stdlib/3/collections/__init__.pyi | 9 ++-- stdlib/3/signal.pyi | 45 ++++------------- stdlib/3/string.pyi | 5 +- stdlib/3/sys.pyi | 3 +- 17 files changed, 77 insertions(+), 199 deletions(-) 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/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/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/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/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/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/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/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/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/string.pyi b/stdlib/3/string.pyi index c5b1ff9f8c22..db437d95aed6 100644 --- a/stdlib/3/string.pyi +++ b/stdlib/3/string.pyi @@ -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/sys.pyi b/stdlib/3/sys.pyi index 48644328d056..6c2fda171f29 100644 --- a/stdlib/3/sys.pyi +++ b/stdlib/3/sys.pyi @@ -135,8 +135,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': From 950f391704d114155f7ed93cfd3c5688f51a9316 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 14 Oct 2019 01:22:03 +0200 Subject: [PATCH 34/59] Remove unnecessary __all__ annotations (#3357) --- stdlib/2/_threading_local.pyi | 4 +--- stdlib/2/toaiff.pyi | 2 -- stdlib/3/_threading_local.pyi | 3 +-- stdlib/3/asyncio/__init__.pyi | 4 +--- stdlib/3/asyncio/coroutines.pyi | 4 +--- stdlib/3/asyncio/events.pyi | 2 -- stdlib/3/asyncio/exceptions.pyi | 4 +--- stdlib/3/asyncio/futures.pyi | 2 -- stdlib/3/asyncio/locks.pyi | 4 +--- stdlib/3/asyncio/protocols.pyi | 5 +---- stdlib/3/asyncio/queues.pyi | 5 +---- stdlib/3/asyncio/streams.pyi | 5 +---- stdlib/3/asyncio/subprocess.pyi | 4 +--- stdlib/3/asyncio/tasks.pyi | 2 -- stdlib/3/asyncio/transports.pyi | 2 -- 15 files changed, 10 insertions(+), 42 deletions(-) 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/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/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/asyncio/__init__.pyi b/stdlib/3/asyncio/__init__.pyi index cada742b4795..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, @@ -139,5 +139,3 @@ else: IncompleteReadError as IncompleteReadError, LimitOverrunError as LimitOverrunError, ) - -__all__: List[str] diff --git a/stdlib/3/asyncio/coroutines.pyi b/stdlib/3/asyncio/coroutines.pyi index 480093273e8d..f75dfe5f63e9 100644 --- a/stdlib/3/asyncio/coroutines.pyi +++ b/stdlib/3/asyncio/coroutines.pyi @@ -1,6 +1,4 @@ -from typing import Any, Callable, 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 e766d9b0813a..d8c8f2b04109 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] diff --git a/stdlib/3/asyncio/exceptions.pyi b/stdlib/3/asyncio/exceptions.pyi index 645481a0a5f4..ecec9560a850 100644 --- a/stdlib/3/asyncio/exceptions.pyi +++ b/stdlib/3/asyncio/exceptions.pyi @@ -1,5 +1,5 @@ import sys -from typing import List, Optional +from typing import Optional if sys.version_info >= (3, 8): class CancelledError(BaseException): ... @@ -13,5 +13,3 @@ if sys.version_info >= (3, 8): class LimitOverrunError(Exception): consumed: int def __init__(self, message: str, consumed: int) -> None: ... - - __all__: List[str] diff --git a/stdlib/3/asyncio/futures.pyi b/stdlib/3/asyncio/futures.pyi index 5ce41c23dcb2..bd333d7c824f 100644 --- a/stdlib/3/asyncio/futures.pyi +++ b/stdlib/3/asyncio/futures.pyi @@ -14,8 +14,6 @@ if sys.version_info < (3, 8): if sys.version_info >= (3, 7): from contextvars import Context -__all__: List[str] - _T = TypeVar('_T') _S = TypeVar('_S') diff --git a/stdlib/3/asyncio/locks.pyi b/stdlib/3/asyncio/locks.pyi index 3e30cc528533..bc78d4b0de2a 100644 --- a/stdlib/3/asyncio/locks.pyi +++ b/stdlib/3/asyncio/locks.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Generator, 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/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 cae88d10cea1..c908b764c9ef 100644 --- a/stdlib/3/asyncio/queues.pyi +++ b/stdlib/3/asyncio/queues.pyi @@ -1,9 +1,6 @@ from asyncio.events import AbstractEventLoop from .coroutines import coroutine -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/streams.pyi b/stdlib/3/asyncio/streams.pyi index e1ce96404045..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,9 +8,6 @@ from . import transports _ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]] - -__all__: List[str] - if sys.version_info < (3, 8): class IncompleteReadError(EOFError): expected: Optional[int] 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 d848abb39e53..7f8f076c6bd1 100644 --- a/stdlib/3/asyncio/tasks.pyi +++ b/stdlib/3/asyncio/tasks.pyi @@ -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') diff --git a/stdlib/3/asyncio/transports.pyi b/stdlib/3/asyncio/transports.pyi index b2ee08a9c42f..dbd491e18375 100644 --- a/stdlib/3/asyncio/transports.pyi +++ b/stdlib/3/asyncio/transports.pyi @@ -2,8 +2,6 @@ import sys from typing import Any, Mapping, List, Optional, Tuple from asyncio.protocols import BaseProtocol -__all__: List[str] - class BaseTransport: def __init__(self, extra: Mapping[Any, Any] = ...) -> None: ... def get_extra_info(self, name: Any, default: Any = ...) -> Any: ... From 6507875f28cefa767e59f39d4b9a0883d8377769 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 14 Oct 2019 09:51:39 +0200 Subject: [PATCH 35/59] Annotate Python 3.8 removals (#3359) * macpath * time.clock() * Some cgi functions * XMLParser(html) and doctype() * unicode_internal * Two sqlite3 classes hidden * fileinput bufsize arg * Treeview.selection no longer takes arguments --- stdlib/2and3/_codecs.pyi | 5 +- stdlib/2and3/cgi.pyi | 12 +- stdlib/2and3/fileinput.pyi | 56 +++-- stdlib/2and3/macpath.pyi | 310 ++++++++++++------------- stdlib/2and3/sqlite3/dbapi2.pyi | 14 +- stdlib/2and3/time.pyi | 3 +- stdlib/2and3/xml/etree/ElementTree.pyi | 7 +- stdlib/3/platform.pyi | 1 - stdlib/3/tkinter/ttk.pyi | 7 +- tests/check_consistent.py | 2 +- 10 files changed, 220 insertions(+), 197 deletions(-) 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/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/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/macpath.pyi b/stdlib/2and3/macpath.pyi index 42409c0e8721..324fc7b31a11 100644 --- a/stdlib/2and3/macpath.pyi +++ b/stdlib/2and3/macpath.pyi @@ -1,4 +1,3 @@ -# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent! # Stubs for os.path # Ron Murawski @@ -6,172 +5,167 @@ import os import sys from typing import overload, List, Any, AnyStr, Sequence, Tuple, 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: +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 expanduser(path: _PathLike[AnyStr]) -> AnyStr: ... @overload - def realpath(filename: _PathLike[AnyStr]) -> AnyStr: ... + def expanduser(path: AnyStr) -> AnyStr: ... @overload - def realpath(filename: AnyStr) -> AnyStr: ... + 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/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/time.pyi b/stdlib/2and3/time.pyi index b04e6164b652..acebb5aedd17 100644 --- a/stdlib/2and3/time.pyi +++ b/stdlib/2and3/time.pyi @@ -70,7 +70,8 @@ else: 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/xml/etree/ElementTree.pyi b/stdlib/2and3/xml/etree/ElementTree.pyi index 0318bd8c2274..7cabe0ee096c 100644 --- a/stdlib/2and3/xml/etree/ElementTree.pyi +++ b/stdlib/2and3/xml/etree/ElementTree.pyi @@ -182,7 +182,10 @@ class XMLParser: # 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/platform.pyi b/stdlib/3/platform.pyi index 728e259fe92c..ca3a08165150 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]: ... 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/tests/check_consistent.py b/tests/check_consistent.py index afe81869bf6e..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'}, From 0501e2b32983d96c52ce56286ca6fdd4ede3181d Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 14 Oct 2019 09:53:48 +0200 Subject: [PATCH 36/59] Annotations for remaining Python 3.8 additions (#3358) * Add os.add_dll_directory() * Add memfd_create() and flags * Add type annotation to flags * Add stat_result.st_reparse_tag and flags * Add ncurses_version * Add Path.link_to() * Add Picker.reducer_override() * Add plistlib.UID * Add has_dualstack_ipv6() and create_server() * Add shlex.join() * Add SSL methods and fields * Add Python 3.8 statistics functions and classes * Remove obsolete sys.subversion * Add sys.unraisablehook * Add threading.excepthook * Add get_native_id() and Thread.native_id * Add Python 3.8 tkinter methods * Add CLOCK_UPTIME_RAW * Add SupportsIndex * Add typing.get_origin() and get_args() * Add unicodedata.is_normalized * Add unittest.mock.AsyncMock Currently this is just an alias for Any like Mock and MagicMock. All of these classes should probably be sub-classing Any and add their own methods. See also #3224. * Add unittest cleanup methods * Add IsolatedAsyncioTestCase * Add ElementTree.canonicalize() and C14NWriterTarget * cProfile.Profile can be used as a context manager * Add asyncio task name handling * mmap.flush() now always returns None * Add posonlyargcount to CodeType --- stdlib/2and3/_curses.pyi | 6 +- stdlib/2and3/cProfile.pyi | 3 + stdlib/2and3/mmap.pyi | 5 +- stdlib/2and3/pickle.pyi | 3 +- stdlib/2and3/plistlib.pyi | 8 ++ stdlib/2and3/socket.pyi | 10 +++ stdlib/2and3/ssl.pyi | 6 ++ stdlib/2and3/threading.pyi | 9 ++ stdlib/2and3/time.pyi | 14 +-- stdlib/2and3/unicodedata.pyi | 4 +- stdlib/2and3/xml/etree/ElementTree.pyi | 76 +++++++++++++++- stdlib/3/_thread.pyi | 19 +++- stdlib/3/asyncio/base_events.pyi | 7 +- stdlib/3/asyncio/events.pyi | 10 ++- stdlib/3/asyncio/tasks.pyi | 10 ++- stdlib/3/os/__init__.pyi | 30 +++++++ stdlib/3/pathlib.pyi | 2 + stdlib/3/shlex.pyi | 11 +-- stdlib/3/stat.pyi | 119 +++++++++++++++---------- stdlib/3/statistics.pyi | 42 ++++++++- stdlib/3/sys.pyi | 12 ++- stdlib/3/tkinter/__init__.pyi | 15 +++- stdlib/3/types.pyi | 59 ++++++++---- stdlib/3/typing.pyi | 9 ++ stdlib/3/unittest/__init__.pyi | 1 + stdlib/3/unittest/async_case.pyi | 9 ++ stdlib/3/unittest/case.pyi | 16 +++- stdlib/3/unittest/mock.pyi | 2 + third_party/2/pathlib2.pyi | 2 + third_party/2and3/mock.pyi | 2 + 30 files changed, 419 insertions(+), 102 deletions(-) create mode 100644 stdlib/3/unittest/async_case.pyi diff --git a/stdlib/2and3/_curses.pyi b/stdlib/2and3/_curses.pyi index cf640b53f7a5..fcfa2f1d8e1b 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,7 @@ 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): + _ncurses_version = NamedTuple("ncurses_version", [("major", int), ("minor", int), ("patch", int)]) + ncurses_version: _ncurses_version 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/mmap.pyi b/stdlib/2and3/mmap.pyi index d6cb4c1bd1ee..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: ... 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/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/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/ssl.pyi b/stdlib/2and3/ssl.pyi index 62a1cbf38d28..cbc4c89f756b 100644 --- a/stdlib/2and3/ssl.pyi +++ b/stdlib/2and3/ssl.pyi @@ -207,6 +207,8 @@ 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): @@ -221,6 +223,8 @@ if sys.version_info >= (3, 7): 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 @@ -285,6 +289,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/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 acebb5aedd17..e3cdcdd8f08c 100644 --- a/stdlib/2and3/time.pyi +++ b/stdlib/2and3/time.pyi @@ -21,13 +21,15 @@ 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( 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/xml/etree/ElementTree.pyi b/stdlib/2and3/xml/etree/ElementTree.pyi index 7cabe0ee096c..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,6 +228,22 @@ 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 diff --git a/stdlib/3/_thread.pyi b/stdlib/3/_thread.pyi index 41f02b04210f..7cd34a0451d5 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,18 @@ 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 + + ExceptHookArgs = NamedTuple( + "ExceptHookArgs", + [ + ("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/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/events.pyi b/stdlib/3/asyncio/events.pyi index d8c8f2b04109..977bef092dee 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -80,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 diff --git a/stdlib/3/asyncio/tasks.pyi b/stdlib/3/asyncio/tasks.pyi index 7f8f076c6bd1..65c28ebe68e5 100644 --- a/stdlib/3/asyncio/tasks.pyi +++ b/stdlib/3/asyncio/tasks.pyi @@ -98,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: ... @@ -106,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/os/__init__.pyi b/stdlib/3/os/__init__.pyi index e94c36efe08b..6d7eef7ebe83 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -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: ... @@ -631,3 +633,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/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/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/stat.pyi b/stdlib/3/stat.pyi index 74bc444154c1..b8cff23ceef7 100644 --- a/stdlib/3/stat.pyi +++ b/stdlib/3/stat.pyi @@ -17,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/sys.pyi b/stdlib/3/sys.pyi index 6c2fda171f29..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 @@ -198,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/types.pyi b/stdlib/3/types.pyi index e1270afa5dc2..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,45 @@ 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, diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 6c8e5125f080..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 @@ -590,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: ... 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/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/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/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 From 6b55f5c49877c37e603d746493071ff07b89d3dd Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 14 Oct 2019 09:54:45 +0200 Subject: [PATCH 37/59] Clean up multiprocessing + shared_memory (#3351) * Make multiprocessing stubs match implementation * Add multiprocessing.process.BaseProcess * Use BaseProcess in multiprocessing.context where applicable * Remove non-existing BaseContext.Process() * Derive DefaultContext from BaseContext * Fix BaseContext/DefaultContext.set_start_method() signatures * Re-export multiprocessing.context.Process from multiprocessing, instead of using a custom definition * Re-export multiprocessing.active_from from multiprocessing.process instead of using a custom definition * Add parent_process() (Python 3.8) * Complete BaseManager; add Server * Add multiprocessing.shared_memory et al --- stdlib/3/multiprocessing/__init__.pyi | 39 +++++----------- stdlib/3/multiprocessing/context.pyi | 52 ++++++++-------------- stdlib/3/multiprocessing/managers.pyi | 34 ++++++++++++-- stdlib/3/multiprocessing/process.pyi | 41 +++++++++++++++-- stdlib/3/multiprocessing/shared_memory.pyi | 29 ++++++++++++ 5 files changed, 125 insertions(+), 70 deletions(-) create mode 100644 stdlib/3/multiprocessing/shared_memory.pyi diff --git a/stdlib/3/multiprocessing/__init__.pyi b/stdlib/3/multiprocessing/__init__.pyi index f99720f46ed1..b9910b1182d9 100644 --- a/stdlib/3/multiprocessing/__init__.pyi +++ b/stdlib/3/multiprocessing/__init__.pyi @@ -1,20 +1,27 @@ # Stubs for multiprocessing +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 @@ -39,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 = ... @@ -90,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 3059e88ce3f3..caf4d123d0c5 100644 --- a/stdlib/3/multiprocessing/context.pyi +++ b/stdlib/3/multiprocessing/context.pyi @@ -4,6 +4,7 @@ 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, Type, Union @@ -27,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: ... @@ -59,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 @@ -104,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): + 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): + 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): + class ForkServerProcess(BaseProcess): _start_method: str @staticmethod - def _Popen(process_obj: Any) -> Any: ... + def _Popen(process_obj: BaseProcess) -> Any: ... class ForkContext(BaseContext): _name: str @@ -157,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): + 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/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/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: ... From 7e99848b2c9e8982873ad87cfe3f6ffc44549df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rni=20M=C3=A1r=20J=C3=B3nsson?= Date: Mon, 14 Oct 2019 13:21:00 +0000 Subject: [PATCH 38/59] fixing https://github.com/python/typeshed/issues/3361 (#3362) Fixes #3361 --- stdlib/3/inspect.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index 099041551d94..975b478287c9 100644 --- a/stdlib/3/inspect.pyi +++ b/stdlib/3/inspect.pyi @@ -187,9 +187,9 @@ def getargspec(func: object) -> ArgSpec: ... FullArgSpec = NamedTuple('FullArgSpec', [('args', List[str]), ('varargs', Optional[str]), ('varkw', Optional[str]), - ('defaults', Tuple[Any, ...]), + ('defaults', Optional[Tuple[Any, ...]]), ('kwonlyargs', List[str]), - ('kwonlydefaults', Dict[str, Any]), + ('kwonlydefaults', Optional[Dict[str, Any]]), ('annotations', Dict[str, Any]), ]) From add16d2715ef9e362e4402f7ace90161d4452b40 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 14 Oct 2019 13:41:58 -0700 Subject: [PATCH 39/59] protobuf: Fix inadvertently deleted annotations. (#3364) * protobuf: Fix inadvertantly deleted annotations. * Run black on protobuf. --- third_party/2and3/google/protobuf/any_pb2.pyi | 17 +- .../2and3/google/protobuf/any_test_pb2.pyi | 30 +- third_party/2and3/google/protobuf/api_pb2.pyi | 78 +- .../google/protobuf/compiler/plugin_pb2.pyi | 67 +- .../2and3/google/protobuf/descriptor.pyi | 124 +- .../2and3/google/protobuf/descriptor_pb2.pyi | 578 +++---- .../2and3/google/protobuf/duration_pb2.pyi | 16 +- .../2and3/google/protobuf/empty_pb2.pyi | 10 +- .../2and3/google/protobuf/field_mask_pb2.pyi | 21 +- .../google/protobuf/internal/containers.pyi | 8 +- .../protobuf/internal/enum_type_wrapper.pyi | 1 - .../protobuf/internal/well_known_types.pyi | 4 +- .../2and3/google/protobuf/json_format.pyi | 11 +- .../protobuf/map_proto2_unittest_pb2.pyi | 261 +--- .../google/protobuf/map_unittest_pb2.pyi | 551 ++----- third_party/2and3/google/protobuf/message.pyi | 7 +- .../google/protobuf/source_context_pb2.pyi | 16 +- .../2and3/google/protobuf/struct_pb2.pyi | 69 +- .../protobuf/test_messages_proto2_pb2.pyi | 502 +++--- .../protobuf/test_messages_proto3_pb2.pyi | 568 +++---- .../2and3/google/protobuf/timestamp_pb2.pyi | 16 +- .../2and3/google/protobuf/type_pb2.pyi | 135 +- .../google/protobuf/unittest_arena_pb2.pyi | 43 +- .../protobuf/unittest_custom_options_pb2.pyi | 267 +--- .../google/protobuf/unittest_import_pb2.pyi | 32 +- .../protobuf/unittest_import_public_pb2.pyi | 15 +- .../google/protobuf/unittest_mset_pb2.pyi | 52 +- .../unittest_mset_wire_format_pb2.pyi | 21 +- .../protobuf/unittest_no_arena_import_pb2.pyi | 15 +- .../google/protobuf/unittest_no_arena_pb2.pyi | 326 ++-- .../unittest_no_generic_services_pb2.pyi | 24 +- .../2and3/google/protobuf/unittest_pb2.pyi | 1390 +++++++---------- .../protobuf/unittest_proto3_arena_pb2.pyi | 321 ++-- .../protobuf/util/json_format_proto3_pb2.pyi | 467 ++---- .../2and3/google/protobuf/wrappers_pb2.pyi | 64 +- 35 files changed, 2086 insertions(+), 4041 deletions(-) diff --git a/third_party/2and3/google/protobuf/any_pb2.pyi b/third_party/2and3/google/protobuf/any_pb2.pyi index 667acf070209..4b8680728250 100644 --- a/third_party/2and3/google/protobuf/any_pb2.pyi +++ b/third_party/2and3/google/protobuf/any_pb2.pyi @@ -1,20 +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: ... + 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 f1ac04db8471..67985f5e25c6 100644 --- a/third_party/2and3/google/protobuf/any_test_pb2.pyi +++ b/third_party/2and3/google/protobuf/any_test_pb2.pyi @@ -1,30 +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: ... + 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 6f4d791f4ac0..f1f76548ad30 100644 --- a/third_party/2and3/google/protobuf/api_pb2.pyi +++ b/third_party/2and3/google/protobuf/api_pb2.pyi @@ -1,51 +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: ... - + 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 @@ -54,26 +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: ... - + 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: ... + 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 63667b05cb49..7ed1a665d244 100644 --- a/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi +++ b/third_party/2and3/google/protobuf/compiler/plugin_pb2.pyi @@ -1,70 +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: ... - + 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: ... - + 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: ... - + 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: ... + 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 540f7218cbd2..4588c1bc45e8 100644 --- a/third_party/2and3/google/protobuf/descriptor_pb2.pyi +++ b/third_party/2and3/google/protobuf/descriptor_pb2.pyi @@ -1,30 +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: ... - + def __init__(self, file: Optional[Iterable[FileDescriptorProto]] = ...) -> None: ... class FileDescriptorProto(Message): name: Text @@ -33,141 +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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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 @@ -188,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 @@ -217,97 +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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__( + self, + name: Optional[Text] = ..., + method: Optional[Iterable[MethodDescriptorProto]] = ..., + options: Optional[ServiceOptions] = ..., + ) -> None: ... class MethodDescriptorProto(Message): name: Text @@ -315,36 +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: ... - + 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 @@ -368,89 +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: ... - + 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: ... - + 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 @@ -462,90 +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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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 @@ -553,89 +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: ... - + 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: ... - - @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: ... - + 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: ... 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: ... - - @property - def location( - self) -> RepeatedCompositeFieldContainer[SourceCodeInfo.Location]: ... - - def __init__(self, - location: Optional[Iterable[SourceCodeInfo.Location]] = ..., - ) -> None: ... - + 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: ... - - @property - def annotation( - self) -> RepeatedCompositeFieldContainer[GeneratedCodeInfo.Annotation]: ... - - def __init__(self, - annotation: Optional[Iterable[GeneratedCodeInfo.Annotation]] = ..., - ) -> None: ... + 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 b617ac7a892e..a7e4bf3caf1e 100644 --- a/third_party/2and3/google/protobuf/duration_pb2.pyi +++ b/third_party/2and3/google/protobuf/duration_pb2.pyi @@ -1,19 +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: ... + 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 e14a141ece64..7046e6432bce 100644 --- a/third_party/2and3/google/protobuf/empty_pb2.pyi +++ b/third_party/2and3/google/protobuf/empty_pb2.pyi @@ -1,10 +1,4 @@ - -from google.protobuf.message import ( - Message, -) - +from google.protobuf.message import Message class Empty(Message): - - def __init__(self, - ) -> None: ... + 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 140824322a31..1185519653d3 100644 --- a/third_party/2and3/google/protobuf/field_mask_pb2.pyi +++ b/third_party/2and3/google/protobuf/field_mask_pb2.pyi @@ -1,22 +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: ... + 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 9a589625f4db..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,357 +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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... + 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 cf65da3dcf07..e802bb761d3f 100644 --- a/third_party/2and3/google/protobuf/map_unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/map_unittest_pb2.pyi @@ -1,716 +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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... + 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 59a0b5bd37bc..215fb2b4ca3b 100644 --- a/third_party/2and3/google/protobuf/message.pyi +++ b/third_party/2and3/google/protobuf/message.pyi @@ -2,10 +2,7 @@ import sys from typing import Any, Sequence, Optional, Tuple, Type, TypeVar, Union -from .descriptor import ( - DescriptorBase, - FieldDescriptor, -) +from .descriptor import DescriptorBase, FieldDescriptor class Error(Exception): ... class DecodeError(Error): ... @@ -44,7 +41,6 @@ class Message: 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 @@ -52,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 50c08501db2c..5d5cc8b7470d 100644 --- a/third_party/2and3/google/protobuf/source_context_pb2.pyi +++ b/third_party/2and3/google/protobuf/source_context_pb2.pyi @@ -1,16 +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: ... + 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 84bf41d3e751..18a67215a78b 100644 --- a/third_party/2and3/google/protobuf/struct_pb2.pyi +++ b/third_party/2and3/google/protobuf/struct_pb2.pyi @@ -1,94 +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: ... - + 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: ... - + 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: ... - + 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: ... + 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 812227b0042d..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,465 +1,345 @@ - -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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__(self, group_int32: Optional[int] = ..., group_uint32: Optional[int] = ...) -> None: ... class MessageSetCorrect(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class MessageSetCorrectExtension1(Message): bytes: Text - - def __init__(self, - bytes: Optional[Text] = ..., - ) -> None: ... - + def __init__(self, bytes: Optional[Text] = ...) -> None: ... class MessageSetCorrectExtension2(Message): i: int - - def __init__(self, - i: Optional[int] = ..., - ) -> None: ... - + def __init__(self, i: Optional[int] = ...) -> None: ... + optional_int32: int + optional_int64: int + optional_uint32: int + optional_uint64: int + optional_sint32: int + optional_sint64: int + optional_fixed32: int + optional_fixed64: int + optional_sfixed32: int + optional_sfixed64: int + optional_float: float + optional_double: float + optional_bool: bool + optional_string: Text + optional_bytes: bytes + optional_nested_enum: TestAllTypesProto2.NestedEnum + optional_foreign_enum: ForeignEnumProto2 + optional_string_piece: Text + optional_cord: Text + repeated_int32: RepeatedScalarFieldContainer[int] + repeated_int64: RepeatedScalarFieldContainer[int] + repeated_uint32: RepeatedScalarFieldContainer[int] + repeated_uint64: RepeatedScalarFieldContainer[int] + repeated_sint32: RepeatedScalarFieldContainer[int] + repeated_sint64: RepeatedScalarFieldContainer[int] + repeated_fixed32: RepeatedScalarFieldContainer[int] + repeated_fixed64: RepeatedScalarFieldContainer[int] + repeated_sfixed32: RepeatedScalarFieldContainer[int] + repeated_sfixed64: RepeatedScalarFieldContainer[int] + repeated_float: RepeatedScalarFieldContainer[float] + repeated_double: RepeatedScalarFieldContainer[float] + repeated_bool: RepeatedScalarFieldContainer[bool] + repeated_string: RepeatedScalarFieldContainer[Text] + repeated_bytes: RepeatedScalarFieldContainer[bytes] + repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypesProto2.NestedEnum] + repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnumProto2] + repeated_string_piece: RepeatedScalarFieldContainer[Text] + repeated_cord: RepeatedScalarFieldContainer[Text] + oneof_uint32: int + oneof_string: Text + oneof_bytes: bytes + oneof_bool: bool + oneof_uint64: int + oneof_float: float + oneof_double: float + oneof_enum: TestAllTypesProto2.NestedEnum + fieldname1: int + field_name2: int + _field_name3: int + field__name4_: int + field0name5: int + field_0_name6: int + fieldName7: int + FieldName8: int + field_Name9: int + Field_Name10: int + FIELD_NAME11: int + FIELD_name12: int + __field_name13: int + __Field_name14: int + field__name15: int + 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: ... - + 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: ... + 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 bd23e3798de6..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,27 +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, @@ -33,539 +16,420 @@ 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[ForeignEnum] = ...) -> None: ... + optional_int32: int + optional_int64: int + optional_uint32: int + optional_uint64: int + optional_sint32: int + optional_sint64: int + optional_fixed32: int + optional_fixed64: int + optional_sfixed32: int + optional_sfixed64: int + optional_float: float + optional_double: float + optional_bool: bool + optional_string: Text + optional_bytes: bytes + optional_nested_enum: TestAllTypesProto3.NestedEnum + optional_foreign_enum: ForeignEnum + optional_string_piece: Text + optional_cord: Text + repeated_int32: RepeatedScalarFieldContainer[int] + repeated_int64: RepeatedScalarFieldContainer[int] + repeated_uint32: RepeatedScalarFieldContainer[int] + repeated_uint64: RepeatedScalarFieldContainer[int] + repeated_sint32: RepeatedScalarFieldContainer[int] + repeated_sint64: RepeatedScalarFieldContainer[int] + repeated_fixed32: RepeatedScalarFieldContainer[int] + repeated_fixed64: RepeatedScalarFieldContainer[int] + repeated_sfixed32: RepeatedScalarFieldContainer[int] + repeated_sfixed64: RepeatedScalarFieldContainer[int] + repeated_float: RepeatedScalarFieldContainer[float] + repeated_double: RepeatedScalarFieldContainer[float] + repeated_bool: RepeatedScalarFieldContainer[bool] + repeated_string: RepeatedScalarFieldContainer[Text] + repeated_bytes: RepeatedScalarFieldContainer[bytes] + repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypesProto3.NestedEnum] + repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] + repeated_string_piece: RepeatedScalarFieldContainer[Text] + repeated_cord: RepeatedScalarFieldContainer[Text] + oneof_uint32: int + oneof_string: Text + oneof_bytes: bytes + oneof_bool: bool + oneof_uint64: int + oneof_float: float + oneof_double: float + oneof_enum: TestAllTypesProto3.NestedEnum + fieldname1: int + field_name2: int + _field_name3: int + field__name4_: int + field0name5: int + field_0_name6: int + fieldName7: int + FieldName8: int + field_Name9: int + Field_Name10: int + FIELD_NAME11: int + FIELD_name12: int + __field_name13: int + __Field_name14: int + field__name15: int + 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: ... - + 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: ... + 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 308b17aefbf7..c34570c623e3 100644 --- a/third_party/2and3/google/protobuf/timestamp_pb2.pyi +++ b/third_party/2and3/google/protobuf/timestamp_pb2.pyi @@ -1,19 +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: ... + 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 ad63ce0f8566..40c8633a1e3d 100644 --- a/third_party/2and3/google/protobuf/type_pb2.pyi +++ b/third_party/2and3/google/protobuf/type_pb2.pyi @@ -1,89 +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: ... - + 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 @@ -105,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 @@ -135,67 +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: ... - + 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: ... - + 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: ... - + 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: ... + 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 7940f644d34d..8be9db18b9fa 100644 --- a/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_arena_pb2.pyi @@ -1,38 +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: ... - + 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: ... + 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 245cb1819eb9..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,385 +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: ... - + def __init__(self, field1: Optional[Text] = ..., oneof_field: Optional[int] = ...) -> None: ... class CustomOptionFooRequest(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class CustomOptionFooResponse(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class CustomOptionFooClientMessage(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class CustomOptionFooServerMessage(Message): - - def __init__(self, - ) -> None: ... - + 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: ... - + def __init__(self,) -> None: ... class DummyMessageInvalidAsOptionType(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class CustomOptionMinIntegerValues(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class CustomOptionMaxIntegerValues(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class CustomOptionOtherValues(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class SettingRealsFromPositiveInts(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class SettingRealsFromNegativeInts(Message): - - def __init__(self, - ) -> None: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__( + self, qux: Optional[int] = ..., complexoptiontype5: Optional[ComplexOptionType3.ComplexOptionType5] = ... + ) -> None: ... class ComplexOpt6(Message): xyzzy: int - - def __init__(self, - xyzzy: Optional[int] = ..., - ) -> None: ... - + def __init__(self, xyzzy: Optional[int] = ...) -> None: ... class VariousComplexOptions(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class AggregateMessageSet(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class AggregateMessageSetElement(Message): s: Text - - def __init__(self, - s: Optional[Text] = ..., - ) -> None: ... - + 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: ... - + 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: ... - + 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: ... - - def __init__(self, - ) -> None: ... - + 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: ... - + 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: ... - + def __init__(self, value: NewOptionType.TestEnum) -> None: ... class TestMessageWithRequiredEnumOption(Message): - - def __init__(self, - ) -> None: ... + 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 a42387ae1ba0..3d4b91cf02e0 100644 --- a/third_party/2and3/google/protobuf/unittest_import_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_import_pb2.pyi @@ -1,64 +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: ... + 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 2207c11041ae..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,15 +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: ... + 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 f30569d69bfa..60a204c2a085 100644 --- a/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_mset_pb2.pyi @@ -1,61 +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: ... - + def __init__(self, message_set: Optional[TestMessageSet] = ...) -> None: ... class TestMessageSetExtension1(Message): i: int - - def __init__(self, - i: Optional[int] = ..., - ) -> None: ... - + def __init__(self, i: Optional[int] = ...) -> None: ... class TestMessageSetExtension2(Message): str: Text - - def __init__(self, - bytes: Optional[Text] = ..., - ) -> None: ... - + 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: ... - + 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: ... + 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 2855d035e7b1..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,23 +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: ... - + def __init__(self,) -> None: ... class TestMessageSetWireFormatContainer(Message): - @property def message_set(self) -> TestMessageSet: ... - - def __init__(self, - message_set: Optional[TestMessageSet] = ..., - ) -> None: ... + 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 7bca5da7082a..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,15 +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: ... + 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 8185f2cfccf8..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,235 +1,225 @@ - -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: ... - + def __init__(self, bb: Optional[int] = ...) -> None: ... class OptionalGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class RepeatedGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... + optional_int32: int + optional_int64: int + optional_uint32: int + optional_uint64: int + optional_sint32: int + optional_sint64: int + optional_fixed32: int + optional_fixed64: int + optional_sfixed32: int + optional_sfixed64: int + optional_float: float + optional_double: float + optional_bool: bool + optional_string: Text + optional_bytes: bytes + optional_nested_enum: TestAllTypes.NestedEnum + optional_foreign_enum: ForeignEnum + optional_import_enum: ImportEnum + optional_string_piece: Text + optional_cord: Text + repeated_int32: RepeatedScalarFieldContainer[int] + repeated_int64: RepeatedScalarFieldContainer[int] + repeated_uint32: RepeatedScalarFieldContainer[int] + repeated_uint64: RepeatedScalarFieldContainer[int] + repeated_sint32: RepeatedScalarFieldContainer[int] + repeated_sint64: RepeatedScalarFieldContainer[int] + repeated_fixed32: RepeatedScalarFieldContainer[int] + repeated_fixed64: RepeatedScalarFieldContainer[int] + repeated_sfixed32: RepeatedScalarFieldContainer[int] + repeated_sfixed64: RepeatedScalarFieldContainer[int] + repeated_float: RepeatedScalarFieldContainer[float] + repeated_double: RepeatedScalarFieldContainer[float] + repeated_bool: RepeatedScalarFieldContainer[bool] + repeated_string: RepeatedScalarFieldContainer[Text] + repeated_bytes: RepeatedScalarFieldContainer[bytes] + repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypes.NestedEnum] + repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] + repeated_import_enum: RepeatedScalarFieldContainer[ImportEnum] + repeated_string_piece: RepeatedScalarFieldContainer[Text] + repeated_cord: RepeatedScalarFieldContainer[Text] + default_int32: int + default_int64: int + default_uint32: int + default_uint64: int + default_sint32: int + default_sint64: int + default_fixed32: int + default_fixed64: int + default_sfixed32: int + default_sfixed64: int + default_float: float + default_double: float + default_bool: bool + default_string: Text + default_bytes: bytes + default_nested_enum: TestAllTypes.NestedEnum + default_foreign_enum: ForeignEnum + default_import_enum: ImportEnum + default_string_piece: Text + default_cord: Text + 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: ... - + 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: ... - + def __init__(self, c: Optional[int] = ...) -> None: ... class TestNoArenaMessage(Message): - @property def arena_message(self) -> ArenaMessage: ... - - def __init__(self, - arena_message: Optional[ArenaMessage] = ..., - ) -> None: ... + 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 a791742c0559..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,38 +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: ... + 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 5ff590577699..26bc91730d64 100644 --- a/third_party/2and3/google/protobuf/unittest_pb2.pyi +++ b/third_party/2and3/google/protobuf/unittest_pb2.pyi @@ -1,93 +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 @@ -96,276 +58,257 @@ 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: ... - + def __init__(self, bb: Optional[int] = ...) -> None: ... class OptionalGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class RepeatedGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... + optional_int32: int + optional_int64: int + optional_uint32: int + optional_uint64: int + optional_sint32: int + optional_sint64: int + optional_fixed32: int + optional_fixed64: int + optional_sfixed32: int + optional_sfixed64: int + optional_float: float + optional_double: float + optional_bool: bool + optional_string: Text + optional_bytes: bytes + optional_nested_enum: TestAllTypes.NestedEnum + optional_foreign_enum: ForeignEnum + optional_import_enum: ImportEnum + optional_string_piece: Text + optional_cord: Text + repeated_int32: RepeatedScalarFieldContainer[int] + repeated_int64: RepeatedScalarFieldContainer[int] + repeated_uint32: RepeatedScalarFieldContainer[int] + repeated_uint64: RepeatedScalarFieldContainer[int] + repeated_sint32: RepeatedScalarFieldContainer[int] + repeated_sint64: RepeatedScalarFieldContainer[int] + repeated_fixed32: RepeatedScalarFieldContainer[int] + repeated_fixed64: RepeatedScalarFieldContainer[int] + repeated_sfixed32: RepeatedScalarFieldContainer[int] + repeated_sfixed64: RepeatedScalarFieldContainer[int] + repeated_float: RepeatedScalarFieldContainer[float] + repeated_double: RepeatedScalarFieldContainer[float] + repeated_bool: RepeatedScalarFieldContainer[bool] + repeated_string: RepeatedScalarFieldContainer[Text] + repeated_bytes: RepeatedScalarFieldContainer[bytes] + repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypes.NestedEnum] + repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] + repeated_import_enum: RepeatedScalarFieldContainer[ImportEnum] + repeated_string_piece: RepeatedScalarFieldContainer[Text] + repeated_cord: RepeatedScalarFieldContainer[Text] + default_int32: int + default_int64: int + default_uint32: int + default_uint64: int + default_sint32: int + default_sint64: int + default_fixed32: int + default_fixed64: int + default_sfixed32: int + default_sfixed64: int + default_float: float + default_double: float + default_bool: bool + default_string: Text + default_bytes: bytes + default_nested_enum: TestAllTypes.NestedEnum + default_foreign_enum: ForeignEnum + default_import_enum: ImportEnum + default_string_piece: Text + default_cord: Text + 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: ... - + 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: ... - + 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: ... - + def __init__(self, deprecated_int32: Optional[int] = ..., deprecated_int32_in_oneof: Optional[int] = ...) -> None: ... class TestDeprecatedMessage(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class ForeignMessage(Message): c: int d: int - - def __init__(self, - c: Optional[int] = ..., - d: Optional[int] = ..., - ) -> None: ... - + def __init__(self, c: Optional[int] = ..., d: Optional[int] = ...) -> None: ... class TestReservedFields(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class TestAllExtensions(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class OptionalGroup_extension(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class RepeatedGroup_extension(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class TestGroup(Message): class OptionalGroup(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + 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: ... - + def __init__( + self, optionalgroup: Optional[TestGroup.OptionalGroup] = ..., optional_foreign_enum: Optional[ForeignEnum] = ... + ) -> None: ... class TestGroupExtension(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class TestNestedExtension(Message): class OptionalGroup_extension(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - - def __init__(self, - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... + def __init__(self,) -> None: ... class TestRequired(Message): a: int @@ -401,270 +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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__(self, foreign_nested: Optional[TestAllTypes.NestedMessage] = ...) -> None: ... class TestEmptyMessage(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class TestEmptyMessageWithExtensions(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class TestMultipleExtensionRanges(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class TestReallyLargeTagNumber(Message): a: int bb: int - - def __init__(self, - a: Optional[int] = ..., - bb: Optional[int] = ..., - ) -> None: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__(self, i: int) -> None: ... @property def subgroup(self) -> TestIsInitialized.SubMessage.SubGroup: ... - - def __init__(self, - subgroup: Optional[TestIsInitialized.SubMessage.SubGroup] = ..., - ) -> None: ... - + 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: ... - + def __init__(self, sub_message: Optional[TestIsInitialized.SubMessage] = ...) -> None: ... class TestDupFieldNumber(Message): class Foo(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + def __init__(self, a: Optional[int] = ...) -> None: ... class Bar(Message): a: int - - def __init__(self, - a: Optional[int] = ..., - ) -> None: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def optional_nested_message(self) -> TestNestedMessageHasBits.NestedMessage: ... + def __init__(self, optional_nested_message: Optional[TestNestedMessageHasBits.NestedMessage] = ...) -> None: ... class TestCamelCaseFieldNames(Message): PrimitiveField: int @@ -677,71 +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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - - def __init__(self, - my_string: Optional[Text] = ..., - ) -> None: ... - + def __init__(self, my_string: Optional[Text] = ...) -> None: ... + my_string: Text + def __init__(self, my_string: Optional[Text] = ...) -> None: ... class TestExtremeDefaultValues(Message): escaped_bytes: bytes @@ -771,251 +600,193 @@ 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: ... - + 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: ... - + def __init__(self, sparse_enum: Optional[TestSparseEnum] = ...) -> None: ... class OneString(Message): data: Text - - def __init__(self, - data: Optional[Text] = ..., - ) -> None: ... - + def __init__(self, data: Optional[Text] = ...) -> None: ... class MoreString(Message): data: RepeatedScalarFieldContainer[Text] - - def __init__(self, - data: Optional[Iterable[Text]] = ..., - ) -> None: ... - + def __init__(self, data: Optional[Iterable[Text]] = ...) -> None: ... class OneBytes(Message): data: bytes - - def __init__(self, - data: Optional[bytes] = ..., - ) -> None: ... - + def __init__(self, data: Optional[bytes] = ...) -> None: ... class MoreBytes(Message): data: RepeatedScalarFieldContainer[bytes] - - def __init__(self, - data: Optional[Iterable[bytes]] = ..., - ) -> None: ... - + def __init__(self, data: Optional[Iterable[bytes]] = ...) -> None: ... class Int32Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class Uint32Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class Int64Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class Uint64Message(Message): data: int - - def __init__(self, - data: Optional[int] = ..., - ) -> None: ... - + def __init__(self, data: Optional[int] = ...) -> None: ... class BoolMessage(Message): data: bool - - def __init__(self, - data: Optional[bool] = ..., - ) -> None: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__(self, qux_int: Optional[int] = ..., corge_int: Optional[Iterable[int]] = ...) -> None: ... + foo_int: int + foo_string: Text + foo_cord: Text + foo_string_piece: Text + foo_bytes: bytes + foo_enum: TestOneof2.NestedEnum + bar_int: int + bar_string: Text + bar_cord: Text + bar_string_piece: Text + bar_bytes: bytes + 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: ... - + 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: ... - + 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: ... - + def __init__( + self, + foo_int: Optional[int] = ..., + foo_string: Optional[Text] = ..., + foo_message: Optional[TestRequiredOneof.NestedMessage] = ..., + ) -> None: ... class TestPackedTypes(Message): packed_int32: RepeatedScalarFieldContainer[int] @@ -1032,24 +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: ... - + 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] @@ -1066,82 +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: ... - + 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: ... - + def __init__(self,) -> None: ... class TestUnpackedExtensions(Message): - - def __init__(self, - ) -> None: ... - + 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: ... - + 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: ... - + 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] @@ -1150,157 +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: ... - + 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: ... - + def __init__(self, field1: Optional[TestAllTypes] = ...) -> None: ... class Group2(Message): - @property def field1(self) -> TestAllTypes: ... - - def __init__(self, - field1: Optional[TestAllTypes] = ..., - ) -> None: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__(self, a: Optional[Text] = ...) -> None: ... class FooRequest(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class FooResponse(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class FooClientMessage(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class FooServerMessage(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class BarRequest(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class BarResponse(Message): - - def __init__(self, - ) -> None: ... - + def __init__(self,) -> None: ... class TestJsonName(Message): field_name1: int @@ -1309,63 +1005,59 @@ 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: ... - + 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: ... - + 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: ... - + def __init__(self, key: Optional[Text] = ..., value: Optional[Text] = ...) -> None: ... + optional_int32: int + fixed_32: int + repeated_int32: RepeatedScalarFieldContainer[int] + packed_int32: RepeatedScalarFieldContainer[int] + optional_enum: ForeignEnum + optional_string: Text + optional_bytes: bytes + 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: ... - + 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 @@ -1377,15 +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: ... + 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 32da8d4f25b1..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,67 +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 @@ -69,106 +38,127 @@ class TestAllTypes(Message): BAR: TestAllTypes.NestedEnum BAZ: TestAllTypes.NestedEnum NEG: TestAllTypes.NestedEnum - class NestedMessage(Message): bb: int - - def __init__(self, - bb: Optional[int] = ..., - ) -> None: ... - + def __init__(self, bb: Optional[int] = ...) -> None: ... + optional_int32: int + optional_int64: int + optional_uint32: int + optional_uint64: int + optional_sint32: int + optional_sint64: int + optional_fixed32: int + optional_fixed64: int + optional_sfixed32: int + optional_sfixed64: int + optional_float: float + optional_double: float + optional_bool: bool + optional_string: Text + optional_bytes: bytes + optional_nested_enum: TestAllTypes.NestedEnum + optional_foreign_enum: ForeignEnum + optional_string_piece: Text + optional_cord: Text + repeated_int32: RepeatedScalarFieldContainer[int] + repeated_int64: RepeatedScalarFieldContainer[int] + repeated_uint32: RepeatedScalarFieldContainer[int] + repeated_uint64: RepeatedScalarFieldContainer[int] + repeated_sint32: RepeatedScalarFieldContainer[int] + repeated_sint64: RepeatedScalarFieldContainer[int] + repeated_fixed32: RepeatedScalarFieldContainer[int] + repeated_fixed64: RepeatedScalarFieldContainer[int] + repeated_sfixed32: RepeatedScalarFieldContainer[int] + repeated_sfixed64: RepeatedScalarFieldContainer[int] + repeated_float: RepeatedScalarFieldContainer[float] + repeated_double: RepeatedScalarFieldContainer[float] + repeated_bool: RepeatedScalarFieldContainer[bool] + repeated_string: RepeatedScalarFieldContainer[Text] + repeated_bytes: RepeatedScalarFieldContainer[bytes] + repeated_nested_enum: RepeatedScalarFieldContainer[TestAllTypes.NestedEnum] + repeated_foreign_enum: RepeatedScalarFieldContainer[ForeignEnum] + repeated_string_piece: RepeatedScalarFieldContainer[Text] + repeated_cord: RepeatedScalarFieldContainer[Text] + 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: ... - + 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] @@ -185,24 +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: ... - + 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] @@ -219,53 +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: ... - + 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: ... - + 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: ... - + def __init__(self, c: Optional[int] = ...) -> None: ... class TestEmptyMessage(Message): - - def __init__(self, - ) -> None: ... + 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 bda01700081e..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,31 +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, @@ -37,47 +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: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class TestMessage(Message): bool_value: bool @@ -100,467 +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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + 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: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class TestExtensions(Message): - @property def extensions(self) -> TestAllExtensions: ... - - def __init__(self, - extensions: Optional[TestAllExtensions] = ..., - ) -> None: ... - + 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: ... + 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 1e70f817eb71..342d0e043d2f 100644 --- a/third_party/2and3/google/protobuf/wrappers_pb2.pyi +++ b/third_party/2and3/google/protobuf/wrappers_pb2.pyi @@ -1,80 +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: ... - + def __init__(self, value: Optional[float] = ...) -> None: ... class FloatValue(Message): value: float - - def __init__(self, - value: Optional[float] = ..., - ) -> None: ... - + def __init__(self, value: Optional[float] = ...) -> None: ... class Int64Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class UInt64Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class Int32Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class UInt32Value(Message): value: int - - def __init__(self, - value: Optional[int] = ..., - ) -> None: ... - + def __init__(self, value: Optional[int] = ...) -> None: ... class BoolValue(Message): value: bool - - def __init__(self, - value: Optional[bool] = ..., - ) -> None: ... - + def __init__(self, value: Optional[bool] = ...) -> None: ... class StringValue(Message): value: Text - - def __init__(self, - value: Optional[Text] = ..., - ) -> None: ... - + def __init__(self, value: Optional[Text] = ...) -> None: ... class BytesValue(Message): value: bytes - - def __init__(self, - value: Optional[bytes] = ..., - ) -> None: ... + def __init__(self, value: Optional[bytes] = ...) -> None: ... From 6c42f6bb2f832909655bc550cdf1e870cd8ddd54 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Mon, 14 Oct 2019 23:01:24 -0400 Subject: [PATCH 40/59] Add bdb stubs (#3354) --- stdlib/2and3/bdb.pyi | 94 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 stdlib/2and3/bdb.pyi 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: ... From dfe68625eceb86c8b82074a7eaec4932feaf68f5 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Tue, 15 Oct 2019 00:03:29 -0400 Subject: [PATCH 41/59] Add public missing asyncio stubs for windows and proactor files (#3234) * Add public missing asyncio stubs for windows and proactor files, and any necessary private return/argument types. * Add methods to BaseProactorEventLoop that mypy is complaining about, with note about status at runtime * Add asyncio constants file --- stdlib/3/asyncio/constants.pyi | 13 ++++++ stdlib/3/asyncio/proactor_events.pyi | 61 ++++++++++++++++++++++++++++ stdlib/3/asyncio/selector_events.pyi | 26 ++++++++++++ stdlib/3/asyncio/transports.pyi | 5 +++ stdlib/3/asyncio/windows_events.pyi | 58 ++++++++++++++++++++++++++ stdlib/3/asyncio/windows_utils.pyi | 21 ++++++++++ 6 files changed, 184 insertions(+) create mode 100644 stdlib/3/asyncio/constants.pyi create mode 100644 stdlib/3/asyncio/proactor_events.pyi create mode 100644 stdlib/3/asyncio/selector_events.pyi create mode 100644 stdlib/3/asyncio/windows_events.pyi create mode 100644 stdlib/3/asyncio/windows_utils.pyi 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/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/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/transports.pyi b/stdlib/3/asyncio/transports.pyi index dbd491e18375..df80beb4eda9 100644 --- a/stdlib/3/asyncio/transports.pyi +++ b/stdlib/3/asyncio/transports.pyi @@ -1,6 +1,7 @@ import sys from typing import Any, Mapping, List, Optional, Tuple from asyncio.protocols import BaseProtocol +from asyncio.events import AbstractEventLoop class BaseTransport: def __init__(self, extra: Mapping[Any, Any] = ...) -> None: ... @@ -41,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: ... From b969ead0ce580f53d684878f651e44289613fc6a Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 15 Oct 2019 14:14:48 +0200 Subject: [PATCH 42/59] Reorder memoryview.__setitem__ overloads (#3365) Necessary for python/mypy#7717 --- stdlib/2/__builtin__.pyi | 4 ++-- stdlib/2and3/builtins.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index ebbf032d6bbe..0a39dae9f752 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -812,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]: ... diff --git a/stdlib/2and3/builtins.pyi b/stdlib/2and3/builtins.pyi index ebbf032d6bbe..0a39dae9f752 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -812,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]: ... From 89f0f635022b274f759feda3f5d6350a1f88500a Mon Sep 17 00:00:00 2001 From: cptpcrd <31829097+cptpcrd@users.noreply.github.com> Date: Tue, 15 Oct 2019 08:42:25 -0400 Subject: [PATCH 43/59] Fix HTMLParser.handle_startendtag() attrs annotation (#3366) The value can be None here as well as in handle_starttag(). --- stdlib/3/html/parser.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/html/parser.pyi b/stdlib/3/html/parser.pyi index 874b85057bc5..4c037845a3b0 100644 --- a/stdlib/3/html/parser.pyi +++ b/stdlib/3/html/parser.pyi @@ -13,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: ... From 67629a14a7863addcd3fdf118415bfd1614ab54a Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Wed, 16 Oct 2019 11:11:23 -0400 Subject: [PATCH 44/59] Add stubs for cgitb (#3368) --- stdlib/2and3/cgitb.pyi | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 stdlib/2and3/cgitb.pyi 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: ... From 299d89ab76f6fbd75c972a01c7c14ac41c66c245 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 16 Oct 2019 17:55:23 +0200 Subject: [PATCH 45/59] generate_tokens(readline) must return bytes (#3372) --- stdlib/3/tokenize.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/tokenize.pyi b/stdlib/3/tokenize.pyi index b3c5fd9641b6..60b6ec97ef49 100644 --- a/stdlib/3/tokenize.pyi +++ b/stdlib/3/tokenize.pyi @@ -41,7 +41,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 From 6058c2313661db047fc5af48d20fe6c5e8fa4b3b Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Wed, 16 Oct 2019 13:12:45 -0400 Subject: [PATCH 46/59] Make path separator based on OS separator (#3375) --- tests/pytype_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From 6e4f6403acaf540c41a5edbf6f13a4b64838f9cb Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Wed, 16 Oct 2019 20:41:38 +0200 Subject: [PATCH 47/59] Add PEP 593 (Annotated etc.) typing_extensions stubs (#3369) The code has been added to typing_extensions in https://github.com/python/typing/pull/632 and https://github.com/python/typing/pull/639/. --- third_party/2and3/typing_extensions.pyi | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 From 7c6104ddfe000b76cb52b1bc01046138c233aeec Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Wed, 16 Oct 2019 12:39:56 -0700 Subject: [PATCH 48/59] Don't shadow ast.Tuple with typing.Tuple (#3376) --- stdlib/3/ast.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/3/ast.pyi b/stdlib/3/ast.pyi index c278d80df23f..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 Any, Iterator, Optional, Tuple, TypeVar, Union, overload +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, @@ -32,7 +32,7 @@ if sys.version_info >= (3, 8): filename: Union[str, bytes] = ..., mode: Literal["exec"] = ..., type_comments: bool = ..., - feature_version: Union[None, int, Tuple[int, int]] = ..., + feature_version: Union[None, int, _typing.Tuple[int, int]] = ..., ) -> Module: ... @overload def parse( @@ -40,7 +40,7 @@ if sys.version_info >= (3, 8): filename: Union[str, bytes] = ..., mode: str = ..., type_comments: bool = ..., - feature_version: Union[None, int, Tuple[int, int]] = ..., + feature_version: Union[None, int, _typing.Tuple[int, int]] = ..., ) -> AST: ... else: From 6b68fb04c92598bd77f9bee18ab2a1aa72bbd93a Mon Sep 17 00:00:00 2001 From: Trim21 Date: Thu, 17 Oct 2019 21:01:55 +0800 Subject: [PATCH 49/59] pymysql.Cursor is a context manager (#3379) --- third_party/2and3/pymysql/cursors.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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]]: ... From fa9e1ab4452777e61a61f6cdcce2347f6897e23d Mon Sep 17 00:00:00 2001 From: Nathaniel Brahms Date: Thu, 17 Oct 2019 08:43:37 -0700 Subject: [PATCH 50/59] multiprocessing.pool: Fix return of map_async() (#3378) Closes #3377 --- stdlib/3/multiprocessing/pool.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/multiprocessing/pool.pyi b/stdlib/3/multiprocessing/pool.pyi index 479c4f21834d..5d37644306e7 100644 --- a/stdlib/3/multiprocessing/pool.pyi +++ b/stdlib/3/multiprocessing/pool.pyi @@ -46,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] = ..., From fd7f1063d5e6c066fa54bfee7698863f617b1b69 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Thu, 17 Oct 2019 21:30:14 +0200 Subject: [PATCH 51/59] Change select() stub to accept iterables, not just sequences (#3382) --- stdlib/2and3/select.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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]]: ... From 966f8d24e6a8ae1129fdb9f75a8e087ac7d956a7 Mon Sep 17 00:00:00 2001 From: "Eric N. Vander Weele" Date: Thu, 17 Oct 2019 18:10:41 -0400 Subject: [PATCH 52/59] Revert __import__ function annotation to return type back to Any (#3383) From python/mypy#7582. This partially reverts back the change in 0ee7c3c38b05a4d1712353bda5e6cffdaab2438b to have `__import__` return `Any` instead of `ModuleType`. --- stdlib/2/__builtin__.pyi | 4 ++-- stdlib/2and3/builtins.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index 0a39dae9f752..453cc040aefa 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -11,7 +11,7 @@ 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,): @@ -1455,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/builtins.pyi b/stdlib/2and3/builtins.pyi index 0a39dae9f752..453cc040aefa 100644 --- a/stdlib/2and3/builtins.pyi +++ b/stdlib/2and3/builtins.pyi @@ -11,7 +11,7 @@ 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,): @@ -1455,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. From 38fbdc94905c5ba3b4e6653ee52697b4f7c4e399 Mon Sep 17 00:00:00 2001 From: David Tucker Date: Fri, 18 Oct 2019 01:22:02 -0700 Subject: [PATCH 53/59] Fix show_default type in click.option signatures (#3385) --- third_party/2and3/click/decorators.pyi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 = ..., From bf862d907957e46b97419565a5bb90314d074ee4 Mon Sep 17 00:00:00 2001 From: JR Heard Date: Fri, 18 Oct 2019 01:23:16 -0700 Subject: [PATCH 54/59] Add missing @property to Response.next() stub (#3384) --- third_party/2and3/requests/models.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/2and3/requests/models.pyi b/third_party/2and3/requests/models.pyi index ae62c79af800..ee98344c4ddd 100644 --- a/third_party/2and3/requests/models.pyi +++ b/third_party/2and3/requests/models.pyi @@ -117,6 +117,7 @@ class Response: def __iter__(self) -> Iterator[bytes]: ... def __enter__(self) -> Response: ... def __exit__(self, *args: Any) -> None: ... + @property def next(self) -> Optional[PreparedRequest]: ... @property def ok(self) -> bool: ... From ffd73b3e8e5be428d6daa9debd8f4644f6f45cfb Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Fri, 18 Oct 2019 14:13:38 -0700 Subject: [PATCH 55/59] Add shlex.shlex.next in Python 2. (#3389) shlex.shlex should match the Iterator protocol, for which it needs both `__iter__` and `__next__` (`next` in Python 2) defined. --- stdlib/2/shlex.pyi | 1 + 1 file changed, 1 insertion(+) 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: ... From 3fbebc78cbe550e903f0164936a5d6c43f262b7f Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Fri, 18 Oct 2019 14:21:53 -0700 Subject: [PATCH 56/59] Require a more recent pytype version. (#3388) Yesterday's release contains a number of pyi parser fixes, such as support for the syntax in #3321. --- requirements-tests-py3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-tests-py3.txt b/requirements-tests-py3.txt index e5e3ba7da6d9..9547f1b04bc3 100644 --- a/requirements-tests-py3.txt +++ b/requirements-tests-py3.txt @@ -5,4 +5,4 @@ flake8==3.7.8 flake8-bugbear==19.8.0 flake8-pyi==19.3.0 isort==4.3.21 -pytype>=2019.7.30 +pytype>=2019.10.17 From 2b9dc7b9c221c9082fa96298f31b887d909bfdb1 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sun, 20 Oct 2019 00:07:04 +0300 Subject: [PATCH 57/59] Adds `posonlyargs` property to `arguments` for python3.8+ (#3390) --- stdlib/3/_ast.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/3/_ast.pyi b/stdlib/3/_ast.pyi index 7bc4e0f45ead..8dfdfbafec64 100644 --- a/stdlib/3/_ast.pyi +++ b/stdlib/3/_ast.pyi @@ -389,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] From ec7960a8cb2e2ff465ee0fff841cd28fa85fe3ba Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Sun, 20 Oct 2019 10:37:33 +0200 Subject: [PATCH 58/59] Convert namedtuples to class syntax (#3321) --- stdlib/2/functools.pyi | 1 - stdlib/2/inspect.pyi | 65 ++++++++-------- stdlib/2/os/__init__.pyi | 32 +++----- stdlib/2/resource.pyi | 24 ++++-- stdlib/2/spwd.pyi | 19 ++--- stdlib/2/urlparse.pyi | 34 ++++----- stdlib/2and3/_curses.pyi | 5 +- stdlib/2and3/aifc.pyi | 10 ++- stdlib/2and3/crypt.pyi | 3 +- stdlib/2and3/decimal.pyi | 8 +- stdlib/2and3/difflib.pyi | 9 +-- stdlib/2and3/dis.pyi | 22 +++--- stdlib/2and3/doctest.pyi | 7 +- stdlib/2and3/grp.pyi | 9 ++- stdlib/2and3/pkgutil.pyi | 5 +- stdlib/2and3/sched.pyi | 13 ++-- stdlib/2and3/shutil.pyi | 7 +- stdlib/2and3/sndhdr.pyi | 13 ++-- stdlib/2and3/ssl.pyi | 20 +++-- stdlib/2and3/sunau.pyi | 15 ++-- stdlib/2and3/time.pyi | 41 +++++----- stdlib/2and3/warnings.pyi | 14 ++-- stdlib/2and3/wave.pyi | 15 ++-- stdlib/3/_thread.pyi | 14 ++-- stdlib/3/functools.pyi | 12 ++- stdlib/3/inspect.pyi | 109 +++++++++++++-------------- stdlib/3/nntplib.pyi | 20 +++-- stdlib/3/os/__init__.pyi | 4 +- stdlib/3/platform.pyi | 8 +- stdlib/3/posix.pyi | 51 ++++++------- stdlib/3/resource.pyi | 23 ++++-- stdlib/3/selectors.pyi | 14 ++-- stdlib/3/spwd.pyi | 19 ++--- stdlib/3/tokenize.pyi | 13 ++-- stdlib/3/urllib/parse.pyi | 52 +++++++------ stdlib/3/urllib/robotparser.pyi | 4 +- third_party/2/tornado/gen.pyi | 7 +- third_party/2/tornado/httputil.pyi | 14 +++- third_party/2and3/decorator.pyi | 16 ++-- third_party/2and3/jinja2/filters.pyi | 4 +- third_party/2and3/werkzeug/urls.pyi | 15 ++-- 41 files changed, 402 insertions(+), 388 deletions(-) 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/inspect.pyi b/stdlib/2/inspect.pyi index b1acc30407cb..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]] = ... @@ -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/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/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/urlparse.pyi b/stdlib/2/urlparse.pyi index f1d1e3f2816d..4f54dde153e4 100644 --- a/stdlib/2/urlparse.pyi +++ b/stdlib/2/urlparse.pyi @@ -25,27 +25,23 @@ class ResultMixin(object): @property 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/_curses.pyi b/stdlib/2and3/_curses.pyi index fcfa2f1d8e1b..4126f36dedbf 100644 --- a/stdlib/2and3/_curses.pyi +++ b/stdlib/2and3/_curses.pyi @@ -454,5 +454,8 @@ class _CursesWindow: def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ... if sys.version_info >= (3, 8): - _ncurses_version = NamedTuple("ncurses_version", [("major", int), ("minor", int), ("patch", int)]) + class _ncurses_version(NamedTuple): + major: int + minor: int + patch: int ncurses_version: _ncurses_version 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/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/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/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/pkgutil.pyi b/stdlib/2and3/pkgutil.pyi index 122dff0004a2..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] 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/shutil.pyi b/stdlib/2and3/shutil.pyi index 81ef46f565f2..b4c6cc129ec1 100644 --- a/stdlib/2and3/shutil.pyi +++ b/stdlib/2and3/shutil.pyi @@ -114,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/ssl.pyi b/stdlib/2and3/ssl.pyi index cbc4c89f756b..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,13 +174,16 @@ 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: _ASN1Object CLIENT_AUTH: _ASN1Object 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/time.pyi b/stdlib/2and3/time.pyi index e3cdcdd8f08c..0c2370ad62a4 100644 --- a/stdlib/2and3/time.pyi +++ b/stdlib/2and3/time.pyi @@ -32,15 +32,19 @@ 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[ @@ -60,14 +64,17 @@ 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: ... 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/3/_thread.pyi b/stdlib/3/_thread.pyi index 7cd34a0451d5..051edefbb63f 100644 --- a/stdlib/3/_thread.pyi +++ b/stdlib/3/_thread.pyi @@ -35,14 +35,10 @@ TIMEOUT_MAX: int if sys.version_info >= (3, 8): def get_native_id() -> int: ... # only available on some platforms - ExceptHookArgs = NamedTuple( - "ExceptHookArgs", - [ - ("exc_type", Type[BaseException]), - ("exc_value", Optional[BaseException]), - ("exc_traceback", Optional[TracebackType]), - ("thread", Optional[Thread]), - ] - ) + 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/functools.pyi b/stdlib/3/functools.pyi index afffb3a41d30..78a3466eaa45 100644 --- a/stdlib/3/functools.pyi +++ b/stdlib/3/functools.pyi @@ -13,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] diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index 975b478287c9..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', Optional[Tuple[Any, ...]]), - ('kwonlyargs', List[str]), - ('kwonlydefaults', Optional[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/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 6d7eef7ebe83..b17a55736cd1 100644 --- a/stdlib/3/os/__init__.pyi +++ b/stdlib/3/os/__init__.pyi @@ -393,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: ... diff --git a/stdlib/3/platform.pyi b/stdlib/3/platform.pyi index ca3a08165150..858bb5930862 100644 --- a/stdlib/3/platform.pyi +++ b/stdlib/3/platform.pyi @@ -12,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 fe9782354c94..c6092ead447c 100644 --- a/stdlib/3/posix.pyi +++ b/stdlib/3/posix.pyi @@ -10,34 +10,29 @@ 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/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/tokenize.pyi b/stdlib/3/tokenize.pyi index 60b6ec97ef49..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 diff --git a/stdlib/3/urllib/parse.pyi b/stdlib/3/urllib/parse.pyi index 7f8120ad4aa8..fb303e5de2a8 100644 --- a/stdlib/3/urllib/parse.pyi +++ b/stdlib/3/urllib/parse.pyi @@ -39,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): ... 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/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/decorator.pyi b/third_party/2and3/decorator.pyi index 3443cd78b8d0..adf5ebe7b47a 100644 --- a/third_party/2and3/decorator.pyi +++ b/third_party/2and3/decorator.pyi @@ -11,14 +11,14 @@ if sys.version_info >= (3,): from inspect import iscoroutinefunction as iscoroutinefunction from inspect import getfullargspec as getfullargspec else: - 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: Tuple[Any, ...] + kwonlyargs: List[str] + kwonlydefaults: Dict[str, Any] + annotations: Dict[str, Any] def iscoroutinefunction(f: Callable[..., Any]) -> bool: ... def getfullargspec(func: Any) -> FullArgSpec: ... 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/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): ... From f28691261a9d1e1a7d4d4a74235dcca2e6a89020 Mon Sep 17 00:00:00 2001 From: Lawrence Chan Date: Sun, 20 Oct 2019 14:14:02 -0500 Subject: [PATCH 59/59] Change pprint depth type to Optional[int] (#3392) --- stdlib/2and3/pprint.pyi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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: ...