{"id":2601,"library":"mypy-boto3-ecs","title":"mypy-boto3-ecs","description":"mypy-boto3-ecs provides type annotations for the AWS boto3 ECS (Elastic Container Service) client, resources, and paginators. It is part of the `mypy-boto3` project, which generates stubs for all boto3 services. The current version is 1.42.88, with frequent releases synchronized with new `boto3` versions and `mypy-boto3-builder` updates.","status":"active","version":"1.42.88","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","types","stubs","ecs","type-checking"],"install":[{"cmd":"pip install boto3 mypy-boto3-ecs mypy","lang":"bash","label":"Install boto3, stubs, and mypy"}],"dependencies":[{"reason":"This package provides type stubs for boto3; boto3 itself must be installed to run the code.","package":"boto3","optional":false},{"reason":"mypy is required to perform static type checking using these stubs.","package":"mypy","optional":false}],"imports":[{"symbol":"ECSClient","correct":"from mypy_boto3_ecs.client import ECSClient"},{"symbol":"ECSResource","correct":"from mypy_boto3_ecs.service_resource import ECSResource"},{"note":"Paginators are service-specific and located in the `paginator` submodule.","symbol":"ListClustersPaginator","correct":"from mypy_boto3_ecs.paginator import ListClustersPaginator"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_ecs.client import ECSClient\nfrom typing import TYPE_CHECKING\n\n# Ensure boto3 is installed: pip install boto3 mypy-boto3-ecs\n\nif TYPE_CHECKING:\n    # This block is only for type checking, not runtime execution\n    client: ECSClient = boto3.client(\"ecs\")\n    \n    # Example usage with type hints\n    response = client.list_clusters()\n    for cluster in response.get(\"clusters\", []):\n        print(f\"Cluster ARN: {cluster.get('clusterArn')}\")\n\nelse:\n    # Runtime code without explicit type hints (mypy will still check)\n    client = boto3.client(\"ecs\")\n    response = client.list_clusters()\n    for cluster in response.get(\"clusters\", []):\n        print(f\"Cluster Name: {cluster.get('clusterName')}\")","lang":"python","description":"This example demonstrates how to use `mypy-boto3-ecs` with `boto3` to gain static type checking for the ECS client. The `TYPE_CHECKING` block ensures that type-specific imports do not affect runtime behavior. You need to run `mypy your_script.py` to see the benefits."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Python 3.8 support has been removed for all `mypy-boto3` packages with `mypy-boto3-builder` version 8.12.0 and above. Ensure your environment uses Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (affecting mypy-boto3-ecs 1.42.88+)"},{"fix":"Always `pip install boto3 mypy-boto3-ecs` (or `aiobotocore`/`aioboto3` for async stubs).","message":"`mypy-boto3-ecs` provides only type stubs. You must install `boto3` separately for your code to run. It's a common mistake to install only the stub package.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review `mypy` errors and adjust TypeDef names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`).","message":"TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Specifically, argument TypeDefs use shorter names, and conflicting TypeDef `Extra` postfixes were moved. This might require updating type annotation references in your codebase.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (affecting mypy-boto3-ecs versions generated by this builder version)"},{"fix":"Ensure your type checker (e.g., mypy) is up-to-date. No direct code changes are typically required unless you have specific, custom stub loading configurations.","message":"The `mypy-boto3` stub packages, including `mypy-boto3-ecs`, migrated to PEP 561 compliance with `mypy-boto3-builder` 8.12.0. While this is an improvement for type checker discovery, some legacy tools or build systems might need minor adjustments.","severity":"gotcha","affected_versions":"mypy-boto3-builder >= 8.12.0 (affecting mypy-boto3-ecs 1.42.88+)"},{"fix":"Use `mypy` for type checking. Install with `pip install mypy` and run `mypy your_script.py`.","message":"These stubs are designed for use with `mypy`. While other type checkers might work, `mypy` is the primary target and often yields the most accurate results.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}