{"id":1569,"library":"mypy-boto3-cloudformation","title":"mypy-boto3-cloudformation","description":"mypy-boto3-cloudformation provides type annotations for the boto3 CloudFormation service. It is automatically generated by mypy-boto3-builder and closely follows boto3's versioning, offering up-to-date type stubs for improved static analysis and IDE assistance when working with AWS CloudFormation using boto3. The library is actively maintained with frequent updates reflecting changes in boto3 and the AWS API.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","cloudformation","typing","stubs","type-hints","static-analysis"],"install":[{"cmd":"pip install boto3 mypy-boto3-cloudformation","lang":"bash","label":"Install boto3 (runtime) and stubs"}],"dependencies":[{"reason":"Runtime dependency for which these are type stubs. The stubs themselves do not have a runtime dependency on boto3, but they are useless without it.","package":"boto3","optional":false},{"reason":"May be required for older Python versions (e.g., <3.10) for certain type features. Automatically managed by the builder's dependency resolution.","package":"typing-extensions","optional":true}],"imports":[{"symbol":"CloudFormationClient","correct":"from mypy_boto3_cloudformation.client import CloudFormationClient"},{"note":"Use the enum `CloudFormationServiceName` for the client name string for type safety.","wrong":"from mypy_boto3_cloudformation import 'cloudformation'","symbol":"CloudFormationServiceName","correct":"from mypy_boto3_cloudformation import CloudFormationServiceName"},{"note":"Example of importing a specific TypedDict for request/response structures.","symbol":"StackSummaryTypeDef","correct":"from mypy_boto3_cloudformation.type_defs import StackSummaryTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_cloudformation.client import CloudFormationClient\nfrom mypy_boto3_cloudformation.type_defs import StackSummaryTypeDef\nfrom mypy_boto3_cloudformation import CloudFormationServiceName\n\n# Get a typed CloudFormation client using CloudFormationServiceName for safety\nclient: CloudFormationClient = boto3.client(CloudFormationServiceName.CLOUDFORMATION)\n\n# Example: List stacks and iterate with type hints\ntry:\n    response = client.list_stacks(StackStatusFilter=['CREATE_COMPLETE', 'UPDATE_COMPLETE'])\n    \n    # response['StackSummaries'] is a list of StackSummaryTypeDef\n    stacks: list[StackSummaryTypeDef] = response.get('StackSummaries', [])\n\n    if stacks:\n        print(\"CloudFormation Stacks:\")\n        for stack in stacks:\n            print(f\"  Name: {stack['StackName']}, Status: {stack['StackStatus']}, Id: {stack['StackId']}\")\n    else:\n        print(\"No CREATE_COMPLETE or UPDATE_COMPLETE stacks found.\")\nexcept Exception as e:\n    print(f\"Error listing stacks: {e}\")\n\n# The type checker (e.g., mypy) will now validate usage of `client`\n# and `stack` objects against the CloudFormation API definition.","lang":"python","description":"This quickstart demonstrates how to obtain a type-hinted CloudFormation client from boto3 and perform a basic operation like listing stacks. It shows how to use the `CloudFormationClient` type for the client object and `StackSummaryTypeDef` for processing response data, ensuring static type checking of your boto3 interactions."},"warnings":[{"fix":"Upgrade your project's Python version to 3.9 or higher. If you must use Python 3.8, pin to an older `mypy-boto3-cloudformation` version (e.g., <1.42.0) and its corresponding `mypy-boto3-builder`.","message":"Python 3.8 support was removed for all mypy-boto3 packages, including mypy-boto3-cloudformation. Projects requiring type stubs must use Python 3.9 or newer.","severity":"breaking","affected_versions":">= 8.12.0 of mypy-boto3-builder (which generates mypy-boto3-cloudformation versions >= 1.42.0)"},{"fix":"Ensure your `mypy` configuration (or other type checkers) correctly identifies `mypy-boto3-cloudformation` as a PEP 561-compliant stub package. For most users, this will work out-of-the-box, but check `mypy` output if stubs are not found.","message":"All mypy-boto3 packages migrated to PEP 561-compliant distribution. This change primarily affects how type checkers locate stubs, potentially requiring adjustments in build configurations or explicit stub path declarations if you were relying on non-standard stub discovery methods.","severity":"breaking","affected_versions":">= 8.12.0 of mypy-boto3-builder (which generates mypy-boto3-cloudformation versions >= 1.42.0)"},{"fix":"Review and update your code to use the new, shorter TypeDef names for request/response payloads if you import them explicitly.","message":"TypeDef naming conventions were changed for packed method arguments, shortening names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). Conflicting TypeDef `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` to `CreateDistributionRequestExtraTypeDef`).","severity":"breaking","affected_versions":">= 8.9.0 of mypy-boto3-builder (which generates mypy-boto3-cloudformation versions >= 1.39.0)"},{"fix":"Always install `boto3` alongside `mypy-boto3-cloudformation` using `pip install boto3 mypy-boto3-cloudformation`.","message":"This library provides type stubs for `boto3`, not the `boto3` runtime itself. You must install `boto3` separately for your code to actually run. Without `boto3`, `mypy-boto3-cloudformation` offers no functional benefit beyond type checking for a non-existent runtime.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Keep `mypy-boto3-cloudformation` updated in sync with your `boto3` installation. Use `pip install --upgrade boto3 mypy-boto3-cloudformation` regularly.","message":"For optimal compatibility and accurate type hints, the major.minor version of `mypy-boto3-cloudformation` (e.g., 1.42.x) should ideally align with the major.minor version of your installed `boto3` (e.g., 1.42.x). Mismatches can lead to type checking errors or missing attributes if the underlying API changes.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}