You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The _add_other_module_pkg function in protobuf_to_pydantic/plugin/field_desc_proto_to_code.py has issues in some cases. Specifically, in cases where the top-level paths are different and the intermediate paths match, the generated relative import paths are not appropriate.
To Reproduce
Consider the following directory structure. Both files share the intermediate path v1.
However, the import statement in the first line of app/v1/app_p2p.py fails to resolve the relative path correctly.
from .types_p2pimportUserType
Expected behavior
I suggest specifying the path from the project root instead of using a relative path. In that case, the previously mentioned import statement should preferably be
fromshared.v1.types_p2pimportUserType
Expectied import path:
from ...shared.v1.types_p2pimportUserType
Desktop (please complete the following information):
OS: macOS Sonoma 14.5
Version MacBook Pro M3 Max (2023)
The text was updated successfully, but these errors were encountered:
Thank you very much for your feedback. There is no problem with this code in the current example proto. Can you add the corresponding proto to the example in the project and execute it? It would be great if you could add corresponding test cases @kasegao
Describe the bug
The
_add_other_module_pkg
function inprotobuf_to_pydantic/plugin/field_desc_proto_to_code.py
has issues in some cases. Specifically, in cases where the top-level paths are different and the intermediate paths match, the generated relative import paths are not appropriate.To Reproduce
Consider the following directory structure. Both files share the intermediate path
v1
.. ├─ app/v1/app.proto └─ shared/v1/types.proto
app/v1/app.proto
shared/v1/types.proto
When generating Pydantic code for these files, the following files are created:
app/v1/app_p2p.py
shared/v1/types_p2p.py
However, the import statement in the first line of
app/v1/app_p2p.py
fails to resolve the relative path correctly.Expected behavior
I suggest specifying the path from the project root instead of using a relative path. In that case, the previously mentioned import statement should preferably beExpectied import path:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: