-
Notifications
You must be signed in to change notification settings - Fork 8
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
Issue 850 fix imports in pyi files #851
base: main
Are you sure you want to change the base?
Issue 850 fix imports in pyi files #851
Conversation
@juraj-juraj Sorry for the delay! Would you mind adding a test case, or describing it here if you don't want to do that? |
@cpcloud This change basically adds an import statement. So because of that, the tests will fail. I think to test this enough would be to just fix the tests. Sadly I wasn't able to make tests work, otherwise I would've done it. |
Ok, I can take a look at the failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently generating invalid Python code.
0004eed
to
4047fc2
Compare
Ok, I got the tests passing, but I think the rules are incorrect. The rewrite should only apply to |
@juraj-juraj can you paste here the following:
From those I can build a test to verify the desired behavior |
I'm including whole hierarchy of protofiles used protofiles.zip. The bug is only apparent in pyi files, where import simply isn't fixed. The rule which I introduced applies to all files, not just .pyi. I didn't know whether it would break something, and it worked for me. So that's why it is fixed like it is. python3 -m grpc_tools.protoc -I./ --python_out=./src/phx_grpc_interface --grpc_python_out=./src/phx_grpc_interface --pyi_out=./src/phx_grpc_interface ./phonexia/common/core.proto ./phonexia/common/health_check.proto ./phonexia/technologies/genderid/v1beta/gid.proto ./phonexia/technologies/speakerid/v1beta/sid.proto The protol invocation: protol -o ./src/phx_grpc_interface --in-place protoc --proto-path=./ ./phonexia/common/core.proto ./phonexia/common/health_check.proto ./phonexia/technologies/genderid/v1beta/gid.proto ./phonexia/technologies/speakerid/v1beta/sid.proto |
Just stumbled upon this issue in one of our projects. The proposed rewrite rule doesn't seem right:
There is no bare But the bigger problem is that this change does not account for name collisions. Imagine that you have packages
The |
👋 What is the conclusion here? |
This pull request fixes issue #850.
Imports in pyi file generated by grpc_tools.protoc are different, thus rewrite rules do not catch it.
New rule was added to account for that.