mypy-boto3-ivschat: Type Annotations for AWS IVS Chat

1.42.3 · active · verified Sat Apr 11

mypy-boto3-ivschat provides type annotations for the AWS IVS Chat service client within the boto3 library, enhancing static analysis and IDE autocomplete. It's part of the `mypy-boto3` ecosystem, which generates stubs for all AWS services. The library updates frequently, typically mirroring boto3 releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` IVS Chat client and use the `mypy-boto3-ivschat` stubs to provide accurate type hints for client methods and their return values. This significantly improves code reliability and development experience with static analysis.

import boto3
from mypy_boto3_ivschat import IvschatClient
from typing import TYPE_CHECKING

# These imports are only for type checking and will be ignored at runtime
if TYPE_CHECKING:
    from mypy_boto3_ivschat.type_defs import ListChannelsResponseTypeDef, ChannelSummaryTypeDef


def get_ivs_chat_channels() -> None:
    # Initialize a boto3 client, type-hinted by mypy-boto3-ivschat
    client: IvschatClient = boto3.client("ivschat")

    print("Listing IVS Chat Channels...")
    try:
        # Make an API call, with return type safety
        response: ListChannelsResponseTypeDef = client.list_channels()

        channels = response.get("channels", [])
        if channels:
            print(f"Found {len(channels)} channels:")
            for channel in channels:
                # Further type-hinting for individual items
                channel_summary: ChannelSummaryTypeDef = channel
                print(f"  - Name: {channel_summary.get('name')}, ARN: {channel_summary.get('arn')}")
        else:
            print("No IVS Chat channels found.")

    except client.exceptions.ClientError as e:
        print(f"AWS Client Error: {e}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

if __name__ == "__main__":
    get_ivs_chat_channels()

view raw JSON →