Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "betterproto2_compiler"
version = "0.2.0"
version = "0.2.1"
description = "Compiler for betterproto2"
authors = ["Adrien Vannson <[email protected]>", "Daniel G. Taylor <[email protected]>"]
readme = "README.md"
Expand Down
21 changes: 14 additions & 7 deletions src/betterproto2_compiler/plugin/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,21 @@ def read_protobuf_type(
)
)

for index, oneof in enumerate(item.oneof_decl):
message_data.oneofs.append(
OneofCompiler(
source_file=source_file,
path=path + [8, index],
proto_obj=oneof,
# Synthetic oneofs are generated for optional fields. We should not generate code or documentation for them.
is_synthetic_oneof = [True for _ in item.oneof_decl]
for field in item.field:
if field.oneof_index is not None and not field.proto3_optional:
is_synthetic_oneof[field.oneof_index] = False

for index, (oneof, is_synthetic) in enumerate(zip(item.oneof_decl, is_synthetic_oneof)):
if not is_synthetic:
message_data.oneofs.append(
OneofCompiler(
source_file=source_file,
path=path + [8, index],
proto_obj=oneof,
)
)
)

elif isinstance(item, EnumDescriptorProto):
# Enum
Expand Down
Loading