mypy-boto3-dax Type Annotations
mypy-boto3-dax provides type annotations for the AWS DynamoDB Accelerator (DAX) service, compatible with `boto3`. It enhances development with static type checking, autocomplete, and improved IDE support for `boto3` DAX clients. This package is version `1.42.3`, generated by `mypy-boto3-builder` `8.12.0`, which periodically releases updates to align with new `boto3` versions and address type-related issues.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 must upgrade their Python version to 3.9 or higher to use the latest `mypy-boto3-dax` stubs.
- breaking Type definition naming conventions changed in `mypy-boto3-builder` 8.9.0, leading to shorter names for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This may require updates to explicit type hints in existing code.
- gotcha `mypy-boto3-dax` provides only type annotations; `boto3` itself must be installed and correctly configured with AWS credentials for the code to run at runtime.
- gotcha While often implicitly handled by IDEs, explicit type annotations (e.g., `client: DAXClient = boto3.client('dax')`) are recommended for optimal code completion and static analysis, especially when using `mypy-boto3-lite` or older IDE versions.
- gotcha PyCharm users might experience performance issues due to its handling of `Literal` overloads. Using `types-boto3-lite` (if available for DAX) or being mindful of explicit typing can mitigate this.
Install
-
pip install mypy-boto3-dax boto3
Imports
- DAXClient
from mypy_boto3_dax.client import DAXClient
- DescribeClustersResponseTypeDef
from mypy_boto3_dax.type_defs import DescribeClustersResponseTypeDef
Quickstart
import boto3
from mypy_boto3_dax.client import DAXClient
from mypy_boto3_dax.type_defs import DescribeClustersResponseTypeDef
def get_dax_clusters() -> DescribeClustersResponseTypeDef:
# boto3.client is implicitly typed by mypy-boto3-dax if installed
# For explicit typing, use:
client: DAXClient = boto3.client('dax')
response: DescribeClustersResponseTypeDef = client.describe_clusters(
MaxResults=5
)
return response
if __name__ == '__main__':
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
try:
clusters_info = get_dax_clusters()
print(f"Found {len(clusters_info['Clusters'])} DAX clusters.")
for cluster in clusters_info['Clusters']:
print(f" - Cluster Name: {cluster['ClusterName']}, Status: {cluster['Status']}")
except Exception as e:
print(f"Error fetching DAX clusters: {e}")