Skip to content

Commit eb5a818

Browse files
authored
Merge pull request #78 from Alfredx/patch__add_other_module_pkg
fix relative path generate logic
2 parents 1570c83 + bc7bcf3 commit eb5a818

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

protobuf_to_pydantic/plugin/field_desc_proto_to_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def _add_other_module_pkg(self, other_fd: FileDescriptorProto, type_str: str) ->
112112
module_name = ".".join(message_path_list[index + 1 : -1] + (module_name,))
113113

114114
logger.info((self._fd.name, other_fd.name, index))
115-
if index != -1:
116-
# Add relative parts: ..b.include_p2p
117-
module_name = "." * (len(message_path_list) - (index + 1)) + module_name
115+
# Add relative parts: ..b.include_p2p
116+
# Always use relative parts
117+
module_name = "." * (len(fd_path_list) - (index + 1)) + module_name
118118
self._add_import_code(module_name, type_str)
119119

120120
def _comment_handler(self, leading_comments: str, trailing_comments: str) -> Tuple[dict, str, str]:

0 commit comments

Comments
 (0)