mypy-boto3-config - Boto3 ConfigService Type Stubs

1.42.68 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a Boto3 ConfigService client and use the `mypy-boto3-config` stubs to add type hints for both the client object and its method responses, enhancing static analysis.

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()

view raw JSON →