Type annotations for aioboto3. Adds code completion in IDEs such as PyCharm.
aioboto3 Type Hints
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 - https://github.com/alliefitter/boto3_type_annotations
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
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 - https://github.com/vemel/mypy_boto3
pip install aioboto3-hints
pip install aioboto3-hints-docs
Regardless of which deployment package you install, you'll still import the same package,
Its constituent packages and modules can be used to declare the type of
aioboto3 objects. For instance, everybody's
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'): print(response) 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') asyncio.run(main()) # 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
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|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|
Hashes for aioboto3_hints-0.4.0-py3-none-any.whl