Type annotations for aiobotocore CloudFormation
Type annotations for aiobotocore CloudFormation 3.4.0 service. It provides comprehensive type hints for `aiobotocore` clients, paginators, waiters, and TypeDefs for the AWS CloudFormation service, compatible with static type checkers like mypy and pyright. The package is generated by the `mypy-boto3-builder` (version 8.12.0) and is released frequently, mirroring `aiobotocore` versions to ensure up-to-date type definitions.
Warnings
- breaking Python 3.8 support has been removed since `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 or older will need to upgrade their Python version to use the latest `types-aiobotocore-cloudformation` stubs.
- breaking The `mypy-boto3-builder` migrated to PEP 561 compliant packages in version 8.12.0. While largely transparent, this may impact specific environments or custom type-checking configurations if they relied on older package structures.
- breaking TypeDef names might have changed to shorter versions (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) or had postfixes moved (`CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`) in `mypy-boto3-builder` 8.9.0. This could break direct imports or references to specific TypeDef names.
- gotcha For full type checking capabilities, both `aiobotocore` and the corresponding `types-aiobotocore-*` stub packages must be installed. Without the stub package, type checkers will have limited or no information for `aiobotocore` calls.
- gotcha In some IDEs like PyCharm, using `types-aiobotocore` can lead to slow performance or high CPU usage. Workarounds include disabling PyCharm's internal type checker, using external checkers like mypy/pyright, or installing `types-aiobotocore-lite` for a more RAM-friendly option that might require more explicit type annotations.
Install
-
pip install types-aiobotocore-cloudformation -
pip install 'types-aiobotocore[cloudformation]'
Imports
- CloudFormationClient
from types_aiobotocore_cloudformation.client import CloudFormationClient
- StackSummaryTypeDef
from types_aiobotocore_cloudformation.type_defs import StackSummaryTypeDef
- StackStatusType
from types_aiobotocore_cloudformation.literals import StackStatusType
Quickstart
import asyncio
import os
from typing import TYPE_CHECKING
import aiobotocore.session
if TYPE_CHECKING:
from types_aiobotocore_cloudformation.client import CloudFormationClient
from types_aiobotocore_cloudformation.type_defs import StackSummaryTypeDef
async def list_cloudformation_stacks():
session = aiobotocore.session.get_session()
async with session.create_client(
"cloudformation",
region_name=os.environ.get('AWS_REGION', 'us-east-1'),
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'testing'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'testing')
) as client:
# The client variable is automatically type-hinted as CloudFormationClient
client: "CloudFormationClient"
response = await client.list_stacks()
for stack in response.get("StackSummaries", []):
stack_summary: "StackSummaryTypeDef" = stack
print(f"Stack Name: {stack_summary['StackName']}, Status: {stack_summary['StackStatus']}")
if __name__ == "__main__":
asyncio.run(list_cloudformation_stacks())