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

Generated code for Pub/Sub does not pass type checks with mypy #1092

Closed
plamut opened this issue Nov 18, 2021 · 1 comment
Closed

Generated code for Pub/Sub does not pass type checks with mypy #1092

plamut opened this issue Nov 18, 2021 · 1 comment
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@plamut
Copy link
Contributor

plamut commented Nov 18, 2021

Running mypy on the Python Pub/Sub client produces several type check errors.

The errors in the manually written code will be handled by googleapis/python-pubsub#536, but even the generated code produces a few errors on its own. The generator should produce code that passes mypy checks (currently only pytype is used).

In the scope of either this or a stand-alone issue, it would also make sense to add a mypy CI check for the generated code (not just the code of the generator itself) to avoid future type-check regressions.

Reproduction

Clone the google-cloud-python repo into a virtual environment, install the Pub/Sub library in editable mode, and then run the commands seen in the "sample output" section.

Versions:

pytype==2021.4.9
google-cloud-pubsub==2.9.0

Sample output:

$ pip install pytype==2021.4.9
$ pip install types-protobuf types-setuptools
$ python -m mypy google/pubsub_v1
google/pubsub_v1/types/__init__.py:82: error: Name "google" is not defined
google/pubsub_v1/types/__init__.py:83: error: Name "google" is not defined
google/pubsub_v1/services/subscriber/client.py:46: error: Skipping analyzing "grpc": found module but no type hints or library stubs
google/pubsub_v1/services/subscriber/client.py:405: error: Incompatible types in assignment (expression has type "partial[SubscriberTransport]", variable has type "Type[SubscriberTransport]")
google/pubsub_v1/services/subscriber/client.py:1175: error: "Callable[[StreamingPullRequest], Union[StreamingPullResponse, Awaitable[StreamingPullResponse]]]" has no attribute "_prefetch_first_result_"
google/pubsub_v1/services/publisher/client.py:46: error: Skipping analyzing "grpc": found module but no type hints or library stubs
google/pubsub_v1/services/publisher/client.py:46: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
google/pubsub_v1/services/publisher/client.py:403: error: Incompatible types in assignment (expression has type "partial[PublisherTransport]", variable has type "Type[PublisherTransport]")
Found 7 errors in 3 files (checked 29 source files)
@plamut plamut added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Nov 18, 2021
@parthea parthea self-assigned this Nov 30, 2021
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Feb 28, 2022
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label May 17, 2022
@parthea
Copy link
Contributor

parthea commented May 18, 2022

These warning do not appear to be part of the auto generated code. I'll reply on googleapis/python-pubsub#536.

@parthea parthea closed this as completed May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants