mypy-boto3-config - Boto3 ConfigService Type Stubs
mypy-boto3-config provides comprehensive type annotations for the AWS Boto3 ConfigService client, enabling static type checking with tools like MyPy. It is part of the `mypy-boto3` ecosystem, which generates stubs for all Boto3 services. Updates are frequent, often aligned with Boto3 releases and `mypy-boto3-builder` enhancements, with the current version being 1.42.68.
Warnings
- breaking Support for Python 3.8 has been removed from `mypy-boto3-builder` version 8.12.0 onwards, which generates these stubs. This means `mypy-boto3-config` versions generated by `builder>=8.12.0` will not support Python 3.8.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Some deeply nested or conflicting TypeDef names may have been shortened or reordered (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).
- gotcha These packages provide type stubs for static analysis (e.g., MyPy) only; they do not include the Boto3 runtime. You must install `boto3` separately for your code to function.
- gotcha For optimal type checking accuracy, the version of `mypy-boto3-config` should ideally match or be newer than your installed `boto3` version to reflect the latest AWS API changes.
Install
-
pip install mypy-boto3-config -
pip install 'boto3<2'
Imports
- ConfigServiceClient
from mypy_boto3_config.client import ConfigServiceClient
- DescribeConfigurationRecordersResponseTypeDef
from mypy_boto3_config.type_defs import DescribeConfigurationRecordersResponseTypeDef
Quickstart
import boto3
from mypy_boto3_config.client import ConfigServiceClient
from mypy_boto3_config.type_defs import DescribeConfigurationRecordersResponseTypeDef
import os
def check_config_recorders() -> None:
# Initialize the Boto3 client, type-hinted with mypy-boto3-config's client type
config_client: ConfigServiceClient = boto3.client(
"config",
region_name=os.environ.get("AWS_REGION", "us-east-1")
)
try:
# Call a method and type-hint its response
response: DescribeConfigurationRecordersResponseTypeDef = config_client.describe_configuration_recorders()
print(f"Configuration recorders found: {len(response['ConfigurationRecorders'])}")
for recorder in response["ConfigurationRecorders"]:
strategy = recorder.get('recordingGroup', {}).get('recordingStrategy', {}).get('recordingStrategyType', 'N/A')
print(f"- {recorder['name']} (Status: {strategy})")
except Exception as e:
print(f"Error describing configuration recorders: {e}")
if __name__ == "__main__":
# Ensure AWS_REGION is set in your environment or replace 'us-east-1'
# For real applications, use proper credential management.
check_config_recorders()