{"id":3044,"library":"mypy-boto3-cloudfront","title":"Type Annotations for boto3 CloudFront","description":"mypy-boto3-cloudfront provides type annotations for the AWS boto3 CloudFront service. It enhances development experience with static type checking, auto-completion, and early error detection in IDEs and with tools like mypy. This package, version 1.42.80, is generated with `mypy-boto3-builder 8.12.0` and receives frequent updates in sync with `boto3` releases.","status":"active","version":"1.42.80","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","cloudfront","mypy","typing","stubs","type-hints"],"install":[{"cmd":"pip install mypy-boto3-cloudfront","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install boto3 'mypy-boto3-cloudfront'","lang":"bash","label":"Install with boto3 (recommended)"}],"dependencies":[{"reason":"This package provides type stubs for the `boto3` library; `boto3` must be installed separately for runtime functionality.","package":"boto3","optional":true}],"imports":[{"note":"Import the specific client type for CloudFront.","symbol":"CloudFrontClient","correct":"from mypy_boto3_cloudfront.client import CloudFrontClient"},{"note":"Import TypeDefs for specific service responses or input parameters. (Note: using DistributionSummaryTypeDef as an example, as exact TypeDef names can vary. Always check docs for the precise TypeDef name).","symbol":"DistributionTypeDef","correct":"from mypy_boto3_cloudfront.type_defs import DistributionSummaryTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_cloudfront.client import CloudFrontClient\n    from mypy_boto3_cloudfront.type_defs import DistributionSummaryTypeDef\n\n# Instantiate a boto3 client (type-hinted for mypy)\ncloudfront_client: 'CloudFrontClient' = boto3.client('cloudfront')\n\n# Example: List distributions with type-hinted response\ntry:\n    response = cloudfront_client.list_distributions()\n    distributions: list['DistributionSummaryTypeDef'] = response.get('DistributionList', {}).get('Items', [])\n\n    if distributions:\n        print(f\"Found {len(distributions)} CloudFront distributions.\")\n        for dist in distributions:\n            print(f\"  Distribution ID: {dist.get('Id')}, Domain Name: {dist.get('DomainName')}\")\n    else:\n        print(\"No CloudFront distributions found.\")\nexcept Exception as e:\n    print(f\"Error listing distributions: {e}\")","lang":"python","description":"This example demonstrates how to initialize a `boto3` CloudFront client with type hints and retrieve a list of distributions. It uses `TYPE_CHECKING` for conditional imports, ensuring the stub package is only a development dependency. The response items are type-hinted using a `DistributionSummaryTypeDef`."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Starting with `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-cloudfront 1.42.80`), support for Python 3.8 has been removed. Projects using this version of the stubs or newer require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0, mypy-boto3-cloudfront >= 1.42.80 (generated by 8.12.0)"},{"fix":"Update your code to use the new, shorter TypeDef names. Refer to the specific service's documentation for exact TypeDef names.","message":"Builder version 8.9.0 introduced breaking changes to TypeDef naming conventions. For instance, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`, and `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`. If you're explicitly using these full TypeDef names, they may need to be updated.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0, mypy-boto3-cloudfront >= 1.42.80 (generated by 8.12.0)"},{"fix":"Ensure your `boto3` and `mypy-boto3-cloudfront` package versions are as closely aligned as possible, ideally using the same major and minor version numbers where applicable.","message":"The version of `mypy-boto3-cloudfront` typically aligns with the `boto3` version it provides stubs for (e.g., `1.42.80` for `boto3==1.42.80`). Using significantly mismatched `boto3` and `mypy-boto3-*` versions can lead to type checking errors or missing type hints if API signatures have changed between versions.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For maximum compatibility and clarity, explicitly import `CloudFrontClient` and any `TypeDef`s from `mypy_boto3_cloudfront.client` and `mypy_boto3_cloudfront.type_defs` respectively. Consider using `if TYPE_CHECKING:` for development-only dependencies.","message":"When using explicit type annotations, some IDEs (like VSCode without full function overload support) may require explicitly importing `Client` types and `TypeDef` structures. While `mypy` and PyCharm might infer types more readily, explicit imports ensure consistent behavior across tools.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}