googleapis / google-cloud-python

Google Cloud Client Library for Python
https://googleapis.github.io/google-cloud-python/
Apache License 2.0
4.81k stars 1.52k forks source link

Skeletons / proper typing missing for this kind of code synthesis #11865

Open doctorpangloss opened 6 years ago

doctorpangloss commented 6 years ago

https://github.com/GoogleCloudPlatform/google-cloud-python/blob/c2a7bffb11425d9c5e98425f8282866a7c7fd634/vision/google/cloud/vision_helpers/decorators.py#L18

Do you think you could commit a valid, simple set of methods that will appear in IDE autocompletes like PyCharm?

It would greatly improve usability of your cloud APIs.

The test is pretty simple:

  1. Open a blank project in PyCharm 2018.
  2. Use a virtualenv with google-vision-api (for example) installed.
  3. Start following a quick start.
  4. Observe no methods can be found on the ImageAnnotatorClient object, for example.

Maybe the equivalent of https://github.com/jbasko/autoboto ?

diegogr-cit commented 4 years ago

Hi,

There is some plan to do better support to IDE autocomplete/IntelliSense/lints with those clients? E.g. @_gapic.add_methods on the clients makes this on vscode:

 from google.cloud import pubsub_v1

client = pubsub_v1.SubscriberClient()
client.subscription_path(project_id, sub_id) < (1)
#(1) Instance of 'SubscriberClient' has no 'subscription_path' member
danielcressman commented 3 years ago

This is still an issue. Any of the methods dynamically added to ImageAnnotatorClient by the add_single_feature_methods decorator throw errors in pylint when used:

Code:

    3 from google.cloud import vision
    4
...
   11
   12 image = vision.Image(content=content)
   13
>> 14 response = client.label_detection(image=image)

Error:

(env) [dcressman ~/projects/vision-api-test] pylint test.py
************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:15:11: E1101: Instance of 'ImageAnnotatorClient' has no 'label_detection' member (no-member)

------------------------------------------------------------------
Your code has been rated at 5.38/10 (previous run: 5.00/10, +0.38)

If this is too difficult/not worth it to fix, can we at least try to call it out explicitly somewhere that pylint will not work out of the box? I figure that may save a lot of people some time.

parthea commented 11 months ago

I'm going to transfer this issue to google-cloud-python as we're planning to move the code for google-cloud-vision there in the next 1-2 weeks