8000 Fix for broken relative imports and missing betterproto_lib_google_protobuf · Issue #472 · danielgtaylor/python-betterproto · GitHub
[go: up one dir, main page]

Skip to content

Fix for broken relative imports and missing betterproto_lib_google_protobuf #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BananaLoaf opened this issue Mar 31, 2023 · 2 comments

Comments

@BananaLoaf
Copy link

The issue affects both relative imports and google.protobuf imports, but is not 100% reproducible.

My working theory is that for service method input types output_package.imports sometimes populates too late to be included in the imports section of a generated file. The list is populated only when template is compiled with method.py_input_message_param which comes way after the import section.

On the contrary, imports for output types are figured out before template compilation in ServiceMethodCompiler:__post__init__ by using self.py_output_message_type

Fix is to add

if "Optional" in self.py_input_message_type:
    self.output_file.typing_imports.add("Optional")

I have only checked it with google.protobuf types, but I suspect that relative imports behave no different and this issue is related to #441

@Dimitrioglo
Copy link

Hello guys @danielgtaylor, @Gobot1234,

can you add please this fix in new beta version?
It has huge impact to generated code, i needed to fork your repo to proceed with python interfaces generating for proto files. It's fixes a lot missing return types import errors

@Gobot1234
Copy link
Collaborator

I can't fix issues myself with a fast turnaround due to needing a review from a collaborator. If you open a PR with the fix I can take a look

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

No branches or pull requests

3 participants
0