From da9de2c52ca0163918183699c8bea2bd3be4707b Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 1 Apr 2024 11:41:55 -0700 Subject: [PATCH 1/7] Black format everything --- .github/workflows/main.yml | 2 +- mypy_protobuf/extensions_pb2.pyi | 1 + test/generated/google/protobuf/duration_pb2.pyi | 1 + test/generated/mypy_protobuf/extensions_pb2.pyi | 1 + test/generated/testproto/Capitalized/Capitalized_pb2.pyi | 1 + test/generated/testproto/comment_special_chars_pb2.pyi | 1 + test/generated/testproto/dot/com/test_pb2.pyi | 1 + test/generated/testproto/grpc/dummy_pb2.pyi | 1 + test/generated/testproto/grpc/dummy_pb2_grpc.pyi | 9 ++++++--- test/generated/testproto/grpc/import_pb2.pyi | 1 + test/generated/testproto/grpc/import_pb2_grpc.pyi | 8 +++++--- test/generated/testproto/inner/inner_pb2.pyi | 1 + test/generated/testproto/nested/nested_pb2.pyi | 1 + test/generated/testproto/nopackage_pb2.pyi | 1 + test/generated/testproto/readme_enum_pb2.pyi | 1 + test/generated/testproto/reexport_pb2.pyi | 1 + test/generated/testproto/test3_pb2.pyi | 2 ++ test/generated/testproto/test_extensions2_pb2.pyi | 1 + test/generated/testproto/test_extensions3_pb2.pyi | 1 + .../generated/testproto/test_no_generic_services_pb2.pyi | 1 + test/generated/testproto/test_pb2.pyi | 3 +++ 21 files changed, 33 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ec5b32d..bc609e3a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -92,7 +92,7 @@ jobs: - uses: actions/setup-python@v4 - name: Run formatters and linters run: | - pip3 install black isort flake8-pyi flake8-noqa flake8-bugbear + pip3 install black==24.3.0 isort flake8-pyi flake8-noqa flake8-bugbear black --check --extend-exclude '(_pb2_grpc|_pb2).pyi?$' . isort --check . --diff flake8 . diff --git a/mypy_protobuf/extensions_pb2.pyi b/mypy_protobuf/extensions_pb2.pyi index 7f4f364d..d8430c44 100644 --- a/mypy_protobuf/extensions_pb2.pyi +++ b/mypy_protobuf/extensions_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 diff --git a/test/generated/google/protobuf/duration_pb2.pyi b/test/generated/google/protobuf/duration_pb2.pyi index f8a80556..9213f322 100644 --- a/test/generated/google/protobuf/duration_pb2.pyi +++ b/test/generated/google/protobuf/duration_pb2.pyi @@ -31,6 +31,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.well_known_types diff --git a/test/generated/mypy_protobuf/extensions_pb2.pyi b/test/generated/mypy_protobuf/extensions_pb2.pyi index 7f4f364d..d8430c44 100644 --- a/test/generated/mypy_protobuf/extensions_pb2.pyi +++ b/test/generated/mypy_protobuf/extensions_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 diff --git a/test/generated/testproto/Capitalized/Capitalized_pb2.pyi b/test/generated/testproto/Capitalized/Capitalized_pb2.pyi index 162e1a06..bb0f20e4 100644 --- a/test/generated/testproto/Capitalized/Capitalized_pb2.pyi +++ b/test/generated/testproto/Capitalized/Capitalized_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/comment_special_chars_pb2.pyi b/test/generated/testproto/comment_special_chars_pb2.pyi index 31dc69dd..3326eaed 100644 --- a/test/generated/testproto/comment_special_chars_pb2.pyi +++ b/test/generated/testproto/comment_special_chars_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/dot/com/test_pb2.pyi b/test/generated/testproto/dot/com/test_pb2.pyi index b56b7e58..99b2c4b8 100644 --- a/test/generated/testproto/dot/com/test_pb2.pyi +++ b/test/generated/testproto/dot/com/test_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/grpc/dummy_pb2.pyi b/test/generated/testproto/grpc/dummy_pb2.pyi index 00fb65a8..f59d68a0 100644 --- a/test/generated/testproto/grpc/dummy_pb2.pyi +++ b/test/generated/testproto/grpc/dummy_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file https://github.com/vmagamedov/grpclib/blob/master/tests/dummy.proto""" + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi index 1ae2b9ea..9745eed3 100644 --- a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file https://github.com/vmagamedov/grpclib/blob/master/tests/dummy.proto""" + import abc import collections.abc import grpc @@ -9,10 +10,9 @@ import grpc.aio import testproto.grpc.dummy_pb2 import typing -_T = typing.TypeVar('_T') +_T = typing.TypeVar("_T") -class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): - ... +class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] ... @@ -76,6 +76,7 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.grpc.dummy_pb2.DummyReply, collections.abc.Awaitable[testproto.grpc.dummy_pb2.DummyReply]]: """UnaryUnary""" + @abc.abstractmethod def UnaryStream( self, @@ -83,6 +84,7 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[collections.abc.Iterator[testproto.grpc.dummy_pb2.DummyReply], collections.abc.AsyncIterator[testproto.grpc.dummy_pb2.DummyReply]]: """UnaryStream""" + @abc.abstractmethod def StreamUnary( self, @@ -90,6 +92,7 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.grpc.dummy_pb2.DummyReply, collections.abc.Awaitable[testproto.grpc.dummy_pb2.DummyReply]]: """StreamUnary""" + @abc.abstractmethod def StreamStream( self, diff --git a/test/generated/testproto/grpc/import_pb2.pyi b/test/generated/testproto/grpc/import_pb2.pyi index e08fa11c..dd854e28 100644 --- a/test/generated/testproto/grpc/import_pb2.pyi +++ b/test/generated/testproto/grpc/import_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import google.protobuf.descriptor DESCRIPTOR: google.protobuf.descriptor.FileDescriptor diff --git a/test/generated/testproto/grpc/import_pb2_grpc.pyi b/test/generated/testproto/grpc/import_pb2_grpc.pyi index aade3c5b..4ac598ea 100644 --- a/test/generated/testproto/grpc/import_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/import_pb2_grpc.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import abc import collections.abc import google.protobuf.empty_pb2 @@ -10,10 +11,9 @@ import grpc.aio import testproto.test_pb2 import typing -_T = typing.TypeVar('_T') +_T = typing.TypeVar("_T") -class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): - ... +class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] ... @@ -65,6 +65,7 @@ class SimpleServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.test_pb2.Simple1, collections.abc.Awaitable[testproto.test_pb2.Simple1]]: """UnaryUnary""" + @abc.abstractmethod def UnaryStream( self, @@ -72,6 +73,7 @@ class SimpleServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[google.protobuf.empty_pb2.Empty, collections.abc.Awaitable[google.protobuf.empty_pb2.Empty]]: """UnaryStream""" + @abc.abstractmethod def NoComment( self, diff --git a/test/generated/testproto/inner/inner_pb2.pyi b/test/generated/testproto/inner/inner_pb2.pyi index 84bb719c..53f367d4 100644 --- a/test/generated/testproto/inner/inner_pb2.pyi +++ b/test/generated/testproto/inner/inner_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/nested/nested_pb2.pyi b/test/generated/testproto/nested/nested_pb2.pyi index bc83b8e1..7a0ba77c 100644 --- a/test/generated/testproto/nested/nested_pb2.pyi +++ b/test/generated/testproto/nested/nested_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper diff --git a/test/generated/testproto/nopackage_pb2.pyi b/test/generated/testproto/nopackage_pb2.pyi index 5cb9430c..b0c539cc 100644 --- a/test/generated/testproto/nopackage_pb2.pyi +++ b/test/generated/testproto/nopackage_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import collections.abc import google.protobuf.descriptor diff --git a/test/generated/testproto/readme_enum_pb2.pyi b/test/generated/testproto/readme_enum_pb2.pyi index 2299c49d..8b287b5c 100644 --- a/test/generated/testproto/readme_enum_pb2.pyi +++ b/test/generated/testproto/readme_enum_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper diff --git a/test/generated/testproto/reexport_pb2.pyi b/test/generated/testproto/reexport_pb2.pyi index 1ae98bf4..9702c2bd 100644 --- a/test/generated/testproto/reexport_pb2.pyi +++ b/test/generated/testproto/reexport_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import google.protobuf.descriptor from google.protobuf.empty_pb2 import ( Empty as Empty, diff --git a/test/generated/testproto/test3_pb2.pyi b/test/generated/testproto/test3_pb2.pyi index 9571d1ad..40c7a2d1 100644 --- a/test/generated/testproto/test3_pb2.pyi +++ b/test/generated/testproto/test3_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file package test3""" + import builtins import collections.abc import google.protobuf.descriptor @@ -163,6 +164,7 @@ class SimpleProto3(google.protobuf.message.Message): @property def map_scalar(self) -> google.protobuf.internal.containers.ScalarMap[builtins.int, builtins.str]: """Test generation of map""" + @property def map_message(self) -> google.protobuf.internal.containers.MessageMap[builtins.int, global___OuterMessage3]: ... an_optional_string: builtins.str diff --git a/test/generated/testproto/test_extensions2_pb2.pyi b/test/generated/testproto/test_extensions2_pb2.pyi index 37592692..806c2a51 100644 --- a/test/generated/testproto/test_extensions2_pb2.pyi +++ b/test/generated/testproto/test_extensions2_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.extension_dict diff --git a/test/generated/testproto/test_extensions3_pb2.pyi b/test/generated/testproto/test_extensions3_pb2.pyi index 9d780f25..83360314 100644 --- a/test/generated/testproto/test_extensions3_pb2.pyi +++ b/test/generated/testproto/test_extensions3_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 diff --git a/test/generated/testproto/test_no_generic_services_pb2.pyi b/test/generated/testproto/test_no_generic_services_pb2.pyi index 4a36e3d2..945e9c8f 100644 --- a/test/generated/testproto/test_no_generic_services_pb2.pyi +++ b/test/generated/testproto/test_no_generic_services_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/test_pb2.pyi b/test/generated/testproto/test_pb2.pyi index 673320db..b618c49b 100644 --- a/test/generated/testproto/test_pb2.pyi +++ b/test/generated/testproto/test_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file Proto 2 test file.""" + import abc import builtins import collections.abc @@ -396,6 +397,7 @@ class PythonReservedKeywordsService(google.protobuf.service.Service, metaclass=a callback: collections.abc.Callable[[global____r_None], None] | None, ) -> concurrent.futures.Future[global____r_None]: """valid_method_name1""" + @abc.abstractmethod def valid_method_name2( inst: PythonReservedKeywordsService, # pyright: ignore[reportSelfClsParameterName] @@ -417,6 +419,7 @@ class PythonReservedKeywordsService_Stub(PythonReservedKeywordsService): callback: collections.abc.Callable[[global____r_None], None] | None = ..., ) -> concurrent.futures.Future[global____r_None]: """valid_method_name1""" + def valid_method_name2( inst: PythonReservedKeywordsService_Stub, # pyright: ignore[reportSelfClsParameterName] rpc_controller: google.protobuf.service.RpcController, From 80327d013a0c3f1b0a26ffd33f671485b39a0326 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 1 Apr 2024 11:49:42 -0700 Subject: [PATCH 2/7] Pin linter job to python 3.8 --- .github/workflows/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bc609e3a..c606061f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -89,7 +89,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 + with: + python-verison: "3.8" - name: Run formatters and linters run: | pip3 install black==24.3.0 isort flake8-pyi flake8-noqa flake8-bugbear @@ -107,7 +109,9 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 + with: + python-verison: "3.8" - name: Read versions run: echo ::set-output name=PROTOBUF_VERSION::$(grep "^protobuf>=" test_requirements.txt | cut -f2 -d=) id: read_versions From 5d58c92124b065b2691326ce4468738f0b00c374 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 1 Apr 2024 11:50:53 -0700 Subject: [PATCH 3/7] typo verison --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c606061f..01f0af89 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,7 +91,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-verison: "3.8" + python-version: "3.8" - name: Run formatters and linters run: | pip3 install black==24.3.0 isort flake8-pyi flake8-noqa flake8-bugbear @@ -111,7 +111,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-verison: "3.8" + python-version: "3.8" - name: Read versions run: echo ::set-output name=PROTOBUF_VERSION::$(grep "^protobuf>=" test_requirements.txt | cut -f2 -d=) id: read_versions From 1089636dc3a16b20fbf57f17518354aa40bff57c Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 1 Apr 2024 11:57:06 -0700 Subject: [PATCH 4/7] Remove compatibility to 3.7 --- .github/workflows/main.yml | 2 +- mypy_protobuf/extensions_pb2.pyi | 12 +--- mypy_protobuf/main.py | 12 ++-- .../google/protobuf/duration_pb2.pyi | 12 +--- .../mypy_protobuf/extensions_pb2.pyi | 12 +--- .../testproto/Capitalized/Capitalized_pb2.pyi | 24 +++---- .../testproto/comment_special_chars_pb2.pyi | 12 +--- test/generated/testproto/dot/com/test_pb2.pyi | 12 +--- test/generated/testproto/grpc/dummy_pb2.pyi | 16 ++--- .../testproto/grpc/dummy_pb2_grpc.pyi | 9 +-- test/generated/testproto/grpc/import_pb2.pyi | 1 - .../testproto/grpc/import_pb2_grpc.pyi | 8 +-- test/generated/testproto/inner/inner_pb2.pyi | 12 +--- .../generated/testproto/nested/nested_pb2.pyi | 11 ++- test/generated/testproto/nopackage_pb2.pyi | 16 ++--- test/generated/testproto/readme_enum_pb2.pyi | 1 - test/generated/testproto/reexport_pb2.pyi | 1 - test/generated/testproto/test3_pb2.pyi | 32 +++++---- .../testproto/test_extensions2_pb2.pyi | 14 ++-- .../testproto/test_extensions3_pb2.pyi | 10 +-- .../test_no_generic_services_pb2.pyi | 14 ++-- test/generated/testproto/test_pb2.pyi | 67 +++++++++---------- 22 files changed, 111 insertions(+), 199 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01f0af89..d5a1ae72 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -94,7 +94,7 @@ jobs: python-version: "3.8" - name: Run formatters and linters run: | - pip3 install black==24.3.0 isort flake8-pyi flake8-noqa flake8-bugbear + pip3 install black==24.3.0 isort flake8 flake8-pyi flake8-noqa flake8-bugbear black --check --extend-exclude '(_pb2_grpc|_pb2).pyi?$' . isort --check . --diff flake8 . diff --git a/mypy_protobuf/extensions_pb2.pyi b/mypy_protobuf/extensions_pb2.pyi index d8430c44..e50c8ab2 100644 --- a/mypy_protobuf/extensions_pb2.pyi +++ b/mypy_protobuf/extensions_pb2.pyi @@ -2,22 +2,16 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 import google.protobuf.internal.extension_dict import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class FieldOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -37,7 +31,7 @@ class FieldOptions(google.protobuf.message.Message): keytype: builtins.str = ..., valuetype: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["casttype", b"casttype", "keytype", b"keytype", "valuetype", b"valuetype"]) -> None: ... + def ClearField(self, field_name: typing.Literal["casttype", b"casttype", "keytype", b"keytype", "valuetype", b"valuetype"]) -> None: ... global___FieldOptions = FieldOptions diff --git a/mypy_protobuf/main.py b/mypy_protobuf/main.py index 4de8d977..388da249 100644 --- a/mypy_protobuf/main.py +++ b/mypy_protobuf/main.py @@ -169,9 +169,7 @@ def _import(self, path: str, name: str) -> str: """ if path == "typing_extensions": stabilization = { - "Literal": (3, 8), "TypeAlias": (3, 10), - "final": (3, 8), } assert name in stabilization if not self.typing_extensions_min or self.typing_extensions_min < stabilization[name]: @@ -407,7 +405,7 @@ def write_messages( class_name = desc.name if desc.name not in PYTHON_RESERVED else "_r_" + desc.name message_class = self._import("google.protobuf.message", "Message") - wl("@{}", self._import("typing_extensions", "final")) + wl("@{}", self._import("typing", "final")) wl(f"class {class_name}({message_class}{addl_base}):") with self._indent(): scl = scl_prefix + [i] @@ -506,14 +504,14 @@ def write_stringly_typed_fields(self, desc: d.DescriptorProto) -> None: if hf_fields: wl( "def HasField(self, field_name: {}[{}]) -> {}: ...", - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), hf_fields_text, self._builtin("bool"), ) if cf_fields: wl( "def ClearField(self, field_name: {}[{}]) -> None: ...", - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), cf_fields_text, ) @@ -522,10 +520,10 @@ def write_stringly_typed_fields(self, desc: d.DescriptorProto) -> None: wl("@{}", self._import("typing", "overload")) wl( "def WhichOneof(self, oneof_group: {}[{}]) -> {}[{}] | None: ...", - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), # Accepts both str and bytes f'"{wo_field}", b"{wo_field}"', - self._import("typing_extensions", "Literal"), + self._import("typing", "Literal"), # Returns `str` ", ".join(f'"{m}"' for m in members), ) diff --git a/test/generated/google/protobuf/duration_pb2.pyi b/test/generated/google/protobuf/duration_pb2.pyi index 9213f322..22d9b4df 100644 --- a/test/generated/google/protobuf/duration_pb2.pyi +++ b/test/generated/google/protobuf/duration_pb2.pyi @@ -31,21 +31,15 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ - import builtins import google.protobuf.descriptor import google.protobuf.internal.well_known_types import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Duration(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Duration): """A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond @@ -130,6 +124,6 @@ class Duration(google.protobuf.message.Message, google.protobuf.internal.well_kn seconds: builtins.int = ..., nanos: builtins.int = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["nanos", b"nanos", "seconds", b"seconds"]) -> None: ... + def ClearField(self, field_name: typing.Literal["nanos", b"nanos", "seconds", b"seconds"]) -> None: ... global___Duration = Duration diff --git a/test/generated/mypy_protobuf/extensions_pb2.pyi b/test/generated/mypy_protobuf/extensions_pb2.pyi index d8430c44..e50c8ab2 100644 --- a/test/generated/mypy_protobuf/extensions_pb2.pyi +++ b/test/generated/mypy_protobuf/extensions_pb2.pyi @@ -2,22 +2,16 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 import google.protobuf.internal.extension_dict import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class FieldOptions(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -37,7 +31,7 @@ class FieldOptions(google.protobuf.message.Message): keytype: builtins.str = ..., valuetype: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["casttype", b"casttype", "keytype", b"keytype", "valuetype", b"valuetype"]) -> None: ... + def ClearField(self, field_name: typing.Literal["casttype", b"casttype", "keytype", b"keytype", "valuetype", b"valuetype"]) -> None: ... global___FieldOptions = FieldOptions diff --git a/test/generated/testproto/Capitalized/Capitalized_pb2.pyi b/test/generated/testproto/Capitalized/Capitalized_pb2.pyi index bb0f20e4..a27666a6 100644 --- a/test/generated/testproto/Capitalized/Capitalized_pb2.pyi +++ b/test/generated/testproto/Capitalized/Capitalized_pb2.pyi @@ -2,20 +2,14 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class lower(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -26,11 +20,11 @@ class lower(google.protobuf.message.Message): *, a: builtins.int = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["a", b"a"]) -> None: ... + def ClearField(self, field_name: typing.Literal["a", b"a"]) -> None: ... global___lower = lower -@typing_extensions.final +@typing.final class Upper(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -42,12 +36,12 @@ class Upper(google.protobuf.message.Message): *, Lower: global___lower | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["Lower", b"Lower"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["Lower", b"Lower"]) -> None: ... + def HasField(self, field_name: typing.Literal["Lower", b"Lower"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["Lower", b"Lower"]) -> None: ... global___Upper = Upper -@typing_extensions.final +@typing.final class lower2(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -59,7 +53,7 @@ class lower2(google.protobuf.message.Message): *, upper: global___Upper | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["upper", b"upper"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["upper", b"upper"]) -> None: ... + def HasField(self, field_name: typing.Literal["upper", b"upper"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["upper", b"upper"]) -> None: ... global___lower2 = lower2 diff --git a/test/generated/testproto/comment_special_chars_pb2.pyi b/test/generated/testproto/comment_special_chars_pb2.pyi index 3326eaed..e90d0858 100644 --- a/test/generated/testproto/comment_special_chars_pb2.pyi +++ b/test/generated/testproto/comment_special_chars_pb2.pyi @@ -2,20 +2,14 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Test(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -76,6 +70,6 @@ class Test(google.protobuf.message.Message): j: builtins.str = ..., k: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["a", b"a", "b", b"b", "c", b"c", "d", b"d", "e", b"e", "f", b"f", "g", b"g", "h", b"h", "i", b"i", "j", b"j", "k", b"k"]) -> None: ... + def ClearField(self, field_name: typing.Literal["a", b"a", "b", b"b", "c", b"c", "d", b"d", "e", b"e", "f", b"f", "g", b"g", "h", b"h", "i", b"i", "j", b"j", "k", b"k"]) -> None: ... global___Test = Test diff --git a/test/generated/testproto/dot/com/test_pb2.pyi b/test/generated/testproto/dot/com/test_pb2.pyi index 99b2c4b8..34ecc15d 100644 --- a/test/generated/testproto/dot/com/test_pb2.pyi +++ b/test/generated/testproto/dot/com/test_pb2.pyi @@ -2,20 +2,14 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class TestMessage(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -26,6 +20,6 @@ class TestMessage(google.protobuf.message.Message): *, foo: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["foo", b"foo"]) -> None: ... + def ClearField(self, field_name: typing.Literal["foo", b"foo"]) -> None: ... global___TestMessage = TestMessage diff --git a/test/generated/testproto/grpc/dummy_pb2.pyi b/test/generated/testproto/grpc/dummy_pb2.pyi index f59d68a0..03eb43e8 100644 --- a/test/generated/testproto/grpc/dummy_pb2.pyi +++ b/test/generated/testproto/grpc/dummy_pb2.pyi @@ -2,20 +2,14 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file https://github.com/vmagamedov/grpclib/blob/master/tests/dummy.proto""" - import builtins import google.protobuf.descriptor import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class DummyRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -26,11 +20,11 @@ class DummyRequest(google.protobuf.message.Message): *, value: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___DummyRequest = DummyRequest -@typing_extensions.final +@typing.final class DummyReply(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -41,6 +35,6 @@ class DummyReply(google.protobuf.message.Message): *, value: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... global___DummyReply = DummyReply diff --git a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi index 9745eed3..1ae2b9ea 100644 --- a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file https://github.com/vmagamedov/grpclib/blob/master/tests/dummy.proto""" - import abc import collections.abc import grpc @@ -10,9 +9,10 @@ import grpc.aio import testproto.grpc.dummy_pb2 import typing -_T = typing.TypeVar("_T") +_T = typing.TypeVar('_T') -class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... +class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): + ... class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] ... @@ -76,7 +76,6 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.grpc.dummy_pb2.DummyReply, collections.abc.Awaitable[testproto.grpc.dummy_pb2.DummyReply]]: """UnaryUnary""" - @abc.abstractmethod def UnaryStream( self, @@ -84,7 +83,6 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[collections.abc.Iterator[testproto.grpc.dummy_pb2.DummyReply], collections.abc.AsyncIterator[testproto.grpc.dummy_pb2.DummyReply]]: """UnaryStream""" - @abc.abstractmethod def StreamUnary( self, @@ -92,7 +90,6 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.grpc.dummy_pb2.DummyReply, collections.abc.Awaitable[testproto.grpc.dummy_pb2.DummyReply]]: """StreamUnary""" - @abc.abstractmethod def StreamStream( self, diff --git a/test/generated/testproto/grpc/import_pb2.pyi b/test/generated/testproto/grpc/import_pb2.pyi index dd854e28..e08fa11c 100644 --- a/test/generated/testproto/grpc/import_pb2.pyi +++ b/test/generated/testproto/grpc/import_pb2.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import google.protobuf.descriptor DESCRIPTOR: google.protobuf.descriptor.FileDescriptor diff --git a/test/generated/testproto/grpc/import_pb2_grpc.pyi b/test/generated/testproto/grpc/import_pb2_grpc.pyi index 4ac598ea..aade3c5b 100644 --- a/test/generated/testproto/grpc/import_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/import_pb2_grpc.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import abc import collections.abc import google.protobuf.empty_pb2 @@ -11,9 +10,10 @@ import grpc.aio import testproto.test_pb2 import typing -_T = typing.TypeVar("_T") +_T = typing.TypeVar('_T') -class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... +class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): + ... class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] ... @@ -65,7 +65,6 @@ class SimpleServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.test_pb2.Simple1, collections.abc.Awaitable[testproto.test_pb2.Simple1]]: """UnaryUnary""" - @abc.abstractmethod def UnaryStream( self, @@ -73,7 +72,6 @@ class SimpleServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[google.protobuf.empty_pb2.Empty, collections.abc.Awaitable[google.protobuf.empty_pb2.Empty]]: """UnaryStream""" - @abc.abstractmethod def NoComment( self, diff --git a/test/generated/testproto/inner/inner_pb2.pyi b/test/generated/testproto/inner/inner_pb2.pyi index 53f367d4..0e51e054 100644 --- a/test/generated/testproto/inner/inner_pb2.pyi +++ b/test/generated/testproto/inner/inner_pb2.pyi @@ -2,21 +2,15 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.message -import sys import testproto.test3_pb2 - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Inner(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -27,6 +21,6 @@ class Inner(google.protobuf.message.Message): *, a: testproto.test3_pb2.OuterEnum.ValueType = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["a", b"a"]) -> None: ... + def ClearField(self, field_name: typing.Literal["a", b"a"]) -> None: ... global___Inner = Inner diff --git a/test/generated/testproto/nested/nested_pb2.pyi b/test/generated/testproto/nested/nested_pb2.pyi index 7a0ba77c..140fd614 100644 --- a/test/generated/testproto/nested/nested_pb2.pyi +++ b/test/generated/testproto/nested/nested_pb2.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper @@ -18,7 +17,7 @@ else: DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Nested(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -29,11 +28,11 @@ class Nested(google.protobuf.message.Message): *, a: testproto.test3_pb2.OuterEnum.ValueType = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["a", b"a"]) -> None: ... + def ClearField(self, field_name: typing.Literal["a", b"a"]) -> None: ... global___Nested = Nested -@typing_extensions.final +@typing.final class AnotherNested(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -52,7 +51,7 @@ class AnotherNested(google.protobuf.message.Message): ONE: AnotherNested.NestedEnum.ValueType # 1 TWO: AnotherNested.NestedEnum.ValueType # 2 - @typing_extensions.final + @typing.final class NestedMessage(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -87,7 +86,7 @@ class AnotherNested(google.protobuf.message.Message): ne: global___AnotherNested.NestedEnum.ValueType = ..., ne2: global___AnotherNested.NestedMessage.NestedEnum2.ValueType = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["b", b"b", "ne", b"ne", "ne2", b"ne2", "s", b"s"]) -> None: ... + def ClearField(self, field_name: typing.Literal["b", b"b", "ne", b"ne", "ne2", b"ne2", "s", b"s"]) -> None: ... def __init__( self, diff --git a/test/generated/testproto/nopackage_pb2.pyi b/test/generated/testproto/nopackage_pb2.pyi index b0c539cc..e9620c3b 100644 --- a/test/generated/testproto/nopackage_pb2.pyi +++ b/test/generated/testproto/nopackage_pb2.pyi @@ -2,22 +2,16 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import collections.abc import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class NoPackage(google.protobuf.message.Message): """Intentionally don't set a package - just to make sure we can handle it.""" @@ -29,7 +23,7 @@ class NoPackage(google.protobuf.message.Message): global___NoPackage = NoPackage -@typing_extensions.final +@typing.final class NoPackage2(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -45,7 +39,7 @@ class NoPackage2(google.protobuf.message.Message): np: global___NoPackage | None = ..., np_rep: collections.abc.Iterable[global___NoPackage] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["np", b"np"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["np", b"np", "np_rep", b"np_rep"]) -> None: ... + def HasField(self, field_name: typing.Literal["np", b"np"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["np", b"np", "np_rep", b"np_rep"]) -> None: ... global___NoPackage2 = NoPackage2 diff --git a/test/generated/testproto/readme_enum_pb2.pyi b/test/generated/testproto/readme_enum_pb2.pyi index 8b287b5c..2299c49d 100644 --- a/test/generated/testproto/readme_enum_pb2.pyi +++ b/test/generated/testproto/readme_enum_pb2.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper diff --git a/test/generated/testproto/reexport_pb2.pyi b/test/generated/testproto/reexport_pb2.pyi index 9702c2bd..1ae98bf4 100644 --- a/test/generated/testproto/reexport_pb2.pyi +++ b/test/generated/testproto/reexport_pb2.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import google.protobuf.descriptor from google.protobuf.empty_pb2 import ( Empty as Empty, diff --git a/test/generated/testproto/test3_pb2.pyi b/test/generated/testproto/test3_pb2.pyi index 40c7a2d1..494bc26c 100644 --- a/test/generated/testproto/test3_pb2.pyi +++ b/test/generated/testproto/test3_pb2.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file package test3""" - import builtins import collections.abc import google.protobuf.descriptor @@ -37,7 +36,7 @@ FOO3: OuterEnum.ValueType # 1 BAR3: OuterEnum.ValueType # 2 global___OuterEnum = OuterEnum -@typing_extensions.final +@typing.final class OuterMessage3(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -48,11 +47,11 @@ class OuterMessage3(google.protobuf.message.Message): *, a_string: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["a_string", b"a_string"]) -> None: ... + def ClearField(self, field_name: typing.Literal["a_string", b"a_string"]) -> None: ... global___OuterMessage3 = OuterMessage3 -@typing_extensions.final +@typing.final class SimpleProto3(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -69,7 +68,7 @@ class SimpleProto3(google.protobuf.message.Message): INNER1: SimpleProto3.InnerEnum.ValueType # 0 INNER2: SimpleProto3.InnerEnum.ValueType # 1 - @typing_extensions.final + @typing.final class MapScalarEntry(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -83,9 +82,9 @@ class SimpleProto3(google.protobuf.message.Message): key: builtins.int = ..., value: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... - @typing_extensions.final + @typing.final class MapMessageEntry(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -100,10 +99,10 @@ class SimpleProto3(google.protobuf.message.Message): key: builtins.int = ..., value: global___OuterMessage3 | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["value", b"value"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ... + def HasField(self, field_name: typing.Literal["value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... - @typing_extensions.final + @typing.final class EmailByUidEntry(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -117,7 +116,7 @@ class SimpleProto3(google.protobuf.message.Message): key: builtins.int = ..., value: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... A_STRING_FIELD_NUMBER: builtins.int A_REPEATED_STRING_FIELD_NUMBER: builtins.int @@ -164,7 +163,6 @@ class SimpleProto3(google.protobuf.message.Message): @property def map_scalar(self) -> google.protobuf.internal.containers.ScalarMap[builtins.int, builtins.str]: """Test generation of map""" - @property def map_message(self) -> google.protobuf.internal.containers.MessageMap[builtins.int, global___OuterMessage3]: ... an_optional_string: builtins.str @@ -197,13 +195,13 @@ class SimpleProto3(google.protobuf.message.Message): email: test.test_generated_mypy.Email = ..., email_by_uid: collections.abc.Mapping[test.test_generated_mypy.UserId, test.test_generated_mypy.Email] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["OuterMessage3", b"OuterMessage3", "_an_optional_string", b"_an_optional_string", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "an_optional_string", b"an_optional_string", "b_oneof", b"b_oneof", "b_oneof_1", b"b_oneof_1", "b_oneof_2", b"b_oneof_2", "bool", b"bool", "inner_enum_in_oneof", b"inner_enum_in_oneof", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message", b"outer_message", "outer_message_in_oneof", b"outer_message_in_oneof"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["OuterEnum", b"OuterEnum", "OuterMessage3", b"OuterMessage3", "_an_optional_string", b"_an_optional_string", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "a_outer_enum", b"a_outer_enum", "a_repeated_string", b"a_repeated_string", "a_string", b"a_string", "an_optional_string", b"an_optional_string", "b_oneof", b"b_oneof", "b_oneof_1", b"b_oneof_1", "b_oneof_2", b"b_oneof_2", "bool", b"bool", "email", b"email", "email_by_uid", b"email_by_uid", "inner_enum", b"inner_enum", "inner_enum_in_oneof", b"inner_enum_in_oneof", "map_message", b"map_message", "map_scalar", b"map_scalar", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message", b"outer_message", "outer_message_in_oneof", b"outer_message_in_oneof", "user_id", b"user_id"]) -> None: ... + def HasField(self, field_name: typing.Literal["OuterMessage3", b"OuterMessage3", "_an_optional_string", b"_an_optional_string", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "an_optional_string", b"an_optional_string", "b_oneof", b"b_oneof", "b_oneof_1", b"b_oneof_1", "b_oneof_2", b"b_oneof_2", "bool", b"bool", "inner_enum_in_oneof", b"inner_enum_in_oneof", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message", b"outer_message", "outer_message_in_oneof", b"outer_message_in_oneof"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["OuterEnum", b"OuterEnum", "OuterMessage3", b"OuterMessage3", "_an_optional_string", b"_an_optional_string", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "a_outer_enum", b"a_outer_enum", "a_repeated_string", b"a_repeated_string", "a_string", b"a_string", "an_optional_string", b"an_optional_string", "b_oneof", b"b_oneof", "b_oneof_1", b"b_oneof_1", "b_oneof_2", b"b_oneof_2", "bool", b"bool", "email", b"email", "email_by_uid", b"email_by_uid", "inner_enum", b"inner_enum", "inner_enum_in_oneof", b"inner_enum_in_oneof", "map_message", b"map_message", "map_scalar", b"map_scalar", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message", b"outer_message", "outer_message_in_oneof", b"outer_message_in_oneof", "user_id", b"user_id"]) -> None: ... @typing.overload - def WhichOneof(self, oneof_group: typing_extensions.Literal["_an_optional_string", b"_an_optional_string"]) -> typing_extensions.Literal["an_optional_string"] | None: ... + def WhichOneof(self, oneof_group: typing.Literal["_an_optional_string", b"_an_optional_string"]) -> typing.Literal["an_optional_string"] | None: ... @typing.overload - def WhichOneof(self, oneof_group: typing_extensions.Literal["a_oneof", b"a_oneof"]) -> typing_extensions.Literal["a_oneof_1", "a_oneof_2", "outer_message_in_oneof", "outer_enum_in_oneof", "inner_enum_in_oneof"] | None: ... + def WhichOneof(self, oneof_group: typing.Literal["a_oneof", b"a_oneof"]) -> typing.Literal["a_oneof_1", "a_oneof_2", "outer_message_in_oneof", "outer_enum_in_oneof", "inner_enum_in_oneof"] | None: ... @typing.overload - def WhichOneof(self, oneof_group: typing_extensions.Literal["b_oneof", b"b_oneof"]) -> typing_extensions.Literal["b_oneof_1", "b_oneof_2"] | None: ... + def WhichOneof(self, oneof_group: typing.Literal["b_oneof", b"b_oneof"]) -> typing.Literal["b_oneof_1", "b_oneof_2"] | None: ... global___SimpleProto3 = SimpleProto3 diff --git a/test/generated/testproto/test_extensions2_pb2.pyi b/test/generated/testproto/test_extensions2_pb2.pyi index 806c2a51..39cbcf94 100644 --- a/test/generated/testproto/test_extensions2_pb2.pyi +++ b/test/generated/testproto/test_extensions2_pb2.pyi @@ -2,22 +2,16 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.internal.extension_dict import google.protobuf.message -import sys import testproto.test_pb2 - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class SeparateFileExtension(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -30,7 +24,7 @@ class SeparateFileExtension(google.protobuf.message.Message): *, flag: builtins.bool | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["flag", b"flag"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["flag", b"flag"]) -> None: ... + def HasField(self, field_name: typing.Literal["flag", b"flag"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["flag", b"flag"]) -> None: ... global___SeparateFileExtension = SeparateFileExtension diff --git a/test/generated/testproto/test_extensions3_pb2.pyi b/test/generated/testproto/test_extensions3_pb2.pyi index 83360314..a0a24264 100644 --- a/test/generated/testproto/test_extensions3_pb2.pyi +++ b/test/generated/testproto/test_extensions3_pb2.pyi @@ -2,24 +2,18 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 import google.protobuf.internal.containers import google.protobuf.internal.extension_dict import google.protobuf.message -import sys import testproto.test3_pb2 - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class MessageOptionsTestMsg(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/test/generated/testproto/test_no_generic_services_pb2.pyi b/test/generated/testproto/test_no_generic_services_pb2.pyi index 945e9c8f..9580f868 100644 --- a/test/generated/testproto/test_no_generic_services_pb2.pyi +++ b/test/generated/testproto/test_no_generic_services_pb2.pyi @@ -2,20 +2,14 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ - import builtins import google.protobuf.descriptor import google.protobuf.message -import sys - -if sys.version_info >= (3, 8): - import typing as typing_extensions -else: - import typing_extensions +import typing DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing_extensions.final +@typing.final class Simple3(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -26,7 +20,7 @@ class Simple3(google.protobuf.message.Message): *, a_string: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["a_string", b"a_string"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["a_string", b"a_string"]) -> None: ... + def HasField(self, field_name: typing.Literal["a_string", b"a_string"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["a_string", b"a_string"]) -> None: ... global___Simple3 = Simple3 diff --git a/test/generated/testproto/test_pb2.pyi b/test/generated/testproto/test_pb2.pyi index b618c49b..df33e242 100644 --- a/test/generated/testproto/test_pb2.pyi +++ b/test/generated/testproto/test_pb2.pyi @@ -2,7 +2,6 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file Proto 2 test file.""" - import abc import builtins import collections.abc @@ -69,7 +68,7 @@ DESCRIPTOR = 8; """ global___NamingConflicts = NamingConflicts -@typing_extensions.final +@typing.final class Simple1(google.protobuf.message.Message): """Message with one of everything""" @@ -94,7 +93,7 @@ class Simple1(google.protobuf.message.Message): INNER2: Simple1.InnerEnum.ValueType # 2 """INNER2""" - @typing_extensions.final + @typing.final class InnerMessage(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -102,7 +101,7 @@ class Simple1(google.protobuf.message.Message): self, ) -> None: ... - @typing_extensions.final + @typing.final class EmailByUidEntry(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -116,8 +115,8 @@ class Simple1(google.protobuf.message.Message): key: builtins.int | None = ..., value: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ... + def HasField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["key", b"key", "value", b"value"]) -> None: ... A_STRING_FIELD_NUMBER: builtins.int A_REPEATED_STRING_FIELD_NUMBER: builtins.int @@ -202,13 +201,13 @@ class Simple1(google.protobuf.message.Message): email: test.test_generated_mypy.Email | None = ..., email_by_uid: collections.abc.Mapping[test.test_generated_mypy.UserId, test.test_generated_mypy.Email] | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["a_boolean", b"a_boolean", "a_enum", b"a_enum", "a_external_enum", b"a_external_enum", "a_inner", b"a_inner", "a_nested", b"a_nested", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "a_string", b"a_string", "a_uint32", b"a_uint32", "email", b"email", "inner_enum", b"inner_enum", "inner_enum_in_oneof", b"inner_enum_in_oneof", "inner_message", b"inner_message", "nested_enum", b"nested_enum", "nested_message", b"nested_message", "no_package", b"no_package", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message_in_oneof", b"outer_message_in_oneof", "user_id", b"user_id"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["a_boolean", b"a_boolean", "a_enum", b"a_enum", "a_external_enum", b"a_external_enum", "a_inner", b"a_inner", "a_nested", b"a_nested", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "a_repeated_string", b"a_repeated_string", "a_string", b"a_string", "a_uint32", b"a_uint32", "email", b"email", "email_by_uid", b"email_by_uid", "inner_enum", b"inner_enum", "inner_enum_in_oneof", b"inner_enum_in_oneof", "inner_message", b"inner_message", "nested_enum", b"nested_enum", "nested_message", b"nested_message", "no_package", b"no_package", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message_in_oneof", b"outer_message_in_oneof", "rep_inner_enum", b"rep_inner_enum", "rep_inner_message", b"rep_inner_message", "user_id", b"user_id"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal["a_oneof", b"a_oneof"]) -> typing_extensions.Literal["a_oneof_1", "a_oneof_2", "outer_message_in_oneof", "outer_enum_in_oneof", "inner_enum_in_oneof"] | None: ... + def HasField(self, field_name: typing.Literal["a_boolean", b"a_boolean", "a_enum", b"a_enum", "a_external_enum", b"a_external_enum", "a_inner", b"a_inner", "a_nested", b"a_nested", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "a_string", b"a_string", "a_uint32", b"a_uint32", "email", b"email", "inner_enum", b"inner_enum", "inner_enum_in_oneof", b"inner_enum_in_oneof", "inner_message", b"inner_message", "nested_enum", b"nested_enum", "nested_message", b"nested_message", "no_package", b"no_package", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message_in_oneof", b"outer_message_in_oneof", "user_id", b"user_id"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["a_boolean", b"a_boolean", "a_enum", b"a_enum", "a_external_enum", b"a_external_enum", "a_inner", b"a_inner", "a_nested", b"a_nested", "a_oneof", b"a_oneof", "a_oneof_1", b"a_oneof_1", "a_oneof_2", b"a_oneof_2", "a_repeated_string", b"a_repeated_string", "a_string", b"a_string", "a_uint32", b"a_uint32", "email", b"email", "email_by_uid", b"email_by_uid", "inner_enum", b"inner_enum", "inner_enum_in_oneof", b"inner_enum_in_oneof", "inner_message", b"inner_message", "nested_enum", b"nested_enum", "nested_message", b"nested_message", "no_package", b"no_package", "outer_enum_in_oneof", b"outer_enum_in_oneof", "outer_message_in_oneof", b"outer_message_in_oneof", "rep_inner_enum", b"rep_inner_enum", "rep_inner_message", b"rep_inner_message", "user_id", b"user_id"]) -> None: ... + def WhichOneof(self, oneof_group: typing.Literal["a_oneof", b"a_oneof"]) -> typing.Literal["a_oneof_1", "a_oneof_2", "outer_message_in_oneof", "outer_enum_in_oneof", "inner_enum_in_oneof"] | None: ... global___Simple1 = Simple1 -@typing_extensions.final +@typing.final class Simple2(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -219,12 +218,12 @@ class Simple2(google.protobuf.message.Message): *, a_string: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["a_string", b"a_string"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["a_string", b"a_string"]) -> None: ... + def HasField(self, field_name: typing.Literal["a_string", b"a_string"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["a_string", b"a_string"]) -> None: ... global___Simple2 = Simple2 -@typing_extensions.final +@typing.final class Extensions1(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -238,12 +237,12 @@ class Extensions1(google.protobuf.message.Message): *, ext1_string: builtins.str | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["ext1_string", b"ext1_string"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["ext1_string", b"ext1_string"]) -> None: ... + def HasField(self, field_name: typing.Literal["ext1_string", b"ext1_string"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["ext1_string", b"ext1_string"]) -> None: ... global___Extensions1 = Extensions1 -@typing_extensions.final +@typing.final class Extensions2(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -257,12 +256,12 @@ class Extensions2(google.protobuf.message.Message): *, flag: builtins.bool | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["flag", b"flag"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["flag", b"flag"]) -> None: ... + def HasField(self, field_name: typing.Literal["flag", b"flag"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["flag", b"flag"]) -> None: ... global___Extensions2 = Extensions2 -@typing_extensions.final +@typing.final class _r_None(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -273,12 +272,12 @@ class _r_None(google.protobuf.message.Message): *, valid: builtins.int | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["valid", b"valid"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["valid", b"valid"]) -> None: ... + def HasField(self, field_name: typing.Literal["valid", b"valid"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["valid", b"valid"]) -> None: ... global____r_None = _r_None -@typing_extensions.final +@typing.final class PythonReservedKeywords(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -293,7 +292,7 @@ class PythonReservedKeywords(google.protobuf.message.Message): class _r_finally(_finally, metaclass=_finallyEnumTypeWrapper): ... valid_in_finally: PythonReservedKeywords._r_finally.ValueType # 2 - @typing_extensions.final + @typing.final class _r_lambda(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -305,8 +304,8 @@ class PythonReservedKeywords(google.protobuf.message.Message): *, valid: builtins.int | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["continue", b"continue", "valid", b"valid"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["continue", b"continue", "valid", b"valid"]) -> None: ... + def HasField(self, field_name: typing.Literal["continue", b"continue", "valid", b"valid"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["continue", b"continue", "valid", b"valid"]) -> None: ... FROM_FIELD_NUMBER: builtins.int IN_FIELD_NUMBER: builtins.int @@ -348,12 +347,12 @@ class PythonReservedKeywords(google.protobuf.message.Message): none: global____r_None | None = ..., valid: global___PythonReservedKeywords._r_finally.ValueType | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["False", b"False", "True", b"True", "and", b"and", "as", b"as", "assert", b"assert", "break", b"break", "class", b"class", "def", b"def", "del", b"del", "elif", b"elif", "else", b"else", "except", b"except", "for", b"for", "from", b"from", "global", b"global", "if", b"if", "import", b"import", "in", b"in", "is", b"is", "none", b"none", "nonlocal", b"nonlocal", "not", b"not", "or", b"or", "pass", b"pass", "raise", b"raise", "try", b"try", "valid", b"valid", "while", b"while", "with", b"with", "yield", b"yield"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["False", b"False", "True", b"True", "and", b"and", "as", b"as", "assert", b"assert", "break", b"break", "class", b"class", "def", b"def", "del", b"del", "elif", b"elif", "else", b"else", "except", b"except", "for", b"for", "from", b"from", "global", b"global", "if", b"if", "import", b"import", "in", b"in", "is", b"is", "none", b"none", "nonlocal", b"nonlocal", "not", b"not", "or", b"or", "pass", b"pass", "raise", b"raise", "try", b"try", "valid", b"valid", "while", b"while", "with", b"with", "yield", b"yield"]) -> None: ... + def HasField(self, field_name: typing.Literal["False", b"False", "True", b"True", "and", b"and", "as", b"as", "assert", b"assert", "break", b"break", "class", b"class", "def", b"def", "del", b"del", "elif", b"elif", "else", b"else", "except", b"except", "for", b"for", "from", b"from", "global", b"global", "if", b"if", "import", b"import", "in", b"in", "is", b"is", "none", b"none", "nonlocal", b"nonlocal", "not", b"not", "or", b"or", "pass", b"pass", "raise", b"raise", "try", b"try", "valid", b"valid", "while", b"while", "with", b"with", "yield", b"yield"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["False", b"False", "True", b"True", "and", b"and", "as", b"as", "assert", b"assert", "break", b"break", "class", b"class", "def", b"def", "del", b"del", "elif", b"elif", "else", b"else", "except", b"except", "for", b"for", "from", b"from", "global", b"global", "if", b"if", "import", b"import", "in", b"in", "is", b"is", "none", b"none", "nonlocal", b"nonlocal", "not", b"not", "or", b"or", "pass", b"pass", "raise", b"raise", "try", b"try", "valid", b"valid", "while", b"while", "with", b"with", "yield", b"yield"]) -> None: ... global___PythonReservedKeywords = PythonReservedKeywords -@typing_extensions.final +@typing.final class PythonReservedKeywordsSmall(google.protobuf.message.Message): """Do one with just one arg - to make sure it's syntactically correct""" @@ -363,12 +362,12 @@ class PythonReservedKeywordsSmall(google.protobuf.message.Message): def __init__( self, ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["from", b"from"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["from", b"from"]) -> None: ... + def HasField(self, field_name: typing.Literal["from", b"from"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["from", b"from"]) -> None: ... global___PythonReservedKeywordsSmall = PythonReservedKeywordsSmall -@typing_extensions.final +@typing.final class SelfField(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -380,8 +379,8 @@ class SelfField(google.protobuf.message.Message): *, self: builtins.int | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["self", b"self"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["self", b"self"]) -> None: ... + def HasField(self, field_name: typing.Literal["self", b"self"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["self", b"self"]) -> None: ... global___SelfField = SelfField @@ -397,7 +396,6 @@ class PythonReservedKeywordsService(google.protobuf.service.Service, metaclass=a callback: collections.abc.Callable[[global____r_None], None] | None, ) -> concurrent.futures.Future[global____r_None]: """valid_method_name1""" - @abc.abstractmethod def valid_method_name2( inst: PythonReservedKeywordsService, # pyright: ignore[reportSelfClsParameterName] @@ -419,7 +417,6 @@ class PythonReservedKeywordsService_Stub(PythonReservedKeywordsService): callback: collections.abc.Callable[[global____r_None], None] | None = ..., ) -> concurrent.futures.Future[global____r_None]: """valid_method_name1""" - def valid_method_name2( inst: PythonReservedKeywordsService_Stub, # pyright: ignore[reportSelfClsParameterName] rpc_controller: google.protobuf.service.RpcController, From b50add9ba25c363b9031cde7a10f929b361ace8a Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 1 Apr 2024 11:57:48 -0700 Subject: [PATCH 5/7] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00ff1229..228538c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Upcoming +- Remove 3.7 compatibility for typing_extensions.final/Literal + ## 3.5.0 - Add gRPC aio stub and servicer generation (#489) From fa66571818ce9a37f3baf1c703feeefaf0b69f2b Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 1 Apr 2024 11:58:02 -0700 Subject: [PATCH 6/7] Run black on all the things --- mypy_protobuf/extensions_pb2.pyi | 1 + test/generated/google/protobuf/duration_pb2.pyi | 1 + test/generated/mypy_protobuf/extensions_pb2.pyi | 1 + test/generated/testproto/Capitalized/Capitalized_pb2.pyi | 1 + test/generated/testproto/comment_special_chars_pb2.pyi | 1 + test/generated/testproto/dot/com/test_pb2.pyi | 1 + test/generated/testproto/grpc/dummy_pb2.pyi | 1 + test/generated/testproto/grpc/dummy_pb2_grpc.pyi | 9 ++++++--- test/generated/testproto/grpc/import_pb2.pyi | 1 + test/generated/testproto/grpc/import_pb2_grpc.pyi | 8 +++++--- test/generated/testproto/inner/inner_pb2.pyi | 1 + test/generated/testproto/nested/nested_pb2.pyi | 1 + test/generated/testproto/nopackage_pb2.pyi | 1 + test/generated/testproto/readme_enum_pb2.pyi | 1 + test/generated/testproto/reexport_pb2.pyi | 1 + test/generated/testproto/test3_pb2.pyi | 2 ++ test/generated/testproto/test_extensions2_pb2.pyi | 1 + test/generated/testproto/test_extensions3_pb2.pyi | 1 + .../generated/testproto/test_no_generic_services_pb2.pyi | 1 + test/generated/testproto/test_pb2.pyi | 3 +++ 20 files changed, 32 insertions(+), 6 deletions(-) diff --git a/mypy_protobuf/extensions_pb2.pyi b/mypy_protobuf/extensions_pb2.pyi index e50c8ab2..357508f3 100644 --- a/mypy_protobuf/extensions_pb2.pyi +++ b/mypy_protobuf/extensions_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 diff --git a/test/generated/google/protobuf/duration_pb2.pyi b/test/generated/google/protobuf/duration_pb2.pyi index 22d9b4df..977e08bf 100644 --- a/test/generated/google/protobuf/duration_pb2.pyi +++ b/test/generated/google/protobuf/duration_pb2.pyi @@ -31,6 +31,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.well_known_types diff --git a/test/generated/mypy_protobuf/extensions_pb2.pyi b/test/generated/mypy_protobuf/extensions_pb2.pyi index e50c8ab2..357508f3 100644 --- a/test/generated/mypy_protobuf/extensions_pb2.pyi +++ b/test/generated/mypy_protobuf/extensions_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 diff --git a/test/generated/testproto/Capitalized/Capitalized_pb2.pyi b/test/generated/testproto/Capitalized/Capitalized_pb2.pyi index a27666a6..3deb6a99 100644 --- a/test/generated/testproto/Capitalized/Capitalized_pb2.pyi +++ b/test/generated/testproto/Capitalized/Capitalized_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/comment_special_chars_pb2.pyi b/test/generated/testproto/comment_special_chars_pb2.pyi index e90d0858..276e75b9 100644 --- a/test/generated/testproto/comment_special_chars_pb2.pyi +++ b/test/generated/testproto/comment_special_chars_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/dot/com/test_pb2.pyi b/test/generated/testproto/dot/com/test_pb2.pyi index 34ecc15d..b6af6e07 100644 --- a/test/generated/testproto/dot/com/test_pb2.pyi +++ b/test/generated/testproto/dot/com/test_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/grpc/dummy_pb2.pyi b/test/generated/testproto/grpc/dummy_pb2.pyi index 03eb43e8..3260440b 100644 --- a/test/generated/testproto/grpc/dummy_pb2.pyi +++ b/test/generated/testproto/grpc/dummy_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file https://github.com/vmagamedov/grpclib/blob/master/tests/dummy.proto""" + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi index 1ae2b9ea..9745eed3 100644 --- a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file https://github.com/vmagamedov/grpclib/blob/master/tests/dummy.proto""" + import abc import collections.abc import grpc @@ -9,10 +10,9 @@ import grpc.aio import testproto.grpc.dummy_pb2 import typing -_T = typing.TypeVar('_T') +_T = typing.TypeVar("_T") -class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): - ... +class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] ... @@ -76,6 +76,7 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.grpc.dummy_pb2.DummyReply, collections.abc.Awaitable[testproto.grpc.dummy_pb2.DummyReply]]: """UnaryUnary""" + @abc.abstractmethod def UnaryStream( self, @@ -83,6 +84,7 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[collections.abc.Iterator[testproto.grpc.dummy_pb2.DummyReply], collections.abc.AsyncIterator[testproto.grpc.dummy_pb2.DummyReply]]: """UnaryStream""" + @abc.abstractmethod def StreamUnary( self, @@ -90,6 +92,7 @@ class DummyServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.grpc.dummy_pb2.DummyReply, collections.abc.Awaitable[testproto.grpc.dummy_pb2.DummyReply]]: """StreamUnary""" + @abc.abstractmethod def StreamStream( self, diff --git a/test/generated/testproto/grpc/import_pb2.pyi b/test/generated/testproto/grpc/import_pb2.pyi index e08fa11c..dd854e28 100644 --- a/test/generated/testproto/grpc/import_pb2.pyi +++ b/test/generated/testproto/grpc/import_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import google.protobuf.descriptor DESCRIPTOR: google.protobuf.descriptor.FileDescriptor diff --git a/test/generated/testproto/grpc/import_pb2_grpc.pyi b/test/generated/testproto/grpc/import_pb2_grpc.pyi index aade3c5b..4ac598ea 100644 --- a/test/generated/testproto/grpc/import_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/import_pb2_grpc.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import abc import collections.abc import google.protobuf.empty_pb2 @@ -10,10 +11,9 @@ import grpc.aio import testproto.test_pb2 import typing -_T = typing.TypeVar('_T') +_T = typing.TypeVar("_T") -class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): - ... +class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] ... @@ -65,6 +65,7 @@ class SimpleServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[testproto.test_pb2.Simple1, collections.abc.Awaitable[testproto.test_pb2.Simple1]]: """UnaryUnary""" + @abc.abstractmethod def UnaryStream( self, @@ -72,6 +73,7 @@ class SimpleServiceServicer(metaclass=abc.ABCMeta): context: _ServicerContext, ) -> typing.Union[google.protobuf.empty_pb2.Empty, collections.abc.Awaitable[google.protobuf.empty_pb2.Empty]]: """UnaryStream""" + @abc.abstractmethod def NoComment( self, diff --git a/test/generated/testproto/inner/inner_pb2.pyi b/test/generated/testproto/inner/inner_pb2.pyi index 0e51e054..171725ef 100644 --- a/test/generated/testproto/inner/inner_pb2.pyi +++ b/test/generated/testproto/inner/inner_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/nested/nested_pb2.pyi b/test/generated/testproto/nested/nested_pb2.pyi index 140fd614..8f808e1f 100644 --- a/test/generated/testproto/nested/nested_pb2.pyi +++ b/test/generated/testproto/nested/nested_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper diff --git a/test/generated/testproto/nopackage_pb2.pyi b/test/generated/testproto/nopackage_pb2.pyi index e9620c3b..1103645c 100644 --- a/test/generated/testproto/nopackage_pb2.pyi +++ b/test/generated/testproto/nopackage_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import collections.abc import google.protobuf.descriptor diff --git a/test/generated/testproto/readme_enum_pb2.pyi b/test/generated/testproto/readme_enum_pb2.pyi index 2299c49d..8b287b5c 100644 --- a/test/generated/testproto/readme_enum_pb2.pyi +++ b/test/generated/testproto/readme_enum_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.enum_type_wrapper diff --git a/test/generated/testproto/reexport_pb2.pyi b/test/generated/testproto/reexport_pb2.pyi index 1ae98bf4..9702c2bd 100644 --- a/test/generated/testproto/reexport_pb2.pyi +++ b/test/generated/testproto/reexport_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import google.protobuf.descriptor from google.protobuf.empty_pb2 import ( Empty as Empty, diff --git a/test/generated/testproto/test3_pb2.pyi b/test/generated/testproto/test3_pb2.pyi index 494bc26c..6da40ead 100644 --- a/test/generated/testproto/test3_pb2.pyi +++ b/test/generated/testproto/test3_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file package test3""" + import builtins import collections.abc import google.protobuf.descriptor @@ -163,6 +164,7 @@ class SimpleProto3(google.protobuf.message.Message): @property def map_scalar(self) -> google.protobuf.internal.containers.ScalarMap[builtins.int, builtins.str]: """Test generation of map""" + @property def map_message(self) -> google.protobuf.internal.containers.MessageMap[builtins.int, global___OuterMessage3]: ... an_optional_string: builtins.str diff --git a/test/generated/testproto/test_extensions2_pb2.pyi b/test/generated/testproto/test_extensions2_pb2.pyi index 39cbcf94..e115b492 100644 --- a/test/generated/testproto/test_extensions2_pb2.pyi +++ b/test/generated/testproto/test_extensions2_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.internal.extension_dict diff --git a/test/generated/testproto/test_extensions3_pb2.pyi b/test/generated/testproto/test_extensions3_pb2.pyi index a0a24264..3ea57373 100644 --- a/test/generated/testproto/test_extensions3_pb2.pyi +++ b/test/generated/testproto/test_extensions3_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.descriptor_pb2 diff --git a/test/generated/testproto/test_no_generic_services_pb2.pyi b/test/generated/testproto/test_no_generic_services_pb2.pyi index 9580f868..1e051777 100644 --- a/test/generated/testproto/test_no_generic_services_pb2.pyi +++ b/test/generated/testproto/test_no_generic_services_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ + import builtins import google.protobuf.descriptor import google.protobuf.message diff --git a/test/generated/testproto/test_pb2.pyi b/test/generated/testproto/test_pb2.pyi index df33e242..e385adac 100644 --- a/test/generated/testproto/test_pb2.pyi +++ b/test/generated/testproto/test_pb2.pyi @@ -2,6 +2,7 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file Proto 2 test file.""" + import abc import builtins import collections.abc @@ -396,6 +397,7 @@ class PythonReservedKeywordsService(google.protobuf.service.Service, metaclass=a callback: collections.abc.Callable[[global____r_None], None] | None, ) -> concurrent.futures.Future[global____r_None]: """valid_method_name1""" + @abc.abstractmethod def valid_method_name2( inst: PythonReservedKeywordsService, # pyright: ignore[reportSelfClsParameterName] @@ -417,6 +419,7 @@ class PythonReservedKeywordsService_Stub(PythonReservedKeywordsService): callback: collections.abc.Callable[[global____r_None], None] | None = ..., ) -> concurrent.futures.Future[global____r_None]: """valid_method_name1""" + def valid_method_name2( inst: PythonReservedKeywordsService_Stub, # pyright: ignore[reportSelfClsParameterName] rpc_controller: google.protobuf.service.RpcController, From b68e542112e0a3ab93077b12911f8db94190e9c4 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 1 Apr 2024 12:02:04 -0700 Subject: [PATCH 7/7] Update output formatting --- mypy_protobuf/main.py | 26 ++++++++++--------- .../testproto/grpc/dummy_pb2_grpc.pyi | 6 +++++ .../testproto/grpc/import_pb2_grpc.pyi | 4 +++ test/generated/testproto/test3_pb2.pyi | 22 ++++++++-------- test/generated/testproto/test_pb2.pyi | 23 ++++++++-------- 5 files changed, 47 insertions(+), 34 deletions(-) diff --git a/mypy_protobuf/main.py b/mypy_protobuf/main.py index 388da249..76913f1c 100644 --- a/mypy_protobuf/main.py +++ b/mypy_protobuf/main.py @@ -436,12 +436,16 @@ def write_messages( if field.name in PYTHON_RESERVED: continue field_type = self.python_type(field) - if is_scalar(field) and field.label != d.FieldDescriptorProto.LABEL_REPEATED: # Scalar non repeated fields are r/w wl(f"{field.name}: {field_type}") self._write_comments(scl + [d.DescriptorProto.FIELD_FIELD_NUMBER, idx]) - else: + + for idx, field in enumerate(desc.field): + if field.name in PYTHON_RESERVED: + continue + field_type = self.python_type(field) + if not (is_scalar(field) and field.label != d.FieldDescriptorProto.LABEL_REPEATED): # r/o Getters for non-scalar fields and scalar-repeated fields scl_field = scl + [d.DescriptorProto.FIELD_FIELD_NUMBER, idx] wl("@property") @@ -450,6 +454,7 @@ def write_messages( if self._has_comments(scl_field): with self._indent(): self._write_comments(scl_field) + wl("") self.write_extensions(desc.extension, scl + [d.DescriptorProto.EXTENSION_FIELD_NUMBER]) @@ -597,6 +602,7 @@ def write_methods( with self._indent(): if not self._write_comments(scl_method): wl("...") + wl("") def write_services( self, @@ -618,7 +624,6 @@ def write_services( if self._write_comments(scl): wl("") self.write_methods(service, class_name, is_abstract=True, scl_prefix=scl) - wl("") # The stub client stub_class_name = service.name + "_Stub" @@ -631,7 +636,6 @@ def write_services( self._import("google.protobuf.service", "RpcChannel"), ) self.write_methods(service, stub_class_name, is_abstract=False, scl_prefix=scl) - wl("") def _import_casttype(self, casttype: str) -> str: split = casttype.split(".") @@ -707,16 +711,14 @@ def write_grpc_async_hacks(self) -> None: wl = self._write_line # _MaybeAsyncIterator[Req] is supertyped by Iterator[Req] and AsyncIterator[Req]. # So both can be used in the contravariant function parameter position. - wl("_T = {}('_T')", self._import("typing", "TypeVar")) + wl('_T = {}("_T")', self._import("typing", "TypeVar")) wl("") wl( - "class _MaybeAsyncIterator({}[_T], {}[_T], metaclass={}):", + "class _MaybeAsyncIterator({}[_T], {}[_T], metaclass={}): ...", self._import("collections.abc", "AsyncIterator"), self._import("collections.abc", "Iterator"), self._import("abc", "ABCMeta"), ) - with self._indent(): - wl("...") wl("") # _ServicerContext is supertyped by grpc.ServicerContext and grpc.aio.ServicerContext @@ -756,6 +758,7 @@ def write_grpc_methods(self, service: d.ServiceDescriptorProto, scl_prefix: Sour with self._indent(): if not self._write_comments(scl): wl("...") + wl("") def write_grpc_stub_methods(self, service: d.ServiceDescriptorProto, scl_prefix: SourceCodeLocation, is_async: bool = False) -> None: wl = self._write_line @@ -772,6 +775,7 @@ def write_grpc_stub_methods(self, service: d.ServiceDescriptorProto, scl_prefix: wl("{},", self._output_type(method)) wl("]") self._write_comments(scl) + wl("") def write_grpc_services( self, @@ -797,7 +801,6 @@ def write_grpc_services( channel = f"{self._import('typing', 'Union')}[{self._import('grpc', 'Channel')}, {self._import('grpc.aio', 'Channel')}]" wl("def __init__(self, channel: {}) -> None: ...", channel) self.write_grpc_stub_methods(service, scl) - wl("") # The (fake) async stub client wl( @@ -809,7 +812,6 @@ def write_grpc_services( wl("") # No __init__ since this isn't a real class (yet), and requires manual casting to work. self.write_grpc_stub_methods(service, scl, is_async=True) - wl("") # The service definition interface wl( @@ -821,7 +823,6 @@ def write_grpc_services( if self._write_comments(scl): wl("") self.write_grpc_methods(service, scl) - wl("") server = self._import("grpc", "Server") aserver = self._import("grpc.aio", "Server") wl( @@ -923,8 +924,9 @@ def write(self) -> str: if self.lines: assert self.lines[0].startswith('"""') self.lines[0] = f'"""{HEADER}{self.lines[0][3:]}' + self._write_line("") else: - self._write_line(f'"""{HEADER}"""') + self._write_line(f'"""{HEADER}"""\n') for reexport_idx in self.fd.public_dependency: reexport_file = self.fd.dependency[reexport_idx] diff --git a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi index 9745eed3..46bbf2c0 100644 --- a/test/generated/testproto/grpc/dummy_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/dummy_pb2_grpc.pyi @@ -26,16 +26,19 @@ class DummyServiceStub: testproto.grpc.dummy_pb2.DummyReply, ] """UnaryUnary""" + UnaryStream: grpc.UnaryStreamMultiCallable[ testproto.grpc.dummy_pb2.DummyRequest, testproto.grpc.dummy_pb2.DummyReply, ] """UnaryStream""" + StreamUnary: grpc.StreamUnaryMultiCallable[ testproto.grpc.dummy_pb2.DummyRequest, testproto.grpc.dummy_pb2.DummyReply, ] """StreamUnary""" + StreamStream: grpc.StreamStreamMultiCallable[ testproto.grpc.dummy_pb2.DummyRequest, testproto.grpc.dummy_pb2.DummyReply, @@ -50,16 +53,19 @@ class DummyServiceAsyncStub: testproto.grpc.dummy_pb2.DummyReply, ] """UnaryUnary""" + UnaryStream: grpc.aio.UnaryStreamMultiCallable[ testproto.grpc.dummy_pb2.DummyRequest, testproto.grpc.dummy_pb2.DummyReply, ] """UnaryStream""" + StreamUnary: grpc.aio.StreamUnaryMultiCallable[ testproto.grpc.dummy_pb2.DummyRequest, testproto.grpc.dummy_pb2.DummyReply, ] """StreamUnary""" + StreamStream: grpc.aio.StreamStreamMultiCallable[ testproto.grpc.dummy_pb2.DummyRequest, testproto.grpc.dummy_pb2.DummyReply, diff --git a/test/generated/testproto/grpc/import_pb2_grpc.pyi b/test/generated/testproto/grpc/import_pb2_grpc.pyi index 4ac598ea..0beb25be 100644 --- a/test/generated/testproto/grpc/import_pb2_grpc.pyi +++ b/test/generated/testproto/grpc/import_pb2_grpc.pyi @@ -27,11 +27,13 @@ class SimpleServiceStub: testproto.test_pb2.Simple1, ] """UnaryUnary""" + UnaryStream: grpc.UnaryUnaryMultiCallable[ testproto.test_pb2.Simple1, google.protobuf.empty_pb2.Empty, ] """UnaryStream""" + NoComment: grpc.UnaryUnaryMultiCallable[ testproto.test_pb2.Simple1, google.protobuf.empty_pb2.Empty, @@ -45,11 +47,13 @@ class SimpleServiceAsyncStub: testproto.test_pb2.Simple1, ] """UnaryUnary""" + UnaryStream: grpc.aio.UnaryUnaryMultiCallable[ testproto.test_pb2.Simple1, google.protobuf.empty_pb2.Empty, ] """UnaryStream""" + NoComment: grpc.aio.UnaryUnaryMultiCallable[ testproto.test_pb2.Simple1, google.protobuf.empty_pb2.Empty, diff --git a/test/generated/testproto/test3_pb2.pyi b/test/generated/testproto/test3_pb2.pyi index 6da40ead..d403e3af 100644 --- a/test/generated/testproto/test3_pb2.pyi +++ b/test/generated/testproto/test3_pb2.pyi @@ -141,24 +141,27 @@ class SimpleProto3(google.protobuf.message.Message): EMAIL_FIELD_NUMBER: builtins.int EMAIL_BY_UID_FIELD_NUMBER: builtins.int a_string: builtins.str - @property - def a_repeated_string(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... a_outer_enum: global___OuterEnum.ValueType - @property - def outer_message(self) -> global___OuterMessage3: ... inner_enum: global___SimpleProto3.InnerEnum.ValueType a_oneof_1: builtins.str a_oneof_2: builtins.str - @property - def outer_message_in_oneof(self) -> global___OuterMessage3: ... outer_enum_in_oneof: global___OuterEnum.ValueType inner_enum_in_oneof: global___SimpleProto3.InnerEnum.ValueType b_oneof_1: builtins.str b_oneof_2: builtins.str - @property - def bool(self) -> global___OuterMessage3: ... OuterEnum: global___OuterEnum.ValueType """Test having fieldname match messagename""" + an_optional_string: builtins.str + user_id: test.test_generated_mypy.UserId + email: test.test_generated_mypy.Email + @property + def a_repeated_string(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... + @property + def outer_message(self) -> global___OuterMessage3: ... + @property + def outer_message_in_oneof(self) -> global___OuterMessage3: ... + @property + def bool(self) -> global___OuterMessage3: ... @property def OuterMessage3(self) -> global___OuterMessage3: ... @property @@ -167,9 +170,6 @@ class SimpleProto3(google.protobuf.message.Message): @property def map_message(self) -> google.protobuf.internal.containers.MessageMap[builtins.int, global___OuterMessage3]: ... - an_optional_string: builtins.str - user_id: test.test_generated_mypy.UserId - email: test.test_generated_mypy.Email @property def email_by_uid(self) -> google.protobuf.internal.containers.ScalarMap[test.test_generated_mypy.UserId, test.test_generated_mypy.Email]: ... def __init__( diff --git a/test/generated/testproto/test_pb2.pyi b/test/generated/testproto/test_pb2.pyi index e385adac..e0aae725 100644 --- a/test/generated/testproto/test_pb2.pyi +++ b/test/generated/testproto/test_pb2.pyi @@ -143,17 +143,24 @@ class Simple1(google.protobuf.message.Message): EMAIL_FIELD_NUMBER: builtins.int EMAIL_BY_UID_FIELD_NUMBER: builtins.int a_string: builtins.str - @property - def a_repeated_string(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... a_boolean: builtins.bool a_uint32: builtins.int a_enum: global___OuterEnum.ValueType a_external_enum: testproto.test3_pb2.OuterEnum.ValueType + inner_enum: global___Simple1.InnerEnum.ValueType + nested_enum: testproto.nested.nested_pb2.AnotherNested.NestedEnum.ValueType + a_oneof_1: builtins.str + a_oneof_2: builtins.str + outer_enum_in_oneof: global___OuterEnum.ValueType + inner_enum_in_oneof: global___Simple1.InnerEnum.ValueType + user_id: test.test_generated_mypy.UserId + email: test.test_generated_mypy.Email + @property + def a_repeated_string(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... @property def a_inner(self) -> testproto.inner.inner_pb2.Inner: ... @property def a_nested(self) -> testproto.nested.nested_pb2.Nested: ... - inner_enum: global___Simple1.InnerEnum.ValueType @property def rep_inner_enum(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[global___Simple1.InnerEnum.ValueType]: ... @property @@ -162,17 +169,10 @@ class Simple1(google.protobuf.message.Message): def rep_inner_message(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Simple1.InnerMessage]: ... @property def no_package(self) -> testproto.nopackage_pb2.NoPackage: ... - nested_enum: testproto.nested.nested_pb2.AnotherNested.NestedEnum.ValueType @property def nested_message(self) -> testproto.nested.nested_pb2.AnotherNested.NestedMessage: ... - a_oneof_1: builtins.str - a_oneof_2: builtins.str @property def outer_message_in_oneof(self) -> global___Simple2: ... - outer_enum_in_oneof: global___OuterEnum.ValueType - inner_enum_in_oneof: global___Simple1.InnerEnum.ValueType - user_id: test.test_generated_mypy.UserId - email: test.test_generated_mypy.Email @property def email_by_uid(self) -> google.protobuf.internal.containers.ScalarMap[test.test_generated_mypy.UserId, test.test_generated_mypy.Email]: ... def __init__( @@ -338,10 +338,11 @@ class PythonReservedKeywords(google.protobuf.message.Message): CLASS_FIELD_NUMBER: builtins.int NONE_FIELD_NUMBER: builtins.int VALID_FIELD_NUMBER: builtins.int + valid: global___PythonReservedKeywords._r_finally.ValueType @property def none(self) -> global____r_None: """Test unreserved identifiers w/ reserved message names""" - valid: global___PythonReservedKeywords._r_finally.ValueType + def __init__( self, *,