Type annotations for boto3 IVS
mypy-boto3-ivs provides PEP 561 compatible type annotations for the `boto3` AWS IVS (Amazon Interactive Video Service) service, enhancing Python development with static type checking and IDE auto-completion. It is part of the `mypy-boto3-builder` project, which automatically generates and releases stub packages in sync with `boto3` updates. The current version is 1.42.3, mirroring the `boto3` version it types.
Warnings
- breaking The underlying `mypy-boto3-builder` (version 8.12.0+) has removed support for Python 3.8. Projects relying on `mypy-boto3-ivs` must use Python 3.9 or newer.
- gotcha `mypy-boto3-ivs` is a stub-only package (PEP 561). It provides type hints for `boto3`, but you must install `boto3` itself separately for runtime functionality. Installing only `mypy-boto3-ivs` will not allow you to interact with AWS services.
- breaking For those creating custom stubs or deeply inspecting generated types, `mypy-boto3-builder` version 8.9.0 introduced breaking changes to `TypeDef` naming conventions (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).
- gotcha PyCharm users might experience slow performance with Literal overloads provided by `mypy-boto3` packages. As a workaround, the `boto3-stubs-lite` variants are recommended for better IDE responsiveness, though they might require more explicit type annotations.
Install
-
pip install mypy-boto3-ivs boto3
Imports
- IVSClient
from mypy_boto3_ivs.client import IVSClient
- boto3
import boto3
Quickstart
import boto3
from mypy_boto3_ivs.client import IVSClient
import os
# Ensure boto3 is configured, e.g., via environment variables or ~/.aws/credentials
# This example assumes credentials are set up for boto3
def get_ivs_channels():
# The client will be implicitly typed as IVSClient due to mypy-boto3-ivs
client: IVSClient = boto3.client("ivs", region_name=os.environ.get('AWS_REGION', 'us-east-1'))
try:
response = client.list_channels()
print("Successfully listed IVS channels.")
for channel in response.get("channels", []):
print(f" Channel ARN: {channel.get('arn')}, Name: {channel.get('name')}")
return response.get("channels", [])
except Exception as e:
print(f"Error listing IVS channels: {e}")
return []
if __name__ == "__main__":
# Example usage
ivs_channels = get_ivs_channels()
if not ivs_channels:
print("No IVS channels found or an error occurred.")