mypy-boto3-redshift Type Annotations

1.42.42 · active · verified Sat Apr 11

mypy-boto3-redshift provides explicit type annotations for the `boto3` Redshift service, enhancing static analysis with tools like mypy, pyright, and various IDEs. Generated by `mypy-boto3-builder`, it offers comprehensive type hinting for Redshift clients, paginators, waiters, and associated type definitions. The library is actively maintained and kept in sync with upstream `boto3` releases.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize a `boto3` Redshift client and call `describe_clusters` with full type annotations provided by `mypy-boto3-redshift`. It explicitly imports `RedshiftClient` for the client object and `DescribeClustersResponseTypeDef` for the response, enabling static analysis and IDE auto-completion.

import boto3
from mypy_boto3_redshift.client import RedshiftClient
from mypy_boto3_redshift.type_defs import DescribeClustersResponseTypeDef

def get_redshift_client() -> RedshiftClient:
    """Initializes and returns a type-hinted Redshift client."""
    # boto3.client returns a Client, which mypy_boto3_redshift annotates
    client: RedshiftClient = boto3.client("redshift")
    return client

def describe_redshift_clusters(client: RedshiftClient) -> DescribeClustersResponseTypeDef:
    """Describes Redshift clusters with type hinting."""
    response: DescribeClustersResponseTypeDef = client.describe_clusters(
        ClusterIdentifier='my-redshift-cluster' # Replace with actual cluster ID
    )
    return response

if __name__ == "__main__":
    redshift_client = get_redshift_client()
    try:
        clusters_info = describe_redshift_clusters(redshift_client)
        print(f"Found {len(clusters_info['Clusters'])} Redshift clusters.")
        for cluster in clusters_info['Clusters']:
            print(f"  - Cluster: {cluster['ClusterIdentifier']} Status: {cluster['ClusterStatus']}")
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →