mypy-boto3-ivschat: Type Annotations for AWS IVS Chat
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
- breaking Support for Python 3.8 was removed starting with `mypy-boto3-builder` version 8.12.0. Ensure your project uses Python 3.9 or newer.
- gotcha `mypy-boto3-ivschat` provides only type annotations; it does NOT include the `boto3` runtime itself. You must install `boto3` separately for your code to execute.
- breaking Starting with `mypy-boto3-builder` 8.9.0, some `TypeDef` names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) or reorganized to avoid conflicts. This could lead to `NameError` if referencing old `TypeDef` names.
- gotcha For type hints, you must import types directly from `mypy_boto3_ivschat` (e.g., `from mypy_boto3_ivschat import IvschatClient`). Importing from `boto3.ivschat` or similar paths will not provide the correct static types.
- gotcha The `mypy-boto3-builder` migrated to PEP 561 compliant packages in version 8.12.0. While mostly internal, ensure `mypy` is up to date to correctly discover and use these stub packages.
Install
-
pip install boto3 mypy-boto3-ivschat
Imports
- IvschatClient
from mypy_boto3_ivschat import IvschatClient
- ListChannelsResponseTypeDef
from mypy_boto3_ivschat.type_defs import ListChannelsResponseTypeDef
Quickstart
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()