mypy-boto3-ecs

1.42.88 · active · verified Fri Apr 10

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.

Warnings

Install

Imports

Quickstart

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.

import boto3
from mypy_boto3_ecs.client import ECSClient
from typing import TYPE_CHECKING

# Ensure boto3 is installed: pip install boto3 mypy-boto3-ecs

if TYPE_CHECKING:
    # This block is only for type checking, not runtime execution
    client: ECSClient = boto3.client("ecs")
    
    # Example usage with type hints
    response = client.list_clusters()
    for cluster in response.get("clusters", []):
        print(f"Cluster ARN: {cluster.get('clusterArn')}")

else:
    # Runtime code without explicit type hints (mypy will still check)
    client = boto3.client("ecs")
    response = client.list_clusters()
    for cluster in response.get("clusters", []):
        print(f"Cluster Name: {cluster.get('clusterName')}")

view raw JSON →