python-jedi

Jedi Not Working With boto3 Library


I am trying to get jedi working properly with the boto3 library for Amazon Web Services ( https://github.com/boto/boto3 ).

It's probably easiest to explain with an example:

$ python
Python 3.4.3 (default, Jul 16 2015, 13:03:44) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> sqs = boto3.resource("sqs", region_name="us-west-2")
>>> sqs.<TAB><TAB>
sqs.Message(            sqs.__dict__            sqs.__format__(
sqs.__hash__            sqs.__module__          sqs.__reduce_ex__(
sqs.__str__(            sqs.get_queue_by_name(
...
>>> type(sqs)
<class 'boto3.resources.factory.sqs'>
>>> 

On the interactive interpreter, I get proper completion for the class. Enter jedi:

>>> import jedi
>>> jedi.__version__
'0.9.0'
>>> jedi.Script('import boto3; sqs = boto3.resou').completions()
[<Completion: resource>, <Completion: resources>]
>>>

Still working here! But then...

>>> code = 'import boto3; sqs = boto3.resource("sqs", region_name="us-west-2"); sqs.'
>>> jedi.Script(code).completions()
[]
>>> 

I'm not sure whether this is my fault, the library's or jedi's.

EDIT: Seems that PyCharm has the same problem: PyCharm intellisense for boto3


Solution

  • Courtesy of jamesls (from the PyCharm question https://stackoverflow.com/a/31681988/3236648 ):

    This is happening because all of the methods on the boto3 clients and resource objects are generated at runtime based on a JSON file that describes what operations the service supports. Pycharm would have to have specific knowledge about this process in order to auto complete method names.