Skip to content

Commit

Permalink
Merge pull request #7 from aidanjakes/main
Browse files Browse the repository at this point in the history
Handle empty proto messages
  • Loading branch information
Ed-XCF authored Dec 21, 2023
2 parents d184c11 + 7073f33 commit dab989b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion protobuf2pydantic/biz.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def convert_field(level: int, field: FieldDescriptor) -> str:

def msg2pydantic(level: int, msg: Descriptor) -> str:
class_statement = f"{tab * level}class {msg.name}(BaseModel):"
field_statements = map(partial(convert_field, level), msg.fields)
if msg.fields:
field_statements = map(partial(convert_field, level), msg.fields)
else:
field_statements = [tab + "pass"]
return linesep.join([class_statement, *field_statements])


Expand Down

0 comments on commit dab989b

Please sign in to comment.