Skip to content

Commit

Permalink
Merge pull request #39 from so1n/38-missing-typing-import-for-optiona…
Browse files Browse the repository at this point in the history
…l-field

Fix: fix missing typing import for optional field
  • Loading branch information
so1n authored Feb 12, 2024
2 parents 7a52683 + 01c5a3f commit 78ccb12
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion protobuf_to_pydantic/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "v0.2.2"
__version__ = "0.0.0"
2 changes: 2 additions & 0 deletions protobuf_to_pydantic/plugin/field_desc_proto_to_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ def _message_field_handle(
value_type_str = self._get_value_code(map_type_dict["values"])
else:
value_type_str = self._get_protobuf_type_model(message.field[1]).py_type_str
self._add_import_code("typing")
type_str = f"typing.Dict[{key_type_str}, {value_type_str}]"

# custom field support
Expand All @@ -308,6 +309,7 @@ def _message_field_handle(
field_param_dict_migration_v2_handler(field_info_dict, is_warnings=False)

if optional_dict.get(field.name, {}).get("is_proto3_optional", False):
self._add_import_code("typing")
type_str = f"typing.Optional[{type_str}]"
if field_info_dict.get(
"default", _pydantic_adapter.PydanticUndefined
Expand Down

0 comments on commit 78ccb12

Please sign in to comment.