Skip to content

Commit

Permalink
Merge pull request #27 from jankatins/patch-2
Browse files Browse the repository at this point in the history
Fix relative includes in case the files are next to each other
  • Loading branch information
so1n authored Nov 2, 2023
2 parents fdab3a3 + 5cf0e59 commit 857c3f9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions protobuf_to_pydantic/plugin/field_desc_proto_to_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ def _add_other_module_pkg(self, other_fd: FileDescriptorProto, type_str: str) ->
for _index in range(min(len(fd_path_list), len(message_path_list))):
if message_path_list[_index] == fd_path_list[_index]:
index = _index
# common/a/name.proto includes common/b/include.proto
# The basic name: include_p2p
module_name: str = message_path_list[-1].replace(".proto", "") + self.config.file_name_suffix
# Add non-shared parts: b.include_p2p
module_name = ".".join(message_path_list[index + 1 : -1] + (module_name,))

module_name: str = (
".".join(message_path_list[index + 1 : -1])
+ "."
+ message_path_list[-1].replace(".proto", "")
+ self.config.file_name_suffix
)
logger.info((self._fd.name, other_fd.name, index))
if index != -1:
# Add relative parts: ..b.include_p2p
module_name = "." * (len(message_path_list) - (index + 1)) + module_name
self._add_import_code(module_name, type_str)

Expand Down

0 comments on commit 857c3f9

Please sign in to comment.