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

Pub/Sub: mistake in publisher client example #6334

Closed
anguillanneuf opened this issue Oct 29, 2018 · 3 comments
Closed

Pub/Sub: mistake in publisher client example #6334

anguillanneuf opened this issue Oct 29, 2018 · 3 comments
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. type: docs Improvement to the documentation for an API.

Comments

@anguillanneuf
Copy link
Contributor

It should have been from google.cloud.pubsub_v1 import PublisherClient in this line:

>>> from google.cloud.pubsub_v1 import publisher_client

@tseaver tseaver added api: pubsub Issues related to the Pub/Sub API. type: docs Improvement to the documentation for an API. labels Oct 30, 2018
@tseaver
Copy link
Contributor

tseaver commented Oct 30, 2018

@anguillanneuf Is the example a mistake, or is it just a question of style? The next line uses the module-qualified name:

>>> from google.cloud.pubsub_v1 import publisher_client
>>> client = publisher_client.PublisherClient()

Some folks prefer "import only modules" as a practice (I'm not one of them, but the usage doesn't bother me, either).

@anguillanneuf
Copy link
Contributor Author

There is no publisher_client in google.cloud.pubsub_v1 in google-cloud-pubsub==0.38.0.

Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud.pubsub_v1 import publisher_client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'publisher_client'
>>> from google.cloud.pubsub_v1 import PublisherClient
>>> 

@tseaver tseaver self-assigned this Oct 30, 2018
@tseaver
Copy link
Contributor

tseaver commented Oct 30, 2018

OK, the docstrings in the generated code all use this pattern:

>>> from google.cloud import pubsub_v1
>>> publisher_client = pubsub_v1.PublisherClient()

I will fix in the hand-written docstrings for pubsub_v1.publisher.client.Client.publish, as well as in pubsub_v1.subcriber.client.Client.subscribe, which has a similar problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. type: docs Improvement to the documentation for an API.
Projects
None yet
Development

No branches or pull requests

2 participants