Type annotations for boto3 AutoScaling

1.42.79 · active · verified Sat Apr 11

mypy-boto3-autoscaling provides comprehensive type annotations (stubs) for the boto3 AutoScaling service. It enables static type checking for your boto3 code using tools like mypy, catching potential errors at development time. The current version is 1.42.79, and it's part of the frequently updated mypy-boto3-builder ecosystem, with releases typically aligning with new boto3/botocore versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an AutoScaling client with type hints provided by `mypy-boto3-autoscaling` and make a basic API call, ensuring that the client and response objects are correctly typed for static analysis.

import boto3
from mypy_boto3_autoscaling.client import AutoScalingClient
from mypy_boto3_autoscaling.type_defs import DescribeAutoScalingGroupsResponseTypeDef
import os

# Ensure boto3 is configured, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION
# or AWS CLI config files.
# Using os.environ.get for demonstration purposes, actual credentials should be handled securely.

# Instantiate the AutoScaling client with type hints
client: AutoScalingClient = boto3.client("autoscaling", region_name=os.environ.get('AWS_REGION', 'us-east-1'))

try:
    # Call a method and apply type hints for the response
    response: DescribeAutoScalingGroupsResponseTypeDef = client.describe_auto_scaling_groups()

    print(f"Found {len(response['AutoScalingGroups'])} Auto Scaling Groups:")
    for group in response['AutoScalingGroups']:
        print(f"  - {group['AutoScalingGroupName']} (Min: {group['MinSize']}, Max: {group['MaxSize']})")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →