betterproto2-compiler 0.6.0__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/.gitignore +1 -1
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/PKG-INFO +2 -2
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/pyproject.toml +16 -2
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/compile/importing.py +62 -30
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/lib/google/protobuf/__init__.py +1 -1
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/lib/google/protobuf/compiler/__init__.py +1 -1
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/models.py +54 -2
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/parser.py +23 -8
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/settings.py +1 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/templates/header.py.j2 +9 -1
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/templates/template.py.j2 +24 -1
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/generate.py +26 -1
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/deprecated/deprecated.proto +3 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/example_service/example_service.proto +4 -0
- betterproto2_compiler-0.7.0/tests/inputs/grpc_reflection_v1/reflection.proto +146 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/util.py +17 -7
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/uv.lock +89 -94
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/pytest.ini +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/__init__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/casing.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/compile/__init__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/compile/naming.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/known_types/__init__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/known_types/any.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/known_types/duration.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/known_types/google_values.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/known_types/timestamp.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/lib/__init__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/lib/google/__init__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/lib/message_pool.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/__init__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/__main__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/compiler.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/main.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/module_validation.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/plugin/plugin.bat +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/py.typed +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/templates/service_stub.py.j2 +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/templates/service_stub_async.py.j2 +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/src/betterproto2_compiler/templates/service_stub_sync.py.j2 +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/__init__.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/any/any.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/bool/bool.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/bytes/bytes.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/casing/casing.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/casing_inner_class/casing_inner_class.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/casing_message_field_uppercase/casing_message_field_uppercase.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/documentation/documentation.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/double/double.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/empty_repeated/empty_repeated.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/empty_service/empty_service.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/encoding_decoding/encoding_decoding.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/entry/entry.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/enum/enum.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/example/example.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/features/features.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/field_name_identical_to_type/field_name_identical_to_type.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/fixed/fixed.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/float/float.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/google_impl_behavior_equivalence/google_impl_behavior_equivalence.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes/googletypes.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes_request/googletypes_request.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes_response/googletypes_response.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes_response_embedded/googletypes_response_embedded.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes_service_returns_empty/googletypes_service_returns_empty.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes_service_returns_googletype/googletypes_service_returns_googletype.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes_struct/googletypes_struct.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/googletypes_value/googletypes_value.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_capitalized_package/capitalized.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_capitalized_package/test.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_package_from_package/child.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_package_from_package/import_child_package_from_package.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_package_from_package/package_message.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_package_from_root/child.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_package_from_root/import_child_package_from_root.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_scoping_rules/child.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_scoping_rules/import_child_scoping_rules.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_child_scoping_rules/package.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_circular_dependency/import_circular_dependency.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_circular_dependency/other.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_circular_dependency/root.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_cousin_package/cousin.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_cousin_package/test.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_cousin_package_same_name/cousin.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_cousin_package_same_name/test.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_nested_child_package_from_root/child.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_nested_child_package_from_root/import_nested_child_package_from_root.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_packages_same_name/import_packages_same_name.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_packages_same_name/posts_v1.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_packages_same_name/users_v1.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_parent_package_from_child/import_parent_package_from_child.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_parent_package_from_child/parent_package_message.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_root_package_from_child/child.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_root_package_from_child/root.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_root_sibling/import_root_sibling.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_root_sibling/sibling.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_service_input_message/child_package_request_message.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_service_input_message/import_service_input_message.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/import_service_input_message/request_message.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/int32/int32.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/invalid_field/invalid_field.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/manual_validation/manual_validation.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/map/map.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/mapmessage/mapmessage.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/message_wrapping/message_wrapping.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/namespace_builtin_types/namespace_builtin_types.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/namespace_keywords/namespace_keywords.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/nested/nested.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/nested2/nested2.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/nested2/package.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/nestedtwice/nestedtwice.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/oneof/oneof.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/oneof_default_value_serialization/oneof_default_value_serialization.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/oneof_empty/oneof_empty.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/oneof_enum/oneof_enum.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/pickling/pickling.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/proto3_field_presence/proto3_field_presence.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/proto3_field_presence_oneof/proto3_field_presence_oneof.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/recursivemessage/recursivemessage.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/ref/ref.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/ref/repeatedmessage.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/regression_387/regression_387.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/regression_414/regression_414.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/repeated/repeated.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/repeated_duration_timestamp/repeated_duration_timestamp.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/repeatedmessage/repeatedmessage.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/repeatedpacked/repeatedpacked.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/rpc_empty_input_message/rpc_empty_input_message.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/service/service.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/service_separate_packages/messages.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/service_separate_packages/service.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/service_uppercase/service.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/signed/signed.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/simple_service/simple_service.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/stream_stream/stream_stream.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/timestamp_dict_encode/timestamp_dict_encode.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/unwrap/unwrap.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/inputs/validation/validation.proto +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/test_casing.py +0 -0
- {betterproto2_compiler-0.6.0 → betterproto2_compiler-0.7.0}/tests/test_module_validation.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: betterproto2_compiler
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.0
|
4
4
|
Summary: Compiler for betterproto2
|
5
5
|
Project-URL: Documentation, https://betterproto.github.io/python-betterproto2/
|
6
6
|
Project-URL: Repository, https://github.com/betterproto/python-betterproto2
|
@@ -8,7 +8,7 @@ Author-email: Adrien Vannson <adrien.vannson@protonmail.com>, "Daniel G. Taylor"
|
|
8
8
|
License-Expression: MIT
|
9
9
|
Keywords: compiler,gRPC,protobuf
|
10
10
|
Requires-Python: <4.0,>=3.10
|
11
|
-
Requires-Dist: betterproto2[grpclib]<0.
|
11
|
+
Requires-Dist: betterproto2[grpclib]<0.8,>=0.7.0
|
12
12
|
Requires-Dist: jinja2>=3.0.3
|
13
13
|
Requires-Dist: ruff~=0.9.3
|
14
14
|
Requires-Dist: strenum<0.5,>=0.4.15; python_version == '3.10'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "betterproto2_compiler"
|
3
|
-
version = "0.
|
3
|
+
version = "0.7.0"
|
4
4
|
description = "Compiler for betterproto2"
|
5
5
|
authors = [
|
6
6
|
{ name = "Adrien Vannson", email = "adrien.vannson@protonmail.com" },
|
@@ -15,7 +15,7 @@ keywords = [
|
|
15
15
|
requires-python = ">=3.10,<4.0"
|
16
16
|
dependencies = [
|
17
17
|
# TODO use the version from the current repo?
|
18
|
-
"betterproto2[grpclib]>=0.
|
18
|
+
"betterproto2[grpclib]>=0.7.0,<0.8",
|
19
19
|
"ruff~=0.9.3",
|
20
20
|
"jinja2>=3.0.3",
|
21
21
|
"typing-extensions>=4.7.1,<5",
|
@@ -122,6 +122,20 @@ python -m grpc.tools.protoc \
|
|
122
122
|
google/protobuf/timestamp.proto \
|
123
123
|
google/protobuf/type.proto \
|
124
124
|
google/protobuf/wrappers.proto
|
125
|
+
|
126
|
+
python -m grpc.tools.protoc \
|
127
|
+
--python_betterproto2_out=tests/output_betterproto_descriptor \
|
128
|
+
--python_betterproto2_opt=google_protobuf_descriptors \
|
129
|
+
google/protobuf/any.proto \
|
130
|
+
google/protobuf/api.proto \
|
131
|
+
google/protobuf/duration.proto \
|
132
|
+
google/protobuf/empty.proto \
|
133
|
+
google/protobuf/field_mask.proto \
|
134
|
+
google/protobuf/source_context.proto \
|
135
|
+
google/protobuf/struct.proto \
|
136
|
+
google/protobuf/timestamp.proto \
|
137
|
+
google/protobuf/type.proto \
|
138
|
+
google/protobuf/wrappers.proto
|
125
139
|
"""
|
126
140
|
|
127
141
|
[tool.poe.tasks.typecheck]
|
@@ -55,6 +55,32 @@ def parse_source_type_name(field_type_name: str, request: PluginRequestCompiler)
|
|
55
55
|
raise ValueError(f"can't find type name: {field_type_name}")
|
56
56
|
|
57
57
|
|
58
|
+
def get_symbol_reference(
|
59
|
+
*,
|
60
|
+
package: str,
|
61
|
+
imports: set,
|
62
|
+
source_package: str,
|
63
|
+
symbol: str,
|
64
|
+
) -> tuple[str, str | None]:
|
65
|
+
"""
|
66
|
+
Return a Python symbol within a proto package. Adds the import if
|
67
|
+
necessary and returns it as well for usage. Unwraps well known type if required.
|
68
|
+
"""
|
69
|
+
current_package: list[str] = package.split(".") if package else []
|
70
|
+
py_package: list[str] = source_package.split(".") if source_package else []
|
71
|
+
|
72
|
+
if py_package == current_package:
|
73
|
+
return (reference_sibling(symbol), None)
|
74
|
+
|
75
|
+
if py_package[: len(current_package)] == current_package:
|
76
|
+
return reference_descendent(current_package, imports, py_package, symbol)
|
77
|
+
|
78
|
+
if current_package[: len(py_package)] == py_package:
|
79
|
+
return reference_ancestor(current_package, imports, py_package, symbol)
|
80
|
+
|
81
|
+
return reference_cousin(current_package, imports, py_package, symbol)
|
82
|
+
|
83
|
+
|
58
84
|
def get_type_reference(
|
59
85
|
*,
|
60
86
|
package: str,
|
@@ -73,30 +99,25 @@ def get_type_reference(
|
|
73
99
|
if wrap and (source_package, source_type) in WRAPPED_TYPES:
|
74
100
|
return WRAPPED_TYPES[(source_package, source_type)]
|
75
101
|
|
76
|
-
current_package: list[str] = package.split(".") if package else []
|
77
|
-
py_package: list[str] = source_package.split(".") if source_package else []
|
78
102
|
py_type: str = pythonize_class_name(source_type)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if current_package[: len(py_package)] == py_package:
|
87
|
-
return reference_ancestor(current_package, imports, py_package, py_type)
|
88
|
-
|
89
|
-
return reference_cousin(current_package, imports, py_package, py_type)
|
103
|
+
(ref, _) = get_symbol_reference(
|
104
|
+
package=package,
|
105
|
+
imports=imports,
|
106
|
+
source_package=source_package,
|
107
|
+
symbol=py_type,
|
108
|
+
)
|
109
|
+
return ref
|
90
110
|
|
91
111
|
|
92
|
-
def reference_absolute(imports: set[str], py_package: list[str], py_type: str) -> str:
|
112
|
+
def reference_absolute(imports: set[str], py_package: list[str], py_type: str) -> tuple[str, str]:
|
93
113
|
"""
|
94
114
|
Returns a reference to a python type located in the root, i.e. sys.path.
|
95
115
|
"""
|
96
116
|
string_import = ".".join(py_package)
|
97
117
|
string_alias = "__".join([safe_snake_case(name) for name in py_package])
|
98
|
-
|
99
|
-
|
118
|
+
import_to_add = f"import {string_import} as {string_alias}"
|
119
|
+
imports.add(import_to_add)
|
120
|
+
return (f"{string_alias}.{py_type}", import_to_add)
|
100
121
|
|
101
122
|
|
102
123
|
def reference_sibling(py_type: str) -> str:
|
@@ -106,7 +127,9 @@ def reference_sibling(py_type: str) -> str:
|
|
106
127
|
return f"{py_type}"
|
107
128
|
|
108
129
|
|
109
|
-
def reference_descendent(
|
130
|
+
def reference_descendent(
|
131
|
+
current_package: list[str], imports: set[str], py_package: list[str], py_type: str
|
132
|
+
) -> tuple[str, str]:
|
110
133
|
"""
|
111
134
|
Returns a reference to a python type in a package that is a descendent of the
|
112
135
|
current package, and adds the required import that is aliased to avoid name
|
@@ -116,15 +139,19 @@ def reference_descendent(current_package: list[str], imports: set[str], py_packa
|
|
116
139
|
string_from = ".".join(importing_descendent[:-1])
|
117
140
|
string_import = importing_descendent[-1]
|
118
141
|
if string_from:
|
119
|
-
string_alias = "_
|
120
|
-
|
121
|
-
|
142
|
+
string_alias = f"{'_'.join(importing_descendent)}"
|
143
|
+
import_to_add = f"from .{string_from} import {string_import} as {string_alias}"
|
144
|
+
imports.add(import_to_add)
|
145
|
+
return (f"{string_alias}.{py_type}", import_to_add)
|
122
146
|
else:
|
123
|
-
|
124
|
-
|
147
|
+
import_to_add = f"from . import {string_import}"
|
148
|
+
imports.add(import_to_add)
|
149
|
+
return (f"{string_import}.{py_type}", import_to_add)
|
125
150
|
|
126
151
|
|
127
|
-
def reference_ancestor(
|
152
|
+
def reference_ancestor(
|
153
|
+
current_package: list[str], imports: set[str], py_package: list[str], py_type: str
|
154
|
+
) -> tuple[str, str]:
|
128
155
|
"""
|
129
156
|
Returns a reference to a python type in a package which is an ancestor to the
|
130
157
|
current package, and adds the required import that is aliased (if possible) to avoid
|
@@ -137,15 +164,19 @@ def reference_ancestor(current_package: list[str], imports: set[str], py_package
|
|
137
164
|
string_import = py_package[-1]
|
138
165
|
string_alias = f"_{'_' * distance_up}{string_import}__"
|
139
166
|
string_from = f"..{'.' * distance_up}"
|
140
|
-
|
141
|
-
|
167
|
+
import_to_add = f"from {string_from} import {string_import} as {string_alias}"
|
168
|
+
imports.add(import_to_add)
|
169
|
+
return (f"{string_alias}.{py_type}", import_to_add)
|
142
170
|
else:
|
143
171
|
string_alias = f"{'_' * distance_up}{py_type}__"
|
144
|
-
|
145
|
-
|
172
|
+
import_to_add = f"from .{'.' * distance_up} import {py_type} as {string_alias}"
|
173
|
+
imports.add(import_to_add)
|
174
|
+
return (string_alias, import_to_add)
|
146
175
|
|
147
176
|
|
148
|
-
def reference_cousin(
|
177
|
+
def reference_cousin(
|
178
|
+
current_package: list[str], imports: set[str], py_package: list[str], py_type: str
|
179
|
+
) -> tuple[str, str]:
|
149
180
|
"""
|
150
181
|
Returns a reference to a python type in a package that is not descendent, ancestor
|
151
182
|
or sibling, and adds the required import that is aliased to avoid name conflicts.
|
@@ -161,5 +192,6 @@ def reference_cousin(current_package: list[str], imports: set[str], py_package:
|
|
161
192
|
+ "__".join([safe_snake_case(name) for name in py_package[len(shared_ancestry) :]])
|
162
193
|
+ "__"
|
163
194
|
)
|
164
|
-
|
165
|
-
|
195
|
+
import_to_add = f"from {string_from} import {string_import} as {string_alias}"
|
196
|
+
imports.add(import_to_add)
|
197
|
+
return (f"{string_alias}.{py_type}", import_to_add)
|
@@ -53,6 +53,7 @@ from betterproto2_compiler.lib.google.protobuf import (
|
|
53
53
|
MethodDescriptorProto,
|
54
54
|
OneofDescriptorProto,
|
55
55
|
ServiceDescriptorProto,
|
56
|
+
SourceCodeInfo,
|
56
57
|
)
|
57
58
|
from betterproto2_compiler.lib.google.protobuf.compiler import CodeGeneratorRequest
|
58
59
|
from betterproto2_compiler.settings import Settings
|
@@ -216,6 +217,33 @@ class OutputTemplate:
|
|
216
217
|
"""
|
217
218
|
return sorted([f.name for f in self.input_files])
|
218
219
|
|
220
|
+
def get_descriptor_name(self, source_file: FileDescriptorProto):
|
221
|
+
return f"{source_file.name.replace('/', '_').replace('.', '_').upper()}_DESCRIPTOR"
|
222
|
+
|
223
|
+
@property
|
224
|
+
def descriptors(self):
|
225
|
+
"""Google protobuf library descriptors.
|
226
|
+
|
227
|
+
Returns
|
228
|
+
-------
|
229
|
+
str
|
230
|
+
A list of pool registrations for proto descriptors.
|
231
|
+
"""
|
232
|
+
descriptors: list[str] = []
|
233
|
+
|
234
|
+
for f in self.input_files:
|
235
|
+
# Remove the source_code_info field since it is not needed at runtime.
|
236
|
+
source_code_info: SourceCodeInfo | None = f.source_code_info
|
237
|
+
f.source_code_info = None
|
238
|
+
|
239
|
+
descriptors.append(
|
240
|
+
f"{self.get_descriptor_name(f)} = default_google_proto_descriptor_pool.AddSerializedFile({bytes(f)})"
|
241
|
+
)
|
242
|
+
|
243
|
+
f.source_code_info = source_code_info
|
244
|
+
|
245
|
+
return "\n".join(descriptors)
|
246
|
+
|
219
247
|
|
220
248
|
@dataclass(kw_only=True)
|
221
249
|
class MessageCompiler(ProtoContentBase):
|
@@ -223,6 +251,7 @@ class MessageCompiler(ProtoContentBase):
|
|
223
251
|
|
224
252
|
output_file: OutputTemplate
|
225
253
|
proto_obj: DescriptorProto
|
254
|
+
prefixed_proto_name: str
|
226
255
|
fields: list["FieldCompiler"] = field(default_factory=list)
|
227
256
|
oneofs: list["OneofCompiler"] = field(default_factory=list)
|
228
257
|
builtins_types: set[str] = field(default_factory=set)
|
@@ -233,7 +262,7 @@ class MessageCompiler(ProtoContentBase):
|
|
233
262
|
|
234
263
|
@property
|
235
264
|
def py_name(self) -> str:
|
236
|
-
return pythonize_class_name(self.
|
265
|
+
return pythonize_class_name(self.prefixed_proto_name)
|
237
266
|
|
238
267
|
@property
|
239
268
|
def deprecated(self) -> bool:
|
@@ -266,6 +295,17 @@ class MessageCompiler(ProtoContentBase):
|
|
266
295
|
|
267
296
|
return methods_source
|
268
297
|
|
298
|
+
@property
|
299
|
+
def descriptor_name(self) -> str:
|
300
|
+
"""Google protobuf library descriptor name.
|
301
|
+
|
302
|
+
Returns
|
303
|
+
-------
|
304
|
+
str
|
305
|
+
The Python name of the descriptor to reference.
|
306
|
+
"""
|
307
|
+
return self.output_file.get_descriptor_name(self.source_file)
|
308
|
+
|
269
309
|
|
270
310
|
def is_map(proto_field_obj: FieldDescriptorProto, parent_message: DescriptorProto) -> bool:
|
271
311
|
"""True if proto_field_obj is a map, otherwise False."""
|
@@ -562,6 +602,7 @@ class EnumDefinitionCompiler(ProtoContentBase):
|
|
562
602
|
|
563
603
|
output_file: OutputTemplate
|
564
604
|
proto_obj: EnumDescriptorProto
|
605
|
+
prefixed_proto_name: str
|
565
606
|
entries: list["EnumDefinitionCompiler.EnumEntry"] = field(default_factory=list)
|
566
607
|
|
567
608
|
@dataclass(unsafe_hash=True, kw_only=True)
|
@@ -589,12 +630,23 @@ class EnumDefinitionCompiler(ProtoContentBase):
|
|
589
630
|
|
590
631
|
@property
|
591
632
|
def py_name(self) -> str:
|
592
|
-
return pythonize_class_name(self.
|
633
|
+
return pythonize_class_name(self.prefixed_proto_name)
|
593
634
|
|
594
635
|
@property
|
595
636
|
def deprecated(self) -> bool:
|
596
637
|
return bool(self.proto_obj.options and self.proto_obj.options.deprecated)
|
597
638
|
|
639
|
+
@property
|
640
|
+
def descriptor_name(self) -> str:
|
641
|
+
"""Google protobuf library descriptor name.
|
642
|
+
|
643
|
+
Returns
|
644
|
+
-------
|
645
|
+
str
|
646
|
+
The Python name of the descriptor to reference.
|
647
|
+
"""
|
648
|
+
return self.output_file.get_descriptor_name(self.source_file)
|
649
|
+
|
598
650
|
|
599
651
|
@dataclass(kw_only=True)
|
600
652
|
class ServiceCompiler(ProtoContentBase):
|
@@ -35,20 +35,21 @@ from .models import (
|
|
35
35
|
|
36
36
|
def traverse(
|
37
37
|
proto_file: FileDescriptorProto,
|
38
|
-
) -> Generator[tuple[EnumDescriptorProto | DescriptorProto, list[int]], None, None]:
|
38
|
+
) -> Generator[tuple[EnumDescriptorProto | DescriptorProto, list[int], str], None, None]:
|
39
39
|
# Todo: Keep information about nested hierarchy
|
40
40
|
def _traverse(
|
41
41
|
path: list[int],
|
42
42
|
items: list[EnumDescriptorProto] | list[DescriptorProto],
|
43
43
|
prefix: str = "",
|
44
|
-
) -> Generator[tuple[EnumDescriptorProto | DescriptorProto, list[int]], None, None]:
|
44
|
+
) -> Generator[tuple[EnumDescriptorProto | DescriptorProto, list[int], str], None, None]:
|
45
45
|
for i, item in enumerate(items):
|
46
46
|
# Adjust the name since we flatten the hierarchy.
|
47
|
-
# Todo: don't change the name, but include full name in returned tuple
|
48
47
|
should_rename = not isinstance(item, DescriptorProto) or not item.options or not item.options.map_entry
|
49
48
|
|
50
|
-
|
51
|
-
|
49
|
+
# Record prefixed name but *do not* mutate original file.
|
50
|
+
# We use this prefixed name to create pythonized names.
|
51
|
+
prefixed_name = next_prefix = f"{prefix}.{item.name}" if prefix and should_rename else item.name
|
52
|
+
yield item, [*path, i], prefixed_name
|
52
53
|
|
53
54
|
if isinstance(item, DescriptorProto):
|
54
55
|
# Get nested types.
|
@@ -81,6 +82,7 @@ def get_settings(plugin_options: list[str]) -> Settings:
|
|
81
82
|
|
82
83
|
return Settings(
|
83
84
|
pydantic_dataclasses="pydantic_dataclasses" in plugin_options,
|
85
|
+
google_protobuf_descriptors="google_protobuf_descriptors" in plugin_options,
|
84
86
|
client_generation=client_generation,
|
85
87
|
server_generation=server_generation,
|
86
88
|
)
|
@@ -109,12 +111,13 @@ def generate_code(request: CodeGeneratorRequest) -> CodeGeneratorResponse:
|
|
109
111
|
# get the references to input/output messages for each service
|
110
112
|
for output_package_name, output_package in request_data.output_packages.items():
|
111
113
|
for proto_input_file in output_package.input_files:
|
112
|
-
for item, path in traverse(proto_input_file):
|
114
|
+
for item, path, prefixed_proto_name in traverse(proto_input_file):
|
113
115
|
read_protobuf_type(
|
114
116
|
source_file=proto_input_file,
|
115
117
|
item=item,
|
116
118
|
path=path,
|
117
119
|
output_package=output_package,
|
120
|
+
prefixed_proto_name=prefixed_proto_name,
|
118
121
|
)
|
119
122
|
|
120
123
|
# Read Services
|
@@ -168,6 +171,15 @@ def generate_code(request: CodeGeneratorRequest) -> CodeGeneratorResponse:
|
|
168
171
|
)
|
169
172
|
)
|
170
173
|
|
174
|
+
if settings.google_protobuf_descriptors:
|
175
|
+
response.file.append(
|
176
|
+
CodeGeneratorResponseFile(
|
177
|
+
name="google_proto_descriptor_pool.py",
|
178
|
+
content="from google.protobuf import descriptor_pool\n\n"
|
179
|
+
+ "default_google_proto_descriptor_pool = descriptor_pool.DescriptorPool()\n",
|
180
|
+
)
|
181
|
+
)
|
182
|
+
|
171
183
|
for output_package_name in sorted(output_paths.union(init_files)):
|
172
184
|
print(f"Writing {output_package_name}", file=sys.stderr)
|
173
185
|
|
@@ -179,6 +191,7 @@ def read_protobuf_type(
|
|
179
191
|
path: list[int],
|
180
192
|
source_file: "FileDescriptorProto",
|
181
193
|
output_package: OutputTemplate,
|
194
|
+
prefixed_proto_name: str,
|
182
195
|
) -> None:
|
183
196
|
if isinstance(item, DescriptorProto):
|
184
197
|
if item.options and item.options.map_entry:
|
@@ -188,10 +201,11 @@ def read_protobuf_type(
|
|
188
201
|
message_data = MessageCompiler(
|
189
202
|
source_file=source_file,
|
190
203
|
output_file=output_package,
|
204
|
+
prefixed_proto_name=prefixed_proto_name,
|
191
205
|
proto_obj=item,
|
192
206
|
path=path,
|
193
207
|
)
|
194
|
-
output_package.messages[message_data.
|
208
|
+
output_package.messages[message_data.prefixed_proto_name] = message_data
|
195
209
|
|
196
210
|
for index, field in enumerate(item.field):
|
197
211
|
if is_map(field, item):
|
@@ -243,10 +257,11 @@ def read_protobuf_type(
|
|
243
257
|
enum = EnumDefinitionCompiler(
|
244
258
|
source_file=source_file,
|
245
259
|
output_file=output_package,
|
260
|
+
prefixed_proto_name=prefixed_proto_name,
|
246
261
|
proto_obj=item,
|
247
262
|
path=path,
|
248
263
|
)
|
249
|
-
output_package.enums[enum.
|
264
|
+
output_package.enums[enum.prefixed_proto_name] = enum
|
250
265
|
|
251
266
|
|
252
267
|
def read_protobuf_service(
|
@@ -32,12 +32,19 @@ import betterproto2
|
|
32
32
|
from betterproto2.grpc.grpclib_server import ServiceBase
|
33
33
|
import grpc
|
34
34
|
import grpclib
|
35
|
+
from google.protobuf.descriptor import Descriptor, EnumDescriptor
|
35
36
|
|
36
37
|
{# Import the message pool of the generated code. #}
|
37
38
|
{% if output_file.package %}
|
38
39
|
from {{ "." * output_file.package.count(".") }}..message_pool import default_message_pool
|
40
|
+
{% if output_file.settings.google_protobuf_descriptors %}
|
41
|
+
from {{ "." * output_file.package.count(".") }}..google_proto_descriptor_pool import default_google_proto_descriptor_pool
|
42
|
+
{% endif %}
|
39
43
|
{% else %}
|
40
44
|
from .message_pool import default_message_pool
|
45
|
+
{% if output_file.settings.google_protobuf_descriptors %}
|
46
|
+
from .google_proto_descriptor_pool import default_google_proto_descriptor_pool
|
47
|
+
{% endif %}
|
41
48
|
{% endif %}
|
42
49
|
|
43
50
|
if TYPE_CHECKING:
|
@@ -45,4 +52,5 @@ if TYPE_CHECKING:
|
|
45
52
|
from betterproto2.grpc.grpclib_client import MetadataLike
|
46
53
|
from grpclib.metadata import Deadline
|
47
54
|
|
48
|
-
|
55
|
+
_COMPILER_VERSION="{{ version }}"
|
56
|
+
betterproto2.check_compiler_version(_COMPILER_VERSION)
|
@@ -6,6 +6,13 @@ class {{ enum.py_name | add_to_all }}(betterproto2.Enum):
|
|
6
6
|
"""
|
7
7
|
{% endif %}
|
8
8
|
|
9
|
+
{% if output_file.settings.google_protobuf_descriptors %}
|
10
|
+
{# Add descriptor class property to be more drop-in compatible with other libraries. #}
|
11
|
+
@betterproto2.classproperty
|
12
|
+
def DESCRIPTOR(self) -> EnumDescriptor:
|
13
|
+
return {{ enum.descriptor_name }}.enum_types_by_name['{{ enum.prefixed_proto_name }}']
|
14
|
+
{% endif %}
|
15
|
+
|
9
16
|
{% for entry in enum.entries %}
|
10
17
|
{{ entry.name }} = {{ entry.value }}
|
11
18
|
{% if entry.comment %}
|
@@ -45,6 +52,13 @@ class {{ message.py_name | add_to_all }}(betterproto2.Message):
|
|
45
52
|
"""
|
46
53
|
{% endif %}
|
47
54
|
|
55
|
+
{% if output_file.settings.google_protobuf_descriptors %}
|
56
|
+
{# Add descriptor class property to be more drop-in compatible with other libraries. #}
|
57
|
+
@betterproto2.classproperty
|
58
|
+
def DESCRIPTOR(self) -> Descriptor:
|
59
|
+
return {{ message.descriptor_name }}.message_types_by_name['{{ message.prefixed_proto_name }}']
|
60
|
+
{% endif %}
|
61
|
+
|
48
62
|
{% for field in message.fields %}
|
49
63
|
{{ field.get_field_string() }}
|
50
64
|
{% if field.comment %}
|
@@ -81,7 +95,7 @@ class {{ message.py_name | add_to_all }}(betterproto2.Message):
|
|
81
95
|
{{ method_source }}
|
82
96
|
{% endfor %}
|
83
97
|
|
84
|
-
default_message_pool.register_message("{{ output_file.package }}", "{{ message.
|
98
|
+
default_message_pool.register_message("{{ output_file.package }}", "{{ message.prefixed_proto_name }}", {{ message.py_name }})
|
85
99
|
|
86
100
|
|
87
101
|
{% endfor %}
|
@@ -102,6 +116,11 @@ default_message_pool.register_message("{{ output_file.package }}", "{{ message.p
|
|
102
116
|
{{ i }}
|
103
117
|
{% endfor %}
|
104
118
|
|
119
|
+
{% if output_file.settings.google_protobuf_descriptors %}
|
120
|
+
{# Add descriptors to Google protobuf's default pool to be more drop-in compatible with other libraries. #}
|
121
|
+
{{ output_file.descriptors }}
|
122
|
+
{% endif %}
|
123
|
+
|
105
124
|
{% if output_file.settings.server_generation == "async" %}
|
106
125
|
{% for _, service in output_file.services|dictsort(by="key") %}
|
107
126
|
class {{ (service.py_name + "Base") | add_to_all }}(ServiceBase):
|
@@ -127,6 +146,10 @@ class {{ (service.py_name + "Base") | add_to_all }}(ServiceBase):
|
|
127
146
|
{% endif %}
|
128
147
|
|
129
148
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
149
|
+
{% if method.server_streaming %}
|
150
|
+
{# yielding here changes the return type from a coroutine to an async_generator #}
|
151
|
+
yield {{ method.py_output_message_type }}()
|
152
|
+
{% endif %}
|
130
153
|
|
131
154
|
{% endfor %}
|
132
155
|
|
@@ -9,6 +9,7 @@ from tests.util import (
|
|
9
9
|
get_directories,
|
10
10
|
inputs_path,
|
11
11
|
output_path_betterproto,
|
12
|
+
output_path_betterproto_descriptor,
|
12
13
|
output_path_betterproto_pydantic,
|
13
14
|
output_path_reference,
|
14
15
|
protoc,
|
@@ -57,23 +58,28 @@ async def generate_test_case_output(test_case_input_path: Path, test_case_name:
|
|
57
58
|
test_case_output_path_reference = output_path_reference.joinpath(test_case_name)
|
58
59
|
test_case_output_path_betterproto = output_path_betterproto
|
59
60
|
test_case_output_path_betterproto_pyd = output_path_betterproto_pydantic
|
61
|
+
test_case_output_path_betterproto_desc = output_path_betterproto_descriptor
|
60
62
|
|
61
63
|
os.makedirs(test_case_output_path_reference, exist_ok=True)
|
62
64
|
os.makedirs(test_case_output_path_betterproto, exist_ok=True)
|
63
65
|
os.makedirs(test_case_output_path_betterproto_pyd, exist_ok=True)
|
66
|
+
os.makedirs(test_case_output_path_betterproto_desc, exist_ok=True)
|
64
67
|
|
65
68
|
clear_directory(test_case_output_path_reference)
|
66
69
|
clear_directory(test_case_output_path_betterproto)
|
67
70
|
clear_directory(test_case_output_path_betterproto_pyd)
|
71
|
+
clear_directory(test_case_output_path_betterproto_desc)
|
68
72
|
|
69
73
|
(
|
70
74
|
(ref_out, ref_err, ref_code),
|
71
75
|
(plg_out, plg_err, plg_code),
|
72
76
|
(plg_out_pyd, plg_err_pyd, plg_code_pyd),
|
77
|
+
(plg_out_desc, plg_err_desc, plg_code_desc),
|
73
78
|
) = await asyncio.gather(
|
74
79
|
protoc(test_case_input_path, test_case_output_path_reference, True),
|
75
80
|
protoc(test_case_input_path, test_case_output_path_betterproto, False),
|
76
81
|
protoc(test_case_input_path, test_case_output_path_betterproto_pyd, False, True),
|
82
|
+
protoc(test_case_input_path, test_case_output_path_betterproto_desc, False, False, True),
|
77
83
|
)
|
78
84
|
|
79
85
|
if ref_code == 0:
|
@@ -127,7 +133,26 @@ async def generate_test_case_output(test_case_input_path: Path, test_case_name:
|
|
127
133
|
sys.stderr.buffer.write(plg_err_pyd)
|
128
134
|
sys.stderr.buffer.flush()
|
129
135
|
|
130
|
-
|
136
|
+
if plg_code_desc == 0:
|
137
|
+
print(f"\033[31;1;4mGenerated plugin (google protobuf descriptor) output for {test_case_name!r}\033[0m")
|
138
|
+
else:
|
139
|
+
print(
|
140
|
+
f"\033[31;1;4mFailed to generate plugin (google protobuf descriptor) output for {test_case_name!r}\033[0m"
|
141
|
+
)
|
142
|
+
print(plg_err_desc.decode())
|
143
|
+
|
144
|
+
if verbose:
|
145
|
+
if plg_out_desc:
|
146
|
+
print("Plugin stdout:")
|
147
|
+
sys.stdout.buffer.write(plg_out_desc)
|
148
|
+
sys.stdout.buffer.flush()
|
149
|
+
|
150
|
+
if plg_err_desc:
|
151
|
+
print("Plugin stderr:")
|
152
|
+
sys.stderr.buffer.write(plg_err_desc)
|
153
|
+
sys.stderr.buffer.flush()
|
154
|
+
|
155
|
+
return max(ref_code, plg_code, plg_code_pyd, plg_code_desc)
|
131
156
|
|
132
157
|
|
133
158
|
def main():
|
@@ -2,6 +2,8 @@ syntax = "proto3";
|
|
2
2
|
|
3
3
|
package example_service;
|
4
4
|
|
5
|
+
import "google/protobuf/struct.proto";
|
6
|
+
|
5
7
|
service Test {
|
6
8
|
rpc ExampleUnaryUnary(ExampleRequest) returns (ExampleResponse);
|
7
9
|
rpc ExampleUnaryStream(ExampleRequest) returns (stream ExampleResponse);
|
@@ -12,9 +14,11 @@ service Test {
|
|
12
14
|
message ExampleRequest {
|
13
15
|
string example_string = 1;
|
14
16
|
int64 example_integer = 2;
|
17
|
+
google.protobuf.Struct example_struct = 3;
|
15
18
|
}
|
16
19
|
|
17
20
|
message ExampleResponse {
|
18
21
|
string example_string = 1;
|
19
22
|
int64 example_integer = 2;
|
23
|
+
google.protobuf.Struct example_struct = 3;
|
20
24
|
}
|