mypy-boto3-application-autoscaling Type Stubs
This library provides type annotations (stubs) for the `boto3` client for the AWS Application Auto Scaling service. It enables static type checking with tools like Mypy, improving code reliability and developer experience when working with AWS SDK for Python. The current version is 1.42.3, and releases typically follow the `boto3` release cycle, with new stub packages generated for each new `boto3` version.
Warnings
- breaking Python 3.8 support has been removed. All `mypy-boto3` packages, including `mypy-boto3-application-autoscaling`, now require Python 3.9 or newer.
- breaking The `mypy-boto3-builder` migrated to PEP 561 compliant packages. While this generally improves compatibility with type checkers, it might affect custom build processes or tools that rely on the old package structure.
- gotcha The version of `mypy-boto3-application-autoscaling` should ideally match your `boto3` runtime version to ensure accurate type hints. Mismatched versions can lead to `mypy` errors or incorrect type inferences.
- breaking In `mypy-boto3-builder` 8.9.0, TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If you were directly importing these longer names, they will no longer exist.
Install
-
pip install mypy-boto3-application-autoscaling boto3 mypy
Imports
- ApplicationAutoScalingClient
from mypy_boto3_application_autoscaling import ApplicationAutoScalingClient
- DescribeScalableTargetsResponseTypeDef
from mypy_boto3_application_autoscaling.type_defs import DescribeScalableTargetsResponseTypeDef
Quickstart
import boto3
from mypy_boto3_application_autoscaling import ApplicationAutoScalingClient
from mypy_boto3_application_autoscaling.type_defs import DescribeScalableTargetsResponseTypeDef
def list_scalable_targets() -> None:
# Using type hint for the boto3 client
client: ApplicationAutoScalingClient = boto3.client('application-autoscaling')
# Example API call
response: DescribeScalableTargetsResponseTypeDef = client.describe_scalable_targets(
ServiceNamespace='ec2'
)
print(f"Scalable targets found: {len(response['ScalableTargets'])}")
for target in response['ScalableTargets']:
print(f"- Resource ID: {target['ResourceId']}, Dimension: {target['ScalableDimension']}")
# To run type checking:
# 1. Save this as a Python file (e.g., `main.py`)
# 2. Run `mypy main.py` in your terminal
# To execute the code (requires AWS credentials configured):
# list_scalable_targets()