Skip to content
Draft
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
471 changes: 302 additions & 169 deletions src/betterproto/__init__.py

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/betterproto/compile/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ def get_type_reference(
elif source_type == ".google.protobuf.Timestamp":
return "datetime"

elif source_type == ".google.protobuf.Value":
# TODO replace `Any` with recursive type in self-reference
return "Union[None, int, float, str, bool, Dict[str, AnyType], List[AnyType]]"

elif source_type == ".google.protobuf.ListValue":
# TODO replace list item with Value type
return "List[Union[None, int, float, str, bool, Dict[str, AnyType], List[AnyType]]]"

elif source_type == ".google.protobuf.Struct":
# TODO replace `Any` with Value type
return "Dict[str, AnyType]"

elif source_type == ".google.protobuf.NullValue":
return "None"

source_package, source_type = parse_source_type_name(source_type)

current_package: List[str] = package.split(".") if package else []
Expand Down
Loading