boto3-stubs-lite

1.42.88 · active · verified Sun Apr 12

boto3-stubs-lite provides lightweight type annotations for the boto3 library (version 1.42.88 at time of writing), generated by mypy-boto3-builder. It enhances static analysis for boto3 code without requiring installation of full service-specific stub packages, receiving frequent updates aligned with boto3 and mypy-boto3-builder releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic boto3 client usage. When `boto3-stubs-lite` is installed, type checkers like MyPy will provide type hints and error checking for `session`, `s3_client`, and their methods, even without explicit type imports.

import boto3
import os

# boto3-stubs-lite provides type hints for this standard boto3 usage
session = boto3.session.Session(
    aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
    aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
    region_name=os.environ.get('AWS_REGION', 'us-east-1')
)

s3_client = session.client('s3')

try:
    # This call is type-checked by boto3-stubs-lite
    response = s3_client.list_buckets()
    print(f"Successfully listed {len(response.get('Buckets', []))} buckets.")
except Exception as e:
    print(f"Error listing buckets: {e}")

# Example of using a resource (also typed)
# s3_resource = session.resource('s3')
# bucket = s3_resource.Bucket('my-example-bucket')
# print(f"Bucket name: {bucket.name}")

view raw JSON →