boto3-stubs Type Annotations for AWS SDK for Python
raw JSON → 1.42.78 verified Tue May 12 auth: no python install: stale quickstart: stale
boto3-stubs provides comprehensive type annotations for the `boto3` AWS SDK for Python, enabling static type checking with tools like MyPy and PyRight, and enhancing IDE auto-completion. It is generated by `mypy-boto3-builder` and is actively maintained with frequent updates, typically aligning with `boto3` releases to ensure compatibility with the latest AWS services and features.
pip install boto3-stubs Common errors
error Type checker reports boto3 types as 'Any' or 'Unknown' ↓
cause boto3-stubs is either not installed, the installed version is incompatible with your boto3 version, or the type checker isn't configured to use it.
fix
Ensure
boto3-stubs is installed and its version matches your boto3 version (pip install 'boto3-stubs[full]' or pip install 'boto3-stubs[essential]' or specific service stubs like pip install 'boto3-stubs[s3]'), and that your type checker (MyPy/PyRight) is correctly configured in your environment. error AttributeError: 'XServiceResource' object has no attribute 'Y' ↓
cause You are attempting to call a method (Y) on a `boto3.ServiceResource` object that only exists on a `boto3.Client` object (or vice-versa), often due to a misunderstanding of Boto3's client vs. resource interfaces.
fix
Use
boto3.client('service_name') when you need low-level API operations, and boto3.resource('service_name') for object-oriented abstractions, ensuring you call the correct method on the appropriate interface. error AttributeError: 'Client' object has no attribute 'Table' ↓
cause You are trying to access the `Table` method or attribute directly from a DynamoDB `boto3.Client` object, but table operations are typically performed on a `boto3.ServiceResource` object for DynamoDB.
fix
Initialize a DynamoDB resource using
dynamodb_resource = boto3.resource('dynamodb') and then access tables via table = dynamodb_resource.Table('your-table-name'). error Mypy/Pyright warning about unused import or runtime dependency for 'from mypy_boto3_service.client import ServiceClient' ↓
cause You are importing type-specific annotations from `mypy_boto3_*` packages directly without guarding them with `if TYPE_CHECKING:`, making them runtime dependencies instead of compile-time only.
fix
Wrap all
mypy_boto3_* type imports within an if TYPE_CHECKING: block to ensure they are only evaluated by type checkers and not at runtime. Example: from typing import TYPE_CHECKING; if TYPE_CHECKING: from mypy_boto3_s3.client import S3Client. Warnings
breaking Dropped Python 3.8 support. As of `mypy-boto3-builder` version 8.12.0, Python 3.8 is no longer supported for any `boto3-stubs` packages. Projects must use Python 3.9 or newer. ↓
fix Upgrade your Python environment to 3.9 or newer.
breaking Migration to PEP 561 packages. This changes how stubs are packaged and distributed, potentially affecting build systems or direct imports from stub packages. ↓
fix Ensure your project's `pyproject.toml` or `setup.py` correctly references PEP 561-compliant stub packages. Re-evaluate any custom build or packaging logic that interacts directly with stub files.
breaking Service `sms-voice` was removed and replaced by `pinpoint-sms-voice`. If you were using `sms-voice` types, they are no longer generated. ↓
fix Update your code to use the `pinpoint-sms-voice` service and its corresponding types where applicable.
breaking TypeDef naming conventions changed for packed method arguments and conflicting names. TypeDefs like `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`, and `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`. ↓
fix Update explicit TypeDef references in your code to match the new naming conventions.
gotcha This library only provides type annotations. You must still install `boto3` (and `botocore`) for your code to actually run. `boto3-stubs` does not include the AWS SDK itself. ↓
fix Ensure `pip install boto3` is part of your project's dependency management.
gotcha PyCharm's performance can be slow with `Literal` overloads. It is recommended to use `boto3-stubs-lite` or external type checkers (MyPy/PyRight) if you experience high CPU usage or slow performance in PyCharm. ↓
fix Consider installing `boto3-stubs-lite` (`pip install boto3-stubs-lite`) or configure PyCharm to use MyPy/PyRight as the primary type checker.
Install
pip install 'boto3-stubs[s3]' pip install 'boto3-stubs[essential]' pip install boto3-stubs-lite Install compatibility stale last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) essential wheel - - 31.0M
3.10 alpine (musl) s3 wheel - - 20.9M
3.10 alpine (musl) boto3-stubs wheel - - 19.7M
3.10 alpine (musl) boto3-stubs-lite wheel - - 67.9M
3.10 alpine (musl) essential - - - -
3.10 alpine (musl) s3 - - - -
3.10 alpine (musl) boto3-stubs - - - -
3.10 alpine (musl) boto3-stubs-lite - - - -
3.10 slim (glibc) essential wheel 9.4s - 32M
3.10 slim (glibc) s3 wheel 7.6s - 21M
3.10 slim (glibc) boto3-stubs wheel 7.3s - 20M
3.10 slim (glibc) boto3-stubs-lite wheel 7.5s - 139M
3.10 slim (glibc) essential - - - -
3.10 slim (glibc) s3 - - - -
3.10 slim (glibc) boto3-stubs - - - -
3.10 slim (glibc) boto3-stubs-lite - - - -
3.11 alpine (musl) essential wheel - - 33.7M
3.11 alpine (musl) s3 wheel - - 22.9M
3.11 alpine (musl) boto3-stubs wheel - - 21.6M
3.11 alpine (musl) boto3-stubs-lite wheel - - 74.5M
3.11 alpine (musl) essential - - - -
3.11 alpine (musl) s3 - - - -
3.11 alpine (musl) boto3-stubs - - - -
3.11 alpine (musl) boto3-stubs-lite - - - -
3.11 slim (glibc) essential wheel 5.2s - 34M
3.11 slim (glibc) s3 wheel 3.8s - 23M
3.11 slim (glibc) boto3-stubs wheel 3.2s - 22M
3.11 slim (glibc) boto3-stubs-lite wheel 3.1s - 146M
3.11 slim (glibc) essential - - - -
3.11 slim (glibc) s3 - - - -
3.11 slim (glibc) boto3-stubs - - - -
3.11 slim (glibc) boto3-stubs-lite - - - -
3.12 alpine (musl) essential wheel - - 24.8M
3.12 alpine (musl) s3 wheel - - 14.3M
3.12 alpine (musl) boto3-stubs wheel - - 13.1M
3.12 alpine (musl) boto3-stubs-lite wheel - - 64.5M
3.12 alpine (musl) essential - - - -
3.12 alpine (musl) s3 - - - -
3.12 alpine (musl) boto3-stubs - - - -
3.12 alpine (musl) boto3-stubs-lite - - - -
3.12 slim (glibc) essential wheel 3.8s - 25M
3.12 slim (glibc) s3 wheel 2.6s - 15M
3.12 slim (glibc) boto3-stubs wheel 2.5s - 14M
3.12 slim (glibc) boto3-stubs-lite wheel 2.5s - 136M
3.12 slim (glibc) essential - - - -
3.12 slim (glibc) s3 - - - -
3.12 slim (glibc) boto3-stubs - - - -
3.12 slim (glibc) boto3-stubs-lite - - - -
3.13 alpine (musl) essential wheel - - 24.6M
3.13 alpine (musl) s3 wheel - - 14.1M
3.13 alpine (musl) boto3-stubs wheel - - 12.9M
3.13 alpine (musl) boto3-stubs-lite wheel - - 61.1M
3.13 alpine (musl) essential - - - -
3.13 alpine (musl) s3 - - - -
3.13 alpine (musl) boto3-stubs - - - -
3.13 alpine (musl) boto3-stubs-lite - - - -
3.13 slim (glibc) essential wheel 3.4s - 25M
3.13 slim (glibc) s3 wheel 2.5s - 15M
3.13 slim (glibc) boto3-stubs wheel 2.2s - 13M
3.13 slim (glibc) boto3-stubs-lite wheel 2.3s - 134M
3.13 slim (glibc) essential - - - -
3.13 slim (glibc) s3 - - - -
3.13 slim (glibc) boto3-stubs - - - -
3.13 slim (glibc) boto3-stubs-lite - - - -
3.9 alpine (musl) essential wheel - - 30.7M
3.9 alpine (musl) s3 wheel - - 20.4M
3.9 alpine (musl) boto3-stubs wheel - - 19.2M
3.9 alpine (musl) boto3-stubs-lite wheel - - 67.1M
3.9 alpine (musl) essential - - - -
3.9 alpine (musl) s3 - - - -
3.9 alpine (musl) boto3-stubs - - - -
3.9 alpine (musl) boto3-stubs-lite - - - -
3.9 slim (glibc) essential wheel 10.5s - 31M
3.9 slim (glibc) s3 wheel 8.6s - 21M
3.9 slim (glibc) boto3-stubs wheel 8.4s - 20M
3.9 slim (glibc) boto3-stubs-lite wheel 8.5s - 139M
3.9 slim (glibc) essential - - - -
3.9 slim (glibc) s3 - - - -
3.9 slim (glibc) boto3-stubs - - - -
3.9 slim (glibc) boto3-stubs-lite - - - -
Imports
- Session
import boto3; from boto3.session import Session - S3Client wrong
from boto3.client import S3Clientcorrectfrom mypy_boto3_s3.client import S3Client - Bucket wrong
from boto3.resource import Bucketcorrectfrom mypy_boto3_s3.service_resource import Bucket
Quickstart stale last tested: 2026-04-24
import boto3
from mypy_boto3_s3.client import S3Client
import os
def list_s3_buckets(region_name: str = os.environ.get('AWS_REGION', 'us-east-1')) -> list[str]:
"""Lists S3 bucket names with type hints."""
# boto3-stubs automatically provides type hints for client() and resource() calls
s3_client: S3Client = boto3.client("s3", region_name=region_name)
response = s3_client.list_buckets()
bucket_names = [bucket['Name'] for bucket in response.get('Buckets', [])]
return bucket_names
if __name__ == "__main__":
print(f"S3 Buckets: {list_s3_buckets()}")