Type annotations for boto3 Customer Profiles

1.42.66 · active · verified Sat Apr 11

This library provides type annotations (stubs) for the `boto3` AWS SDK, specifically for the CustomerProfiles service. It enables static type checking tools like Mypy to validate `boto3` usage, preventing common runtime errors related to incorrect arguments or return types. The current version is 1.42.66, and releases are frequent, synchronized with `boto3` and `botocore` updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` Customer Profiles client with `mypy-boto3` type annotations and perform a basic operation like listing domains. It shows the correct import paths for client types and type definitions, allowing Mypy to provide comprehensive static analysis for your `boto3` calls.

import boto3
from mypy_boto3_customer_profiles.client import CustomerProfilesClient
from mypy_boto3_customer_profiles.type_defs import ListDomainsOutputTypeDef

# Initialize a boto3 client with type hints
client: CustomerProfilesClient = boto3.client("customer-profiles", region_name="us-east-1")

# Example operation: List Customer Profiles domains
try:
    print("Listing Customer Profiles domains...")
    # The response object will be typed as ListDomainsOutputTypeDef
    response: ListDomainsOutputTypeDef = client.list_domains()
    for domain in response.get("DomainList", []):
        print(f"  Domain ARN: {domain.get('DomainArn')}, Name: {domain.get('DomainName')}")
    print("Successfully listed domains.")
except Exception as e:
    print(f"Error listing domains: {e}")

# Example of creating a new profile (requires appropriate permissions)
# profile_data = {
#     "DomainName": "your_domain_name",
#     "FirstName": "John",
#     "LastName": "Doe",
#     "EmailAddress": "john.doe@example.com"
# }
# try:
#     # You would use a specific type definition for the input here, e.g., CreateProfileRequestRequestTypeDef
#     # client.create_profile(**profile_data)
#     print("Profile creation commented out, uncomment to run.")
# except client.exceptions.ResourceNotFoundException:
#     print("Domain not found. Ensure 'your_domain_name' exists.")
# except Exception as e:
#     print(f"Error creating profile: {e}")

view raw JSON →