Skip to content
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

googleapis-common-protos is now using native namespace packages #8

Closed
sevein opened this issue Jan 22, 2024 · 5 comments
Closed

googleapis-common-protos is now using native namespace packages #8

sevein opened this issue Jan 22, 2024 · 5 comments

Comments

@sevein
Copy link

sevein commented Jan 22, 2024

The README in this project reads:

Note that if you're using Mypy you need to use the --namespace-packages option as google and some of its subpackages are namespace packages.

I wanted to bring up that the warning above may have to be updated somehow given that googleapis-common-protos v1.62.0 has been migrated to native namespace packages. Related issue: googleapis/python-api-common-protos#187.

For me this change caused this error when running mypy after the upgrade:

error: Module "google.rpc" has no attribute "code_pb2"  [attr-defined]

I had to make this change to fix it:

[tool.mypy]
-namespace_packages = true
+namespace_packages = false

Thank you for this project, @henribru!

@henribru
Copy link
Owner

Thanks for the heads up! I'm having some trouble reproducing this issue, unfortunately. Is it failing at a simple import google.rpc.code_pb2/from google.rpc import code_pb2? Which version of Mypy are you using? Do you have any other Google packages or stubs for them installed? You don't happen to have your own package called google or somthing like that?

@henribru
Copy link
Owner

One thing I'm noticing is that the PR you linked appears to actually have turned some subpackages that previously were not namespace packages into namespace packges. Namely all the ones with empty removed __init__.pys here: https://github.com/googleapis/python-api-common-protos/pull/187/files I should probably remove the corresponding __init__.pys in my stubs.

google.rpc isn't one of these, but google.rpc.context is. google.rpc also was never declared as a namespace package in setup.py. But not sure if any of that is relevant to the issue you're seeing.

@sevein
Copy link
Author

sevein commented Jan 25, 2024

I'll see if I can find a good way to show how to reproduce, will get back to you soon. Thanks!

@sevein
Copy link
Author

sevein commented Jan 27, 2024

I've just discovered that the problem started happening when I upgraded types-protobuf from 4.24.0.4 to 4.24.0.20240106. I don't understant what the problem is. This may be related: python/typeshed#11254. Feel free to close this issue, sorry for the noise!

@henribru
Copy link
Owner

I'm not able to reproduce it with that version of types-protobuf either, but it sounds plausible for that issue to be the cause. I'll close this, but let me know if it's not resolved after python/typeshed#11254 is fixed and I'll investigate further.

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

2 participants