betterproto2-compiler 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
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/compile/importing.py +2 -2
- betterproto2_compiler/lib/std/google/protobuf/__init__.py +263 -259
- betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py +25 -25
- betterproto2_compiler/plugin/models.py +7 -6
- betterproto2_compiler/templates/header.py.j2 +4 -4
- betterproto2_compiler/templates/template.py.j2 +3 -3
- {betterproto2_compiler-0.0.1.dist-info → betterproto2_compiler-0.0.3.dist-info}/METADATA +2 -1
- {betterproto2_compiler-0.0.1.dist-info → betterproto2_compiler-0.0.3.dist-info}/RECORD +11 -11
- {betterproto2_compiler-0.0.1.dist-info → betterproto2_compiler-0.0.3.dist-info}/LICENSE.md +0 -0
- {betterproto2_compiler-0.0.1.dist-info → betterproto2_compiler-0.0.3.dist-info}/WHEEL +0 -0
- {betterproto2_compiler-0.0.1.dist-info → betterproto2_compiler-0.0.3.dist-info}/entry_points.txt +0 -0
@@ -1,17 +1,17 @@
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
2
|
# sources: google/protobuf/compiler/plugin.proto
|
3
|
-
# plugin: python-
|
3
|
+
# plugin: python-betterproto2
|
4
4
|
# This file has been @generated
|
5
5
|
|
6
6
|
from dataclasses import dataclass
|
7
7
|
from typing import List
|
8
8
|
|
9
|
-
import
|
9
|
+
import betterproto2
|
10
10
|
|
11
11
|
import betterproto2_compiler.lib.google.protobuf as betterproto_lib_google_protobuf
|
12
12
|
|
13
13
|
|
14
|
-
class CodeGeneratorResponseFeature(
|
14
|
+
class CodeGeneratorResponseFeature(betterproto2.Enum):
|
15
15
|
"""Sync with code_generator.h."""
|
16
16
|
|
17
17
|
FEATURE_NONE = 0
|
@@ -20,13 +20,13 @@ class CodeGeneratorResponseFeature(betterproto.Enum):
|
|
20
20
|
|
21
21
|
|
22
22
|
@dataclass(eq=False, repr=False)
|
23
|
-
class Version(
|
23
|
+
class Version(betterproto2.Message):
|
24
24
|
"""The version number of protocol compiler."""
|
25
25
|
|
26
|
-
major: int =
|
27
|
-
minor: int =
|
28
|
-
patch: int =
|
29
|
-
suffix: str =
|
26
|
+
major: int = betterproto2.int32_field(1)
|
27
|
+
minor: int = betterproto2.int32_field(2)
|
28
|
+
patch: int = betterproto2.int32_field(3)
|
29
|
+
suffix: str = betterproto2.string_field(4)
|
30
30
|
"""
|
31
31
|
A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
|
32
32
|
be empty for mainline stable releases.
|
@@ -34,20 +34,20 @@ class Version(betterproto.Message):
|
|
34
34
|
|
35
35
|
|
36
36
|
@dataclass(eq=False, repr=False)
|
37
|
-
class CodeGeneratorRequest(
|
37
|
+
class CodeGeneratorRequest(betterproto2.Message):
|
38
38
|
"""An encoded CodeGeneratorRequest is written to the plugin's stdin."""
|
39
39
|
|
40
|
-
file_to_generate: List[str] =
|
40
|
+
file_to_generate: List[str] = betterproto2.string_field(1, repeated=True)
|
41
41
|
"""
|
42
42
|
The .proto files that were explicitly listed on the command-line. The
|
43
43
|
code generator should generate code only for these files. Each file's
|
44
44
|
descriptor will be included in proto_file, below.
|
45
45
|
"""
|
46
46
|
|
47
|
-
parameter: str =
|
47
|
+
parameter: str = betterproto2.string_field(2)
|
48
48
|
"""The generator parameter passed on the command-line."""
|
49
49
|
|
50
|
-
proto_file: List["betterproto_lib_google_protobuf.FileDescriptorProto"] =
|
50
|
+
proto_file: List["betterproto_lib_google_protobuf.FileDescriptorProto"] = betterproto2.message_field(
|
51
51
|
15, repeated=True
|
52
52
|
)
|
53
53
|
"""
|
@@ -72,7 +72,7 @@ class CodeGeneratorRequest(betterproto.Message):
|
|
72
72
|
fully qualified.
|
73
73
|
"""
|
74
74
|
|
75
|
-
source_file_descriptors: List["betterproto_lib_google_protobuf.FileDescriptorProto"] =
|
75
|
+
source_file_descriptors: List["betterproto_lib_google_protobuf.FileDescriptorProto"] = betterproto2.message_field(
|
76
76
|
17, repeated=True
|
77
77
|
)
|
78
78
|
"""
|
@@ -81,15 +81,15 @@ class CodeGeneratorRequest(betterproto.Message):
|
|
81
81
|
files_to_generate.
|
82
82
|
"""
|
83
83
|
|
84
|
-
compiler_version: "Version" =
|
84
|
+
compiler_version: "Version" = betterproto2.message_field(3)
|
85
85
|
"""The version number of protocol compiler."""
|
86
86
|
|
87
87
|
|
88
88
|
@dataclass(eq=False, repr=False)
|
89
|
-
class CodeGeneratorResponse(
|
89
|
+
class CodeGeneratorResponse(betterproto2.Message):
|
90
90
|
"""The plugin writes an encoded CodeGeneratorResponse to stdout."""
|
91
91
|
|
92
|
-
error: str =
|
92
|
+
error: str = betterproto2.string_field(1)
|
93
93
|
"""
|
94
94
|
Error message. If non-empty, code generation failed. The plugin process
|
95
95
|
should exit with status code zero even if it reports an error in this way.
|
@@ -101,13 +101,13 @@ class CodeGeneratorResponse(betterproto.Message):
|
|
101
101
|
exiting with a non-zero status code.
|
102
102
|
"""
|
103
103
|
|
104
|
-
supported_features: int =
|
104
|
+
supported_features: int = betterproto2.uint64_field(2)
|
105
105
|
"""
|
106
106
|
A bitmask of supported features that the code generator supports.
|
107
107
|
This is a bitwise "or" of values from the Feature enum.
|
108
108
|
"""
|
109
109
|
|
110
|
-
minimum_edition: int =
|
110
|
+
minimum_edition: int = betterproto2.int32_field(3)
|
111
111
|
"""
|
112
112
|
The minimum edition this plugin supports. This will be treated as an
|
113
113
|
Edition enum, but we want to allow unknown values. It should be specified
|
@@ -115,7 +115,7 @@ class CodeGeneratorResponse(betterproto.Message):
|
|
115
115
|
effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
|
116
116
|
"""
|
117
117
|
|
118
|
-
maximum_edition: int =
|
118
|
+
maximum_edition: int = betterproto2.int32_field(4)
|
119
119
|
"""
|
120
120
|
The maximum edition this plugin supports. This will be treated as an
|
121
121
|
Edition enum, but we want to allow unknown values. It should be specified
|
@@ -123,14 +123,14 @@ class CodeGeneratorResponse(betterproto.Message):
|
|
123
123
|
effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
|
124
124
|
"""
|
125
125
|
|
126
|
-
file: List["CodeGeneratorResponseFile"] =
|
126
|
+
file: List["CodeGeneratorResponseFile"] = betterproto2.message_field(15, repeated=True)
|
127
127
|
|
128
128
|
|
129
129
|
@dataclass(eq=False, repr=False)
|
130
|
-
class CodeGeneratorResponseFile(
|
130
|
+
class CodeGeneratorResponseFile(betterproto2.Message):
|
131
131
|
"""Represents a single generated file."""
|
132
132
|
|
133
|
-
name: str =
|
133
|
+
name: str = betterproto2.string_field(1)
|
134
134
|
"""
|
135
135
|
The file name, relative to the output directory. The name must not
|
136
136
|
contain "." or ".." components and must be relative, not be absolute (so,
|
@@ -145,7 +145,7 @@ class CodeGeneratorResponseFile(betterproto.Message):
|
|
145
145
|
CodeGeneratorResponse before writing files to disk.
|
146
146
|
"""
|
147
147
|
|
148
|
-
insertion_point: str =
|
148
|
+
insertion_point: str = betterproto2.string_field(2)
|
149
149
|
"""
|
150
150
|
If non-empty, indicates that the named file should already exist, and the
|
151
151
|
content here is to be inserted into that file at a defined insertion
|
@@ -186,10 +186,10 @@ class CodeGeneratorResponseFile(betterproto.Message):
|
|
186
186
|
If |insertion_point| is present, |name| must also be present.
|
187
187
|
"""
|
188
188
|
|
189
|
-
content: str =
|
189
|
+
content: str = betterproto2.string_field(15)
|
190
190
|
"""The file contents."""
|
191
191
|
|
192
|
-
generated_code_info: "betterproto_lib_google_protobuf.GeneratedCodeInfo" =
|
192
|
+
generated_code_info: "betterproto_lib_google_protobuf.GeneratedCodeInfo" = betterproto2.message_field(16)
|
193
193
|
"""
|
194
194
|
Information describing the file content being inserted. If an insertion
|
195
195
|
point is used, this information will be appropriately offset and inserted
|
@@ -46,7 +46,8 @@ from typing import (
|
|
46
46
|
Union,
|
47
47
|
)
|
48
48
|
|
49
|
-
import
|
49
|
+
import betterproto2
|
50
|
+
|
50
51
|
from betterproto2_compiler.compile.naming import (
|
51
52
|
pythonize_class_name,
|
52
53
|
pythonize_field_name,
|
@@ -182,7 +183,7 @@ class ProtoContentBase:
|
|
182
183
|
source_file: FileDescriptorProto
|
183
184
|
typing_compiler: TypingCompiler
|
184
185
|
path: List[int]
|
185
|
-
parent: Union["
|
186
|
+
parent: Union["betterproto2.Message", "OutputTemplate"]
|
186
187
|
|
187
188
|
__dataclass_fields__: Dict[str, object]
|
188
189
|
|
@@ -389,7 +390,7 @@ class FieldCompiler(ProtoContentBase):
|
|
389
390
|
"""Construct string representation of this field as a field."""
|
390
391
|
name = f"{self.py_name}"
|
391
392
|
field_args = ", ".join(([""] + self.betterproto_field_args) if self.betterproto_field_args else [])
|
392
|
-
betterproto_field_type = f"
|
393
|
+
betterproto_field_type = f"betterproto2.{self.field_type}_field({self.proto_obj.number}{field_args})"
|
393
394
|
if self.py_name in dir(builtins):
|
394
395
|
self.parent.builtins_types.add(self.py_name)
|
395
396
|
return f'{name}: "{self.annotation}" = {betterproto_field_type}'
|
@@ -420,8 +421,8 @@ class FieldCompiler(ProtoContentBase):
|
|
420
421
|
match_wrapper = re.match(r"\.google\.protobuf\.(.+)Value$", self.proto_obj.type_name)
|
421
422
|
if match_wrapper:
|
422
423
|
wrapped_type = "TYPE_" + match_wrapper.group(1).upper()
|
423
|
-
if hasattr(
|
424
|
-
return f"
|
424
|
+
if hasattr(betterproto2, wrapped_type):
|
425
|
+
return f"betterproto2.{wrapped_type}"
|
425
426
|
return None
|
426
427
|
|
427
428
|
@property
|
@@ -548,7 +549,7 @@ class MapEntryCompiler(FieldCompiler):
|
|
548
549
|
|
549
550
|
@property
|
550
551
|
def betterproto_field_args(self) -> List[str]:
|
551
|
-
return [f"
|
552
|
+
return [f"betterproto2.{self.proto_k_type}", f"betterproto2.{self.proto_v_type}"]
|
552
553
|
|
553
554
|
@property
|
554
555
|
def field_type(self) -> str:
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
4
4
|
# sources: {{ ', '.join(output_file.input_filenames) }}
|
5
|
-
# plugin: python-
|
5
|
+
# plugin: python-betterproto2
|
6
6
|
# This file has been @generated
|
7
7
|
|
8
8
|
__all__ = (
|
@@ -36,9 +36,9 @@ from dataclasses import dataclass
|
|
36
36
|
{% endfor %}
|
37
37
|
{% endif %}
|
38
38
|
|
39
|
-
import
|
39
|
+
import betterproto2
|
40
40
|
{% if output_file.services %}
|
41
|
-
from
|
41
|
+
from betterproto2.grpc.grpclib_server import ServiceBase
|
42
42
|
import grpclib
|
43
43
|
{% endif %}
|
44
44
|
|
@@ -46,5 +46,5 @@ from typing import TYPE_CHECKING
|
|
46
46
|
|
47
47
|
if TYPE_CHECKING:
|
48
48
|
import grpclib.server
|
49
|
-
from
|
49
|
+
from betterproto2.grpc.grpclib_client import MetadataLike
|
50
50
|
from grpclib.metadata import Deadline
|
@@ -1,5 +1,5 @@
|
|
1
1
|
{% for _, enum in output_file.enums|dictsort(by="key") %}
|
2
|
-
class {{ enum.py_name }}(
|
2
|
+
class {{ enum.py_name }}(betterproto2.Enum):
|
3
3
|
{% if enum.comment %}
|
4
4
|
"""
|
5
5
|
{{ enum.comment | indent(4) }}
|
@@ -31,7 +31,7 @@ class {{ enum.py_name }}(betterproto.Enum):
|
|
31
31
|
{% else %}
|
32
32
|
@dataclass(eq=False, repr=False)
|
33
33
|
{% endif %}
|
34
|
-
class {{ message.py_name }}(
|
34
|
+
class {{ message.py_name }}(betterproto2.Message):
|
35
35
|
{% if message.comment %}
|
36
36
|
"""
|
37
37
|
{{ message.comment | indent(4) }}
|
@@ -71,7 +71,7 @@ class {{ message.py_name }}(betterproto.Message):
|
|
71
71
|
|
72
72
|
{% endfor %}
|
73
73
|
{% for _, service in output_file.services|dictsort(by="key") %}
|
74
|
-
class {{ service.py_name }}Stub(
|
74
|
+
class {{ service.py_name }}Stub(betterproto2.ServiceStub):
|
75
75
|
{% if service.comment %}
|
76
76
|
"""
|
77
77
|
{{ service.comment | indent(4) }}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: betterproto2_compiler
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.3
|
4
4
|
Summary: Compiler for betterproto2
|
5
5
|
Home-page: https://github.com/betterproto/python-betterproto2-compiler
|
6
6
|
License: MIT
|
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
17
|
+
Requires-Dist: betterproto2 (==0.0.2)
|
17
18
|
Requires-Dist: grpclib (>=0.4.1,<0.5.0)
|
18
19
|
Requires-Dist: jinja2 (>=3.0.3)
|
19
20
|
Requires-Dist: ruff (>=0.7.4,<0.8.0)
|
@@ -2,7 +2,7 @@ betterproto2_compiler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
2
2
|
betterproto2_compiler/_types.py,sha256=nIsUxcId43N1Gu8EqdeuflR9iUZB1JWu4JTGQV9NeUI,294
|
3
3
|
betterproto2_compiler/casing.py,sha256=bMdI4W0hfYh6kV-DQIqFEjSfGYEqUtPciAzP64z5HLQ,3587
|
4
4
|
betterproto2_compiler/compile/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
betterproto2_compiler/compile/importing.py,sha256=
|
5
|
+
betterproto2_compiler/compile/importing.py,sha256=UNBvayHZmvvwQMIEZ0Zzk0KsqIGqGSbPKhv_DUg2qV8,7442
|
6
6
|
betterproto2_compiler/compile/naming.py,sha256=zf0VOmNojzyv33upOGelGxjZTEDE8JULEEED5_3inHg,562
|
7
7
|
betterproto2_compiler/enum.py,sha256=LcILQf1BEjnszouUCtPwifJAR_8u2tf9U9hfwP4vXTc,5396
|
8
8
|
betterproto2_compiler/grpc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -20,22 +20,22 @@ betterproto2_compiler/lib/pydantic/google/protobuf/__init__.py,sha256=eAvwcNussn
|
|
20
20
|
betterproto2_compiler/lib/pydantic/google/protobuf/compiler/__init__.py,sha256=uI4F0DytRxbrwXqiRKOJD0nJFewlQE0Lj_3WJdiGoDU,9217
|
21
21
|
betterproto2_compiler/lib/std/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
betterproto2_compiler/lib/std/google/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
|
-
betterproto2_compiler/lib/std/google/protobuf/__init__.py,sha256=
|
24
|
-
betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py,sha256=
|
23
|
+
betterproto2_compiler/lib/std/google/protobuf/__init__.py,sha256=s5Tkt3684xnq2VL0cHZXytN2ja4D73C6ZNf7APEYdcI,80454
|
24
|
+
betterproto2_compiler/lib/std/google/protobuf/compiler/__init__.py,sha256=z63o4vkjnDWB7yZpYnx-T0FZCbmSs5gBzfKrNP_qf8c,8646
|
25
25
|
betterproto2_compiler/plugin/__init__.py,sha256=L3pW0b4CvkM5x53x_sYt1kYiSFPO0_vaeH6EQPq9FAM,43
|
26
26
|
betterproto2_compiler/plugin/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
|
27
27
|
betterproto2_compiler/plugin/compiler.py,sha256=J_0WvuOVXuIINogNTOtU9Kyhzbu3NDrKh7ojbMjSjJk,2032
|
28
28
|
betterproto2_compiler/plugin/main.py,sha256=Q9PmcJqXuYYFe51l7AqHVzJrHqi2LWCUu80CZSQOOwk,1469
|
29
|
-
betterproto2_compiler/plugin/models.py,sha256=
|
29
|
+
betterproto2_compiler/plugin/models.py,sha256=Ljo08MGmZ68q7bFTI7532KrqyjjJhHMe15a-tvxAGyI,24288
|
30
30
|
betterproto2_compiler/plugin/module_validation.py,sha256=vye8PjsZFs1Ikh0yNLQXuy12EdM0em0Bflgx7xYrMhk,4853
|
31
31
|
betterproto2_compiler/plugin/parser.py,sha256=PFFlK7Di7BF7_tCzkIWUeaRqDfVKJQc9YjSVKeHVXWM,9651
|
32
32
|
betterproto2_compiler/plugin/plugin.bat,sha256=lfLT1WguAXqyerLLsRL6BfHA0RqUE6QG79v-1BYVSpI,48
|
33
33
|
betterproto2_compiler/plugin/typing_compiler.py,sha256=gMrKsrA_xFoy33tbm4VjiktXyGAARFGHPL6iVmUiPLU,4866
|
34
34
|
betterproto2_compiler/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
|
-
betterproto2_compiler/templates/header.py.j2,sha256=
|
36
|
-
betterproto2_compiler/templates/template.py.j2,sha256=
|
37
|
-
betterproto2_compiler-0.0.
|
38
|
-
betterproto2_compiler-0.0.
|
39
|
-
betterproto2_compiler-0.0.
|
40
|
-
betterproto2_compiler-0.0.
|
41
|
-
betterproto2_compiler-0.0.
|
35
|
+
betterproto2_compiler/templates/header.py.j2,sha256=H3R2v5MiCebp5p1zMKCDjsVlnOLklqrwO24SUtjfdN0,1410
|
36
|
+
betterproto2_compiler/templates/template.py.j2,sha256=icyiNdSTJRgyD20e_lTgTAvSjgnSFSn4t1L1-yZnkEM,8712
|
37
|
+
betterproto2_compiler-0.0.3.dist-info/LICENSE.md,sha256=Pgl2pReU-2yw2miGeQ55UFlyzqAZ_EpYVyZ2nWjwRv4,1121
|
38
|
+
betterproto2_compiler-0.0.3.dist-info/METADATA,sha256=-h0sesZ9kJlHnXU645Jmgbo-DA2BMVqfTZu7b8pCbiQ,1163
|
39
|
+
betterproto2_compiler-0.0.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
40
|
+
betterproto2_compiler-0.0.3.dist-info/entry_points.txt,sha256=DE80wLfBwKlvu82d9pAYzEo7Cp22WNqwU7WJZq6JAWk,83
|
41
|
+
betterproto2_compiler-0.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{betterproto2_compiler-0.0.1.dist-info → betterproto2_compiler-0.0.3.dist-info}/entry_points.txt
RENAMED
File without changes
|