Skip to content

Conversation

kasegao
Copy link

@kasegao kasegao commented Sep 1, 2024

close #62

The original logic had issues generating import statements in some cases where only the intermediate paths matched (for details, please see issue #62).

This PR contains two changes.
First, it fixes the relative import bug described in #62.
Second, it makes sure that imports are relative even when importing from the root. This helps with path resolution when importing generated code from the destination project.

Comment on lines +109 to +110
else:
break
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the parent paths are different, the loop should exit.

module_name = ".".join(message_path_list[index + 1 : -1] + (module_name,))

logger.info((self._fd.name, other_fd.name, index))
if index != -1:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When importing generated files from the destination project, paths should always be relative, even if they start from the root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The generation logic for import statements has issues in some cases

1 participant