mypy-boto3-codecatalyst Type Stubs
mypy-boto3-codecatalyst provides comprehensive type annotations for the AWS CodeCatalyst service within the `boto3` library. It enables static type checking with tools like MyPy, Pyright, and enhances IDE features like auto-completion and error detection for `boto3.client('codecatalyst')`. The library is actively maintained and generated with `mypy-boto3-builder`, following a frequent release cadence to align with `boto3` updates.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 (and consequently for packages built with it). Projects using this library must upgrade to Python 3.9 or newer.
- breaking TypeDef names for method arguments and conflicting TypeDefs were renamed in `mypy-boto3-builder` version 8.9.0. Specifically, `RequestRequestTypeDef` was shortened to `RequestTypeDef` and `ExtraRequestTypeDef` was changed to `RequestExtraTypeDef`.
- gotcha This package provides type stubs only; `boto3` itself must be installed separately for the code to run. The type stubs are compile-time dependencies, while `boto3` is a runtime dependency.
- gotcha While direct installation of `mypy-boto3-codecatalyst` works, the recommended approach for `boto3` users is to install `boto3-stubs` with the service extra (e.g., `pip install 'boto3-stubs[codecatalyst]'`). This method often provides better overall type inference and compatibility across services by leveraging `boto3-stubs`'s session overloads.
Install
-
pip install mypy-boto3-codecatalyst boto3 -
pip install 'boto3-stubs[codecatalyst]'
Imports
- CodeCatalystClient
from mypy_boto3_codecatalyst import CodeCatalystClient
- ListDevEnvironmentsResponseTypeDef
from mypy_boto3_codecatalyst.type_defs import ListDevEnvironmentsResponseTypeDef
Quickstart
import boto3
from boto3.session import Session
from mypy_boto3_codecatalyst import CodeCatalystClient
import os
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# For a runnable example, we'll simulate an empty config if not set
# Explicitly set up a session for clarity, though boto3.client() uses a default session
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')
)
# Get a typed CodeCatalyst client
client: CodeCatalystClient = session.client("codecatalyst")
# Now, the 'client' object is fully type-checked by MyPy and provides IDE auto-completion
# For example, calling a method with incorrect arguments will be flagged.
# try:
# response = client.list_dev_environments(InvalidArg=True) # This would be a type error
# except Exception as e:
# print(f"Expected error: {e}")
response = client.list_dev_environments()
print(f"Successfully called list_dev_environments. Found {len(response.get('items', []))} dev environments.")
# Access type-safe response data
# if response['items']:
# first_env_name = response['items'][0]['devEnvironmentName']