mypy-boto3-cleanroomsml: AWS Clean Rooms ML Type Annotations for boto3
mypy-boto3-cleanroomsml provides static type annotations for the `boto3` CleanRoomsML service, enhancing code quality, readability, and error detection for Python developers working with AWS. It is generated by `mypy-boto3-builder` and is currently at version 1.42.22, with frequent updates mirroring `boto3` releases.
Warnings
- breaking Python 3.8 support has been removed since `mypy-boto3-builder` version 8.12.0. Users must use Python 3.9 or newer.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. This might affect code directly importing and referencing `TypedDict` definitions from the stubs.
- gotcha These are type stubs, not runtime code. `mypy-boto3-cleanroomsml` does not provide an executable client or modify `boto3`'s runtime behavior. It only provides type hints for static analysis.
- gotcha Some IDEs (e.g., VS Code without specific extensions or configurations) may require explicit type annotations for `boto3.client()` and `boto3.resource()` calls to fully leverage the type stubs for autocomplete and inline error detection.
Install
-
pip install mypy-boto3-cleanroomsml boto3 mypy
Imports
- CleanRoomsMLClient
from mypy_boto3_cleanroomsml.client import CleanRoomsMLClient
- boto3.client
import boto3 client: CleanRoomsMLClient = boto3.client('cleanrooms-ml')
Quickstart
import boto3
from mypy_boto3_cleanroomsml.client import CleanRoomsMLClient
# Boto3 will pick up credentials from environment variables or ~/.aws/credentials
# This example demonstrates type hinting for the client.
client: CleanRoomsMLClient = boto3.client('cleanrooms-ml')
print("Listing CleanRooms ML audience models...")
try:
response = client.list_audience_models(maxResults=1)
models = response.get('audienceModelSummaries', [])
if models:
print(f"Found {len(models)} audience model(s). First model name: {models[0].get('name')}")
else:
print("No audience models found.")
except Exception as e:
print(f"Error listing audience models: {e}")
# Example of type-checking a method call (mypy will validate arguments and return type)
# mypy will report errors if 'maxResults' was misspelled or of wrong type.
# mypy will also know the structure of `response` and its `get` methods.