How to get code completion with 'weird' libraries?

I have some code:

import googlemaps

api_key = 'abcde'
gmaps = googlemaps.Client(key=api_key)
coordinates = (12.0, 22.0)
v = gmaps.reverse_geocode(coordinates)

 

Which causes an error:

'Unresolved attribute reference 'reverse_geocode' for class 'Client'

I also don't get proper code completion when I type 'gmaps.'

 

Note that this is not a problem that is solved by invalidating caches. I lost the link, but I read that it has to do with the way that the library is structured. The source code for the class (https://github.com/googlemaps/google-maps-services-python/blob/master/googlemaps/client.py) does not contain the functions that should appear in the code completion. So it's not strange that Pycharm does not recognize them. Instead, these functions are imported from elsewhere (line 337 for the reverse_geocoding function).

 

Now my question is: How can I still get code completion so that when I type 'gmaps.' I get suggestions for the functions 'directions', 'distance_matrix', 'elevation_along_path' et cetera?

 
0
2 comments

Hi,

Is the code being executed without errors? If yes, I suggest reporting this false positive to the issue tracker https://youtrack.jetbrains.com

0
Avatar
Permanently deleted user

Yes, the code executes without errors. I have submitted an issue: https://youtrack.jetbrains.com/issue/PY-38998

0

Please sign in to leave a comment.