Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit df716e2

Browse files
committed
Remove __post_init__ from MessageCompiler
1 parent 2e25d9b commit df716e2

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/betterproto2_compiler/plugin/models.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,6 @@ class MessageCompiler(ProtoContentBase):
269269
oneofs: list["OneofCompiler"] = field(default_factory=list)
270270
builtins_types: set[str] = field(default_factory=set)
271271

272-
def __post_init__(self) -> None:
273-
# Add message to output file
274-
if isinstance(self.parent, OutputTemplate):
275-
if isinstance(self, EnumDefinitionCompiler):
276-
self.output_file.enums[self.proto_name] = self
277-
else:
278-
self.output_file.messages[self.proto_name] = self
279-
super().__post_init__()
280-
281272
@property
282273
def proto_name(self) -> str:
283274
return self.proto_obj.name

src/betterproto2_compiler/plugin/parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ def read_protobuf_type(
192192
path=path,
193193
typing_compiler=output_package.typing_compiler,
194194
)
195+
output_package.messages[message_data.proto_name] = message_data
196+
195197
for index, field in enumerate(item.field):
196198
if is_map(field, item):
197199
MapEntryCompiler(
@@ -235,13 +237,14 @@ def read_protobuf_type(
235237

236238
elif isinstance(item, EnumDescriptorProto):
237239
# Enum
238-
EnumDefinitionCompiler(
240+
enum = EnumDefinitionCompiler(
239241
source_file=source_file,
240242
parent=output_package,
241243
proto_obj=item,
242244
path=path,
243245
typing_compiler=output_package.typing_compiler,
244246
)
247+
output_package.enums[enum.proto_name] = enum
245248

246249

247250
def read_protobuf_service(

0 commit comments

Comments
 (0)