Type Annotations for aiobotocore

3.4.0 · active · verified Thu Apr 09

types-aiobotocore provides PEP 561 compliant type annotations for the `aiobotocore` library, enabling static type checking for asynchronous AWS client interactions. It helps catch type-related errors before runtime and improves IDE autocompletion. The current version is 3.4.0, and new versions are released frequently, tied to updates in the `mypy-boto3-builder` and `aiobotocore` itself.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `aiobotocore` to list S3 buckets. By installing `types-aiobotocore` (and potentially `types-aiobotocore-s3`), your static type checker (like MyPy) will understand the types of `session` and `client`, providing autocompletion and error checking without altering the runtime code. Note that `aiobotocore` itself must be installed.

import asyncio
from aiobotocore.session import get_session

async def main():
    session = get_session()
    # `types-aiobotocore` provides type stubs for the session and client.
    # For S3 specific types, you would also install `types-aiobotocore-s3`.
    async with session.create_client("s3") as client:
        response = await client.list_buckets()
        print("S3 Buckets:", [b["Name"] for b in response.get("Buckets", [])])

if __name__ == "__main__":
    asyncio.run(main())

view raw JSON →