mypy-boto3-personalize: Type Annotations for AWS Personalize

1.42.3 · active · verified Sat Apr 11

mypy-boto3-personalize provides comprehensive type annotations for the AWS Personalize service in `boto3`. It enhances static analysis with tools like MyPy, catching potential type-related errors before runtime. The current version is 1.42.3, tracking `boto3` releases, and is part of the frequently updated `mypy-boto3-builder` ecosystem.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and apply type hints for the AWS Personalize client using `mypy-boto3-personalize`. It shows the typical pattern of instantiating a `boto3` client and then annotating it with the provided `PersonalizeClient` type, enabling static type checking for your AWS SDK interactions.

import boto3
from mypy_boto3_personalize.client import PersonalizeClient

# mypy-boto3-personalize provides type hints for the boto3 client.
# You still use the standard boto3 client at runtime.

# Configure AWS credentials as usual (e.g., ~/.aws/credentials, environment variables)

# Instantiate a boto3 client and apply the type hint
personalize_client: PersonalizeClient = boto3.client("personalize")

print(f"Client type successfully inferred by mypy-boto3-personalize: {type(personalize_client)}")

# Example of how type hints are used for method calls (for static analysis).
# This code block is for demonstration of type-checking, not intended for live execution
# without proper setup and AWS resources.

# from mypy_boto3_personalize.type_defs import CreateDatasetRequestRequestTypeDef

# try:
#     # Type checkers like MyPy will ensure 'name', 'datasetGroupArn', etc. are correct types
#     # and that the return value matches CreateDatasetResponseTypeDef.
#     create_request: CreateDatasetRequestRequestTypeDef = {
#         "name": "MyNewDataset",
#         "datasetGroupArn": "arn:aws:personalize:us-east-1:123456789012:dataset-group/my-group",
#         "datasetType": "ITEMS",
#         "schemaArn": "arn:aws:personalize:us-east-1:123456789012:schema/my-schema",
#     }
#     response = personalize_client.create_dataset(**create_request)
#     print(f"Type-checked call example response: {response}")
# except Exception as e:
#     print(f"Example call failed (expected without real AWS setup): {e}")

view raw JSON →