fix(pubsub): preserve publisher method type annotations - #18106
fix(pubsub): preserve publisher method type annotations#18106ishaangandhi wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request simplifies retry and timeout type definitions in the Google Cloud Pub/Sub library, including direct imports of timeout classes and updating type annotations for publisher requests. The feedback suggests using Dict instead of dict for backward compatibility and consistency, and simplifying the TimeoutType definition by removing the redundant int type hint since float already encompasses it.
56a192f to
d8c4582
Compare
| OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] | ||
| except AttributeError: # pragma: NO COVER | ||
| OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore | ||
| OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] |
There was a problem hiding this comment.
Thanks for looking into cleaning up these type annotations!
You're right that with "google-api-core[grpc] >= 2.25.0, <3.0.0", gapic_v1.method._MethodDefault is guaranteed to exist at runtime, making the try/except AttributeError fallback obsolete here.
However, because the files under google/pubsub_v1/ are automatically generated, manual edits will be overwritten during the next generator run and will introduce drift from the other generated client services (like subscriber/client.py).
Would you be open to proposing this change upstream in the generator templates instead ?
You can update the Jinja template directly here:
The PR should only include changes to packages/gapic-generator because the generator fix must first be merged and released to PyPI before downstream packages like google-cloud-pubsub can be regenerated with the updated version.
Overview