Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Type annotations for aioboto3. Adds code completion in IDEs such as PyCharm.

Project description

aioboto3 Type Hints

PyPi Version Build Status PyUp Updates

All of the credit goes to Allie Fitter who did all of the hard work, I've just repurposed his repo to generate async type hints

Upstream repo -

With or Without Docstrings

This package is available both with docstrings, named aioboto3-hints-docs on PyPi (which contains the same documentation you'll find online), and without, named aioboto3-hints on PyPi. The reason for this is that, for a python package, aioboto3-hints-docs is HUGE. aioboto3-hints is pretty large itself at 2.2 MB, but aioboto3-hints-with-docs dwarfs it at 41 MB. Both of the packages contain a module aioboto3_hints so you can swap out the libraries between local testing and going to production with ease.


Am planning to add in work to reflect some work done by vemel here -


Without docs:

pip install aioboto3-hints

With docs:

pip install aioboto3-hints-docs


Regardless of which deployment package you install, you'll still import the same package, aioboto3_hints. Its constituent packages and modules can be used to declare the type of aioboto3 objects. For instance, everybody's favorite, S3:

import asyncio
import boto3
from aioboto3_hints.s3 import Client, ServiceResource
from aioboto3_hints.s3.waiter import BucketExists
from aioboto3_hints.s3.paginator import ListObjectsV2

# With type annotations
async def main():
    client: Client = boto3.client('s3')
    await client.create_bucket(Bucket='foo')  # Not only does your IDE knows the name of this method, 
                                              # it knows the type of the `Bucket` argument too!
                                              # It also, knows that `Bucket` is required, but `ACL` isn't!

    # Waiters and paginators and defined also...
    waiter: BucketExists = client.get_waiter('bucket_exists')
    await waiter.wait('foo')

    paginator: ListObjectsV2 = client.get_paginator('list_objects_v2')
    async for response in paginator.paginate(Bucket='foo'):

    await client.close()

    # Along with service resources.
    resource: ServiceResource = boto3.resource('s3')
    bucket = resource.Bucket('bar')
    await bucket.create()

    await resource.close()

    # With type comments
    async with boto3.client('s3') as client:  # type: Client
        response = await client.get_object(Bucket='foo', Key='bar')

    # This should also work
    client: Client
    async with boto3.client('s3') as client:
        response = await client.get_object(Bucket='foo', Key='bar')    

# In docstrings
class Foo:
    def __init__(self, client):
        :param client: It's an S3 Client and the IDE is gonna know what it is!
        :type client: Client
        self.client = client

    async def bar(self):
        :rtype: Client
        await self.client.delete_object(Bucket='foo', Key='bar')
        return self.client

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aioboto3-hints, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size aioboto3_hints-0.4.0-py3-none-any.whl (348.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size aioboto3-hints-0.4.0.tar.gz (156.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page