diff --git a/scripts/generate_proto_stubs.sh b/scripts/generate_proto_stubs.sh index 89edfc8b8..1bb7a8c6a 100755 --- a/scripts/generate_proto_stubs.sh +++ b/scripts/generate_proto_stubs.sh @@ -11,7 +11,7 @@ set -ex -o pipefail # followed by committing the changes to typeshed # # Update these two variables when rerunning script -PROTOBUF_VERSION=3.18.1 +PROTOBUF_VERSION=3.19.2 MYPY_PROTOBUF_VERSION=v3.0.0 if uname -a | grep Darwin; then @@ -74,4 +74,5 @@ protoc_install/bin/protoc --proto_path="$PYTHON_PROTOBUF_DIR/src" --mypy_out="$R isort "$REPO_ROOT/stubs/protobuf" black "$REPO_ROOT/stubs/protobuf" -sed -i="" "s/mypy-protobuf [^\"]*/mypy-protobuf ${MYPY_PROTOBUF_VERSION}/" "$REPO_ROOT/stubs/protobuf/METADATA.toml" +sed -i "" "s/mypy-protobuf [^\"]*/mypy-protobuf ${MYPY_PROTOBUF_VERSION}/" "$REPO_ROOT/stubs/protobuf/METADATA.toml" +sed -i "" "s/version = .*$/version = \"$(echo ${PROTOBUF_VERSION} | cut -d. -f1-2)\.\*\"/" "$REPO_ROOT/stubs/protobuf/METADATA.toml" diff --git a/stubs/protobuf/@tests/stubtest_allowlist.txt b/stubs/protobuf/@tests/stubtest_allowlist.txt index 2c5e07c85..5c52da428 100644 --- a/stubs/protobuf/@tests/stubtest_allowlist.txt +++ b/stubs/protobuf/@tests/stubtest_allowlist.txt @@ -99,13 +99,8 @@ google.protobuf.duration_pb2.Duration.__init__ google.protobuf.empty_pb2.Empty.__init__ google.protobuf.field_mask_pb2.FieldMask.__init__ google.protobuf.internal.containers.BaseContainer.sort -google.protobuf.internal.containers.Mapping google.protobuf.internal.containers.MessageMap.__init__ google.protobuf.internal.containers.MessageMap.get -google.protobuf.internal.containers.MutableMapping.__delitem__ -google.protobuf.internal.containers.MutableMapping.__setitem__ -google.protobuf.internal.containers.MutableMapping.pop -google.protobuf.internal.containers.MutableMapping.setdefault google.protobuf.internal.containers.RepeatedCompositeFieldContainer.__init__ google.protobuf.internal.containers.RepeatedScalarFieldContainer.__init__ google.protobuf.internal.containers.ScalarMap.__init__ @@ -123,7 +118,6 @@ google.protobuf.internal.well_known_types.Error google.protobuf.internal.well_known_types.ParseError google.protobuf.message.Message.DESCRIPTOR google.protobuf.message.Message.Extensions -google.protobuf.message.Message.FromString google.protobuf.message.Message.SerializePartialToString google.protobuf.message.Message.SerializeToString google.protobuf.message.Message.__init__ diff --git a/stubs/protobuf/METADATA.toml b/stubs/protobuf/METADATA.toml index c551073ba..cd11ebcd1 100644 --- a/stubs/protobuf/METADATA.toml +++ b/stubs/protobuf/METADATA.toml @@ -1,4 +1,4 @@ -version = "3.18.*" +version = "3.19.*" python2 = true requires = ["types-futures"] extra_description = "Generated with aid from mypy-protobuf v3.0.0" diff --git a/stubs/protobuf/google/protobuf/internal/containers.pyi b/stubs/protobuf/google/protobuf/internal/containers.pyi index cef517ec2..170f34cb5 100644 --- a/stubs/protobuf/google/protobuf/internal/containers.pyi +++ b/stubs/protobuf/google/protobuf/internal/containers.pyi @@ -1,18 +1,5 @@ -from typing import ( - Any, - Callable, - Iterable, - Iterator, - List, - Mapping as Mapping, - MutableMapping as MutableMapping, - Optional, - Sequence, - Text, - TypeVar, - Union, - overload, -) +from collections.abc import MutableMapping +from typing import Any, Callable, Iterable, Iterator, List, Optional, Sequence, Text, TypeVar, Union, overload from typing_extensions import SupportsIndex from google.protobuf.descriptor import Descriptor diff --git a/stubs/protobuf/google/protobuf/message.pyi b/stubs/protobuf/google/protobuf/message.pyi index 8d63932e1..9e23bae8f 100644 --- a/stubs/protobuf/google/protobuf/message.pyi +++ b/stubs/protobuf/google/protobuf/message.pyi @@ -1,5 +1,4 @@ -import sys -from typing import Any, ByteString, Sequence, Tuple, Type, TypeVar, Union +from typing import Any, Sequence, Tuple, Type, TypeVar from .descriptor import Descriptor, FieldDescriptor from .internal.extension_dict import _ExtensionDict, _ExtensionFieldDescriptor @@ -10,11 +9,6 @@ class EncodeError(Error): ... _M = TypeVar("_M", bound=Message) # message type (of self) -if sys.version_info >= (3, 0): - _Serialized = ByteString -else: - _Serialized = Union[bytes, buffer, unicode] - class Message: DESCRIPTOR: Descriptor def __deepcopy__(self, memo=...): ... @@ -25,8 +19,8 @@ class Message: def Clear(self) -> None: ... def SetInParent(self) -> None: ... def IsInitialized(self) -> bool: ... - def MergeFromString(self, serialized: _Serialized) -> int: ... - def ParseFromString(self, serialized: _Serialized) -> int: ... + def MergeFromString(self, serialized: bytes) -> int: ... + def ParseFromString(self, serialized: bytes) -> int: ... def SerializeToString(self, deterministic: bool = ...) -> bytes: ... def SerializePartialToString(self, deterministic: bool = ...) -> bytes: ... def ListFields(self) -> Sequence[Tuple[FieldDescriptor, Any]]: ... @@ -34,7 +28,7 @@ class Message: def ClearExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> None: ... def ByteSize(self) -> int: ... @classmethod - def FromString(cls: Type[_M], s: _Serialized) -> _M: ... + def FromString(cls: Type[_M], s: bytes) -> _M: ... @property def Extensions(self: _M) -> _ExtensionDict[_M]: ... # Intentionally left out typing on these three methods, because they are diff --git a/stubs/protobuf/google/protobuf/struct_pb2.pyi b/stubs/protobuf/google/protobuf/struct_pb2.pyi index 54e8df72a..ade8d5ad0 100644 --- a/stubs/protobuf/google/protobuf/struct_pb2.pyi +++ b/stubs/protobuf/google/protobuf/struct_pb2.pyi @@ -75,8 +75,8 @@ global___Struct = Struct class Value(google.protobuf.message.Message): """`Value` represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a - list of values. A producer of value is expected to set one of that - variants, absence of any variant indicates an error. + list of values. A producer of value is expected to set one of these + variants. Absence of any variant indicates an error. The JSON representation for `Value` is JSON value. """ diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index eafb77a63..52f866047 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import SupportsWrite from typing import Any, Callable, Iterable, Optional, Text, Tuple, TypeVar, Union @@ -6,9 +5,6 @@ from .descriptor import FieldDescriptor from .descriptor_pool import DescriptorPool from .message import Message -if sys.version_info < (3, 0): - long = int - _M = TypeVar("_M", bound=Message) # message type (of self) class Error(Exception): ...