Botocore Stubs
raw JSON → 1.42.41 verified Tue May 12 auth: no python install: stale quickstart: stale
Botocore Stubs provides comprehensive type annotations and code completion for the `botocore` library, the low-level interface to Amazon Web Services. This package, part of the `mypy_boto3_builder` project, is designed to enhance static type analysis with tools like MyPy and Pyright, and improve IDE auto-completion for `botocore`'s dynamically generated classes. It is actively maintained with versions aligned to corresponding `botocore` releases, with the current version being 1.42.41.
pip install botocore-stubs Common errors
error error: Skipping analyzing 'botocore': found module but no type hints or library stubs ↓
cause Your static type checker (like MyPy or Pyright) is not correctly detecting the installed `botocore-stubs` package, often due to an incomplete installation or an incorrect environment setup.
fix
Ensure
botocore-stubs is installed in the same Python environment your type checker is inspecting. Verify the installation with pip show botocore-stubs and run your type checker in the activated environment. error AttributeError: module 'botocore.client' has no attribute 'EC2' ↓
cause This occurs when attempting to import specific AWS service client types (e.g., `EC2Client`, `S3Client`) directly from `botocore.client`, which does not expose these dynamically generated types for static analysis.
fix
Instead of importing from
botocore.client, import the specific client type from the corresponding service stub package generated by mypy_boto3_builder, typically named mypy_boto3_<service_name>.client. For example, for EC2: from mypy_boto3_ec2.client import EC2Client. error Typing/Reformatting/Autocomplete lags when stubs for boto3 are installed ↓
cause The comprehensive `boto3-stubs` package (which includes `botocore-stubs`) generates a large number of `Literal` overloads for `boto3.client` and `boto3.resource` calls, which can significantly degrade performance in IDEs like PyCharm due to intensive type inference.
fix
For PyCharm, it is often recommended to use
boto3-stubs-lite for only the specific services you use (e.g., pip install boto3-stubs-lite[s3,ec2]) or to disable PyCharm's internal type checker and rely on external tools like MyPy or Pyright. error error: Argument "X" to "Y" has incompatible type "dict[str, Any]"; expected "DateTimeRangeTypeDef" ↓
cause You are providing a generic Python dictionary where a specific `TypedDict` structure, generated by `mypy_boto3_builder` for AWS service responses or parameters, is expected by the type checker.
fix
Import and use the precise
TypeDef classes provided by the mypy_boto3_* stub packages to correctly type your AWS request parameters or response handling. For example: from mypy_boto3_health.type_defs import DateTimeRangeTypeDef. Warnings
gotcha botocore-stubs only provides type hints for the low-level `botocore` library, not for the higher-level `boto3` library. Boto3 includes additional abstractions (e.g., `resource` objects, specific helper methods like `upload_file`) that `botocore-stubs` will not type. For `boto3` specific typing, consider `boto3-stubs` (part of the same `mypy_boto3_builder` project). ↓
fix If using `boto3`, install `boto3-stubs` (e.g., `pip install boto3-stubs[essential]`) in addition to or instead of `botocore-stubs`.
gotcha Type stubs are only effective when used with a compatible static type checker (e.g., MyPy, Pyright) or an IDE with strong type-hinting support. Installing `botocore-stubs` alone will not provide runtime changes or visual hints without these tools. ↓
fix Integrate a type checker like MyPy (`pip install mypy`) or Pyright (`npm install -g pyright`) into your development workflow. Configure your IDE (e.g., VSCode with Pylance, PyCharm) to use these tools.
gotcha The version of `botocore-stubs` should ideally align with the version of your installed `botocore` library. Mismatched versions may lead to incomplete or incorrect type hints, especially for new features or deprecated APIs in `botocore`. ↓
fix Ensure `botocore-stubs` is updated alongside `botocore`. Use `pip install --upgrade botocore-stubs botocore` to keep them synchronized, or specify exact versions in your `requirements.txt`.
breaking Version 1.29.0 removed deprecated stubs for client and endpoint_provider modules. If you were relying on type hints for previously deprecated interfaces within these modules, your type checking might now fail or report missing attributes. ↓
fix Update your code to use the non-deprecated `botocore` APIs. Consult the `botocore` documentation and `botocore-stubs` changelog for details on specific removed stubs.
breaking Version 1.29.26 included a fix for `RuleSetStandardLibrary` naming within the `endpoint_provider` module. If your code directly referenced this internal naming for type hints before this fix, it might now cause type checker errors due to the correction. ↓
fix Review any direct type references to `botocore.endpoint_provider.RuleSetStandardLibrary` or related components and adjust to the corrected naming, if applicable. Direct interaction with these internal components is generally discouraged.
breaking The `botocore` library itself is not installed. This module is a core dependency and must be present for any `botocore` (or `boto3`) related code to run. ↓
fix Install `botocore` using pip (e.g., `pip install botocore`). Ensure it's listed in your project's dependencies (e.g., `requirements.txt`).
breaking The `botocore` library must be installed for your application to run. `botocore-stubs` provides only type hints, not the runtime library itself. ↓
fix Ensure `botocore` is installed in your environment (e.g., `pip install botocore`). If you are using `boto3`, `botocore` is typically installed as a dependency, but direct usage requires explicit installation.
Install compatibility stale last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - - 18.4M
3.10 alpine (musl) - - - -
3.10 slim (glibc) wheel 1.8s - 19M
3.10 slim (glibc) - - - -
3.11 alpine (musl) wheel - - 20.3M
3.11 alpine (musl) - - - -
3.11 slim (glibc) wheel 1.8s - 21M
3.11 slim (glibc) - - - -
3.12 alpine (musl) wheel - - 12.1M
3.12 alpine (musl) - - - -
3.12 slim (glibc) wheel 1.6s - 13M
3.12 slim (glibc) - - - -
3.13 alpine (musl) wheel - - 11.9M
3.13 alpine (musl) - - - -
3.13 slim (glibc) wheel 1.6s - 12M
3.13 slim (glibc) - - - -
3.9 alpine (musl) wheel - - 17.9M
3.9 alpine (musl) - - - -
3.9 slim (glibc) wheel 2.2s - 18M
3.9 slim (glibc) - - - -
Imports
- S3Client
from botocore.client import S3Client - Session
from botocore.session import Session
Quickstart stale last tested: 2026-04-24
import os
from botocore.session import Session
from botocore.client import S3Client # For type hinting the client
def get_s3_client() -> S3Client:
"""
Returns a typed S3 client from botocore.
botocore-stubs provides the type hints for S3Client.
"""
# Ensure AWS credentials are set up, e.g., via environment variables
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION
session = Session()
# The return type of session.create_client('s3') is dynamically generated.
# The type checker uses botocore-stubs to infer it as S3Client.
return session.create_client('s3', region_name=os.environ.get('AWS_REGION', 'us-east-1'))
if __name__ == "__main__":
s3_client = get_s3_client()
try:
# This call will have type hints thanks to botocore-stubs
response = s3_client.list_buckets()
print("Successfully listed S3 buckets:")
for bucket in response.get('Buckets', []):
print(f"- {bucket['Name']}")
except Exception as e:
print(f"Error listing S3 buckets: {e}")
print("Ensure you have AWS credentials configured (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION environment variables).")