types-aiobotocore-lite

3.4.0 · active · verified Fri Apr 17

types-aiobotocore-lite provides lite type annotations for the `aiobotocore` library, version 3.4.0. It offers Mypy-compatible stubs for a common subset of AWS services, generated by `mypy-boto3-builder`. The project maintains a frequent release cadence, often aligning with `aiobotocore` and `mypy-boto3-builder` updates.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `aiobotocore` with `types-aiobotocore-lite` installed. The type hints for `S3Client`, `CreateBucketRequestRequestTypeDef`, and `CreateBucketOutputTypeDef` are provided by the stub package. To verify type checking, run `mypy your_script_name.py` after installing `aiobotocore` and `types-aiobotocore-lite`.

import asyncio
from aiobotocore.session import get_session
from typing import TYPE_CHECKING, Dict, Any

# These imports are for type checking only and won't be executed at runtime
if TYPE_CHECKING:
    # Example: S3Client is made available by types-aiobotocore-lite for common services
    from types_aiobotocore_s3.client import S3Client
    from types_aiobotocore_s3.type_defs import CreateBucketRequestRequestTypeDef, CreateBucketOutputTypeDef

async def create_s3_bucket(bucket_name: str) -> Dict[str, Any]:
    session = get_session()
    async with session.create_client("s3") as client:  # type: S3Client
        # Now 'client' is type-checked as S3Client
        request_params: CreateBucketRequestRequestTypeDef = {
            "Bucket": bucket_name
        }
        response: CreateBucketOutputTypeDef = await client.create_bucket(**request_params)
        print(f"Bucket '{bucket_name}' created: {response}")
        return response

async def main():
    # Replace with a unique bucket name, AWS credentials must be configured
    await create_s3_bucket("my-unique-test-bucket-12345")

if __name__ == "__main__":
    # Make sure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set in your environment
    # or ~/.aws/credentials is configured.
    asyncio.run(main())

view raw JSON →