Type Annotations for aiobotocore
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
- breaking Python 3.8 support has been removed as of `mypy-boto3-builder` version 8.12.0 (which generates `types-aiobotocore` 3.4.0). Users on Python 3.8 will need to upgrade to Python 3.9+.
- breaking The builder migrated to PEP 561 compliant packages in version 8.12.0. While this is generally an improvement for type checker discovery, older type checker configurations or specific environments might require re-evaluation of how stub packages are found.
- gotcha This `types-aiobotocore` package specifically provides type stubs for the *core* `aiobotocore` library (e.g., `AioSession`, generic `Client`). For service-specific type stubs (e.g., `S3Client`, `EC2Client`, `ListBucketsOutputTypeDef`), you must install the corresponding service package like `types-aiobotocore-s3`.
- gotcha `types-aiobotocore` only provides type annotations; it does not include the `aiobotocore` runtime library itself. Both must be installed for your code to execute and be type-checked.
Install
-
pip install types-aiobotocore
Imports
- AioSession
from types_aiobotocore.session import AioSession
- Client
from types_aiobotocore.client import Client
Quickstart
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())