boto3-stubs-full

1.42.88 · active · verified Mon Apr 13

boto3-stubs-full provides comprehensive type annotations (stubs) for the dynamically typed boto3 library, enhancing static analysis, IDE autocompletion, and early error detection for AWS Python development. It is generated by `mypy-boto3-builder` and currently supports boto3 version 1.42.88. The project maintains an active release cadence, typically aligning with boto3 updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates using `boto3-stubs-full` with a standard boto3 S3 client. After installing `boto3-stubs-full`, your IDE and static type checkers like MyPy will automatically provide type hints for `boto3` calls. For explicit type annotations, `mypy_boto3_s3.client.S3Client` is imported conditionally for type-checking only.

from typing import TYPE_CHECKING
import boto3
import os

# Boto3-stubs-full enhances type checking for standard boto3 usage.
# For explicit type annotations, import service clients within a TYPE_CHECKING block.
if TYPE_CHECKING:
    from mypy_boto3_s3.client import S3Client

def list_s3_buckets(region: str) -> None:
    # Initialize an S3 client. IDEs and type checkers will recognize the type
    # even without explicit type hints if boto3-stubs-full is installed.
    s3_client: S3Client = boto3.client('s3', region_name=region)

    print(f"Listing S3 buckets in {region}:")
    try:
        response = s3_client.list_buckets()
        for bucket in response.get('Buckets', []):
            print(f"- {bucket['Name']}")
    except Exception as e:
        print(f"Error listing buckets: {e}")

if __name__ == "__main__":
    aws_region = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
    list_s3_buckets(aws_region)

view raw JSON →