Type Annotations for boto3 PersonalizeEvents
mypy-boto3-personalize-events provides type annotations for the `boto3` PersonalizeEvents service, enabling static type checking with tools like MyPy, PyRight, and improved IDE auto-completion. It is part of the `mypy-boto3` project, which generates stubs for all `boto3` services. This package is currently at version 1.42.3, generated with `mypy-boto3-builder 8.12.0`, and follows a frequent release cadence, often aligning with `boto3` and `mypy-boto3-builder` updates.
Warnings
- breaking Support for Python 3.8 was officially removed for all `mypy-boto3` packages with `mypy-boto3-builder` version 8.12.0.
- breaking Some generated TypeDefs for method arguments were renamed for brevity (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`) in `mypy-boto3-builder` 8.9.0. Similarly, conflicting TypeDef `Extra` postfixes were moved to the end.
- gotcha When using standalone packages like `mypy-boto3-personalize-events` or `boto3-stubs-lite`, explicit type annotations for `session.client()` and `session.resource()` calls are often necessary in IDEs (like VSCode with Pylance) to ensure full auto-completion and correct type inference.
- gotcha PyCharm users might experience performance issues due to its handling of `Literal` overloads. For better performance, especially in larger projects, `boto3-stubs-lite` is recommended over full `boto3-stubs` or standalone packages.
Install
-
pip install mypy-boto3-personalize-events -
pip install "boto3-stubs[personalize-events]"
Imports
- PersonalizeEventsClient
from mypy_boto3_personalize_events.client import PersonalizeEventsClient
- PutEventsRequestRequestTypeDef
from mypy_boto3_personalize_events.type_defs import PutEventsRequestRequestTypeDef
Quickstart
import boto3
import os
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_personalize_events.client import PersonalizeEventsClient
from mypy_boto3_personalize_events.type_defs import PutEventsRequestRequestTypeDef
def process_personalize_events(session: boto3.Session) -> None:
# Client is explicitly typed for full IDE support and static analysis
client: PersonalizeEventsClient = session.client("personalize-events")
# Example: Put events
event_data: PutEventsRequestRequestTypeDef = {
"trackingId": "your-tracking-id",
"sessionId": "user-session-id-123",
"eventList": [
{
"eventId": "event-id-1",
"eventType": "Purchase",
"itemId": "item-id-101",
"sentAt": "2026-04-11T13:00:00Z",
"properties": "{\"price\": 10.99}"
}
]
}
response = client.put_events(**event_data)
print(f"PutEvents response: {response}")
if __name__ == "__main__":
# Use environment variables for credentials in production
aws_session = boto3.Session(
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
region_name=os.environ.get('AWS_REGION', 'us-east-1')
)
process_personalize_events(aws_session)