At Wavycloud we use Amazon Web Services (AWS) to run our service and we use boto3 to manage and automate our infrastructure as well as using it in our Lambda microservices.
One caveat to boto3 is the lack of autocomplete, which means you will have to open boto3 documentation every time you use it just to copy those long function and parameter names.
We decided to fix that by creating pyboto3. We used BeautifulSoup to parse the documentation of boto3 and generate python stub files that will give hint to your IDE.
Here is what will happen when u click ctrl+space after you install pyboto3 and annotate boto3 client.
😮 😮 😮 😮 😮 crazy cool right?
Here is how you can enable this feature.
pip install pyboto3
import boto3 s3 = boto3.client('s3') """ :type : pyboto3.s3 """ # s3. will give you autocomplete for s3 methods
This is currently limited to boto3 clients and doesn’t work for resources like Paginators, Waiters, Table, etc.
This was currently tested on PyCharm and it worked like a charm. Let us know if it doesn’t work for your favorite IDE.
Sad I was not able to make this work in Visual Studio Code even try putting the path to this in the settings:
“python.autoComplete.extraPaths”: [
“/usr/local/lib/python2.7/site-packages/pyboto3”
]
Anyone made it work in VS Code? I will try more but really do not know how tis really works to start with. 🙂
LikeLike
Can you show how you annotated the client?
LikeLike
Any help would be great. I not even clear what you mean by that. LOL
LikeLike
First install pyboto3, then after you create the client, for example:
S3 = boto3.client(‘s3’)
“”” :type : pyboto3.s3 “””
Without the type annotation, autocomplete will not work.
LikeLiked by 1 person
I did miss that part and just tried it in both VSC and PYCharm and no luck ☹ Can it be due to versions of boto3?
https://puu.sh/tE7XE/e0419b7802.png
Mark
From: WavyCloud Blog
Reply-To: WavyCloud Blog
Date: Saturday, January 28, 2017 at 11:44 AM
To: “Hubers, Mark”
Subject: [New comment] Boto3 + Pyboto3 = Autocomplete = ❤︎
Gehad Shaat commented: “First install pyboto3, then after you create the client, for example: S3 = boto3.client(‘s3’) “”” :type : pyboto3.s3 “”” Without the type annotation, autocomplete will not work.”
LikeLike
BTY in that bitmap I had forgot to send both. One had where i was using s3 not d3 to show both give me the same listing.
LikeLike
Did u install pyboto3? Try importing pyboto3 before boto3
import pyboto3.s3
Let me know the result
LikeLike
Added import pyboto3.s3 or import pyboto3 and no luck but it warns me saying module does not exist in PYCherm IDE.
└> pip install pyboto3
Requirement already satisfied: pyboto3 in /usr/local/lib/python2.7/site-packages
Maybe this is due to python 2.7. We can forget this unless you like to keep debugging with me.
From: WavyCloud Blog
Reply-To: WavyCloud Blog
Date: Saturday, January 28, 2017 at 12:45 PM
To: “Hubers, Mark”
Subject: [New comment] Boto3 + Pyboto3 = Autocomplete = ❤︎
Gehad Shaat commented: “Did u install pyboto3? Try importing pyboto3 before boto3 import pyboto3.s3 Let me know the result”
LikeLike
If you do “import pyboto3” and pycharm doesnt recognize it then autocomolete wont work.
Try going to settings->python interpreter and check what python version is selected and install pyboto3 from there
LikeLike
Yes I did pip install pyboto3 long ago (first thing I did) and re-ran it to show that it said that it already installed.
LikeLike
Do you know if this works with Pydev in eclipse? I did the following and it doesn’t work:
import pyboto3
import boto3
s3 = boto3.client(‘s3’)
“”” :type: pyboto3.s3 “””
s3.
LikeLike
haven’t tried it on Pydev. Could you try s3 as function parameter like in http://www.pydev.org/manual_adv_type_hints.html
LikeLike
Sorry, I don’t understand how to try that..
LikeLike
Does this work?
l = boto3.client(‘lambda’)
“”” :type : pyboto3.lambda “””
LikeLike
This should work, just add underscore
l = boto3.client(‘lambda’)
“”” :type : pyboto3.lambda_ “””
LikeLike
Hey guys, great plugin for pyCharm. Any one knows how to make it work in Atom?
I hava auto-complete python installed and correct path set.
Cheers
LikeLike
We haven’t tested it in Atom.
LikeLike
I didn’t understand: was it supposed to work on Visual Studio Code or not? I was not able to make it work, so I’m wondering if it’s my fault or if it doesn’t work at all on that IDE. Thanks!
LikeLike
It was only tested on Pycharm because it understand type hinting. Let us know if u got it to work on Visual Studio.
LikeLike
I like using Cloud9 but pyboto3 doesn’t work there. It works fine on PyCharm thought.
LikeLike