google-cloud-python icon indicating copy to clipboard operation
google-cloud-python copied to clipboard

Skeletons / proper typing missing for this kind of code synthesis

Open doctorpangloss opened this issue 7 years ago • 3 comments

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 ?

doctorpangloss avatar Sep 13 '18 23:09 doctorpangloss

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

diegogr-cit avatar Nov 11 '19 22:11 diegogr-cit

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.

danielcressman avatar Oct 06 '21 05:10 danielcressman

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

parthea avatar Oct 21 '23 20:10 parthea