mypy-boto3-elasticache

1.42.81 · active · verified Sat Apr 11

mypy-boto3-elasticache provides comprehensive type annotations for the `boto3` ElastiCache service. It enables static type checking with tools like MyPy for `boto3` users, improving code reliability and developer experience. The library is generated by `mypy-boto3-builder` and is updated frequently, often in sync with `boto3` releases and builder improvements. The current version is 1.42.81.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-elasticache` with `boto3`. The type stubs are automatically picked up by MyPy, allowing you to annotate your `boto3` client and response objects for better static analysis. Ensure your AWS credentials are configured for the `boto3` client to function.

import boto3
import os
from mypy_boto3_elasticache.client import ElastiCacheClient
from mypy_boto3_elasticache.type_defs import DescribeCacheClustersResultTypeDef

# mypy-boto3-elasticache provides type annotations for boto3. 
# The actual boto3 library handles runtime interactions.

aws_region = os.environ.get("AWS_REGION", "us-east-1")

try:
    # Initialize ElastiCache client with type annotation for improved type checking
    client: ElastiCacheClient = boto3.client("elasticache", region_name=aws_region)

    # Example: Describe cache clusters
    # The return type is automatically inferred by MyPy if stubs are installed,
    # but can be explicitly annotated for clarity.
    response: DescribeCacheClustersResultTypeDef = client.describe_cache_clusters()

    print(f"Successfully described {len(response.get('CacheClusters', []))} ElastiCache clusters.")
    for cluster in response.get('CacheClusters', []):
        print(f"  - {cluster['CacheClusterId']} ({cluster['Engine']})")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Ensure AWS credentials and region are configured (e.g., via environment variables or ~/.aws/credentials).")

view raw JSON →