mypy-boto3-chatbot Type Annotations

1.42.3 · active · verified Sat Apr 11

mypy-boto3-chatbot provides comprehensive type annotations for the `boto3` AWS Chatbot service. Generated by `mypy-boto3-builder` (currently version 8.12.0), this library enables static type checking with tools like `mypy` and `pyright`, offering improved autocompletion and early error detection in IDEs like VSCode and PyCharm. It is updated frequently to synchronize with the latest `boto3` service definitions (current `chatbot` version 1.42.3).

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `mypy-boto3-chatbot` to add type hints to your `boto3` Chatbot client. By explicitly annotating the client and its response, you gain static analysis benefits like autocompletion and type validation.

import boto3
from typing import TYPE_CHECKING, Dict, Any

# Ensure boto3 is installed for runtime functionality
# pip install boto3

if TYPE_CHECKING:
    from mypy_boto3_chatbot.client import ChatbotClient
    from mypy_boto3_chatbot.type_defs import DescribeChatbotSourcesResponseTypeDef

def get_chatbot_sources(aws_region: str = "us-east-1") -> Dict[str, Any]:
    """
    Retrieves and type-checks AWS Chatbot sources using mypy-boto3-chatbot stubs.
    """
    # boto3.client returns an untyped client by default
    client: ChatbotClient = boto3.client("chatbot", region_name=aws_region)
    
    # The response is now type-checked, providing autocompletion and validation
    response: DescribeChatbotSourcesResponseTypeDef = client.describe_chatbot_sources()
    
    print(f"Chatbot sources response: {response}")
    return response

if __name__ == "__main__":
    # This assumes AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
    try:
        sources = get_chatbot_sources()
        print(f"Successfully retrieved chatbot sources with HTTP status: {sources['ResponseMetadata']['HTTPStatusCode']}")
    except Exception as e:
        print(f"An error occurred while fetching chatbot sources: {e}")

view raw JSON →