{"id":3082,"library":"mypy-boto3-elasticache","title":"mypy-boto3-elasticache","description":"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.","status":"active","version":"1.42.81","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","type-checking","mypy","elasticache","stubs","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-elasticache","lang":"bash","label":"Install library"}],"dependencies":[{"reason":"Provides the runtime AWS SDK for which these type stubs are generated. This library only provides types, not implementation.","package":"boto3","optional":false}],"imports":[{"note":"mypy-boto3-* packages provide type stubs, not runtime implementations. The actual client should be obtained via `boto3.client()`, with the stub type used for annotation only.","wrong":"from mypy_boto3_elasticache.client import ElastiCacheClient\n\nclient = ElastiCacheClient()","symbol":"ElastiCacheClient","correct":"from mypy_boto3_elasticache.client import ElastiCacheClient\nimport boto3\n\nclient: ElastiCacheClient = boto3.client('elasticache')"},{"note":"Type definitions for service responses and request parameters are available for explicit annotation, though MyPy often infers them when stubs are installed.","symbol":"DescribeCacheClustersResultTypeDef","correct":"from mypy_boto3_elasticache.type_defs import DescribeCacheClustersResultTypeDef"}],"quickstart":{"code":"import boto3\nimport os\nfrom mypy_boto3_elasticache.client import ElastiCacheClient\nfrom mypy_boto3_elasticache.type_defs import DescribeCacheClustersResultTypeDef\n\n# mypy-boto3-elasticache provides type annotations for boto3. \n# The actual boto3 library handles runtime interactions.\n\naws_region = os.environ.get(\"AWS_REGION\", \"us-east-1\")\n\ntry:\n    # Initialize ElastiCache client with type annotation for improved type checking\n    client: ElastiCacheClient = boto3.client(\"elasticache\", region_name=aws_region)\n\n    # Example: Describe cache clusters\n    # The return type is automatically inferred by MyPy if stubs are installed,\n    # but can be explicitly annotated for clarity.\n    response: DescribeCacheClustersResultTypeDef = client.describe_cache_clusters()\n\n    print(f\"Successfully described {len(response.get('CacheClusters', []))} ElastiCache clusters.\")\n    for cluster in response.get('CacheClusters', []):\n        print(f\"  - {cluster['CacheClusterId']} ({cluster['Engine']})\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure AWS credentials and region are configured (e.g., via environment variables or ~/.aws/credentials).\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Starting with `mypy-boto3-builder` version 8.12.0, support for Python 3.8 has been removed for all generated packages, including `mypy-boto3-elasticache`. Minimum required Python version is now 3.9.","severity":"breaking","affected_versions":">=8.12.0 (builder), >=1.42.0 (stubs, approx)"},{"fix":"Review your explicit `TypeDef` imports and update them according to the new naming conventions if type checking errors occur.","message":"Beginning with `mypy-boto3-builder` version 8.9.0, there were breaking changes to `TypeDef` naming conventions (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). If you explicitly import and use these generated types, your code may require updates.","severity":"breaking","affected_versions":">=8.9.0 (builder)"},{"fix":"Use `boto3.client()` or `boto3.resource()` for runtime operations. The `mypy_boto3_elasticache` imports are solely for static type annotations.","message":"These packages provide only type stubs. Do not attempt to instantiate clients or resources directly from `mypy_boto3_elasticache` modules at runtime. Always use `boto3.client('elasticache')` or `boto3.resource('elasticache')` for runtime operations.","severity":"gotcha","affected_versions":"all"},{"fix":"Refer to AWS documentation and `mypy-boto3` release notes for changes in service names or available modules, especially after `boto3` or `mypy-boto3` upgrades.","message":"AWS service names can change or be deprecated (e.g., `sms-voice` was replaced by `pinpoint-sms-voice`). While this specific change doesn't affect ElastiCache, be aware that service module names in `mypy-boto3` packages may evolve with AWS service updates.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}