mypy-boto3-redshift-serverless Type Stubs

1.42.28 · active · verified Sat Apr 11

This package provides type annotations for the `boto3` Redshift Serverless service, generated by `mypy-boto3-builder`. It enables static type checking for your `boto3` client calls, enhancing code quality and developer experience. The current version is 1.42.28, closely tracking `boto3` releases, with frequent updates to align with new AWS service features and API changes.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize a `RedshiftServerlessClient` with type hints and call a basic operation (`list_namespaces`) while leveraging the provided `TypeDef` for the response. Ensure `boto3` and AWS credentials are configured to run successfully.

import boto3
from mypy_boto3_redshift_serverless.client import RedshiftServerlessClient
from mypy_boto3_redshift_serverless.type_defs import ListNamespacesResponseTypeDef

# Create a boto3 client for Redshift Serverless with type hints
# The 'type: ignore' is sometimes needed if boto3.client does not directly
# return the exact stub type expected by mypy-boto3 in all scenarios,
# or if you are using an older boto3 without full type-hinting support.
redshift_client: RedshiftServerlessClient = boto3.client("redshift-serverless") # type: ignore

def list_redshift_namespaces() -> ListNamespacesResponseTypeDef:
    """
    Lists Redshift Serverless namespaces and returns the typed response.
    """
    print("Calling list_namespaces...")
    response: ListNamespacesResponseTypeDef = redshift_client.list_namespaces()
    
    namespaces = response.get("namespaces", [])
    if namespaces:
        for ns in namespaces:
            print(f"  Namespace Name: {ns.get('namespaceName')}, Status: {ns.get('status')}")
    else:
        print("  No namespaces found.")
        
    return response

if __name__ == "__main__":
    # To run this, ensure:
    # 1. 'pip install boto3'
    # 2. 'pip install mypy-boto3-redshift-serverless'
    # 3. AWS credentials are configured (e.g., via ~/.aws/credentials or environment variables)

    try:
        list_redshift_namespaces()
    except Exception as e:
        print(f"An error occurred: {e}")
        print("Please ensure boto3 is configured with valid AWS credentials and permissions.")

view raw JSON →