mypy-boto3-pinpoint: Type Annotations for AWS Pinpoint with boto3

1.42.3 · active · verified Sat Apr 11

mypy-boto3-pinpoint provides drop-in type annotations for the AWS Pinpoint service client within the boto3 library. It enables static type checking with tools like mypy and enhances IDE features such as autocompletion and error detection for boto3 Pinpoint API calls. The package, currently at version 1.42.3, is generated by mypy-boto3-builder 8.12.0 and aligns its versioning with boto3 releases to ensure compatibility and up-to-date type information. It is actively maintained with frequent updates to reflect changes in boto3 and Python typing standards.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted Pinpoint client using `boto3.session.Session().client()` and `mypy_boto3_pinpoint.client.PinpointClient`. The `if TYPE_CHECKING:` block ensures that the type stub import is only processed by static analysis tools, preventing a runtime dependency on the stub package.

from typing import TYPE_CHECKING
import boto3
from boto3.session import Session

if TYPE_CHECKING:
    from mypy_boto3_pinpoint.client import PinpointClient

def get_pinpoint_client() -> 'PinpointClient':
    # In a real application, consider using AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
    # environment variables or other boto3 credential providers.
    # For local development or testing, this might use ~/.aws/credentials
    # or IAM roles.
    session = Session(region_name='us-east-1')
    return session.client('pinpoint')

# Example usage (will be type-checked by mypy):
client = get_pinpoint_client()
# client.send_messages(...) # mypy will now validate arguments for send_messages
print(f"Pinpoint client created: {client}")

# Without TYPE_CHECKING, the import is ignored at runtime, preventing a direct dependency on the stub package.
# In a runtime context without type checking, `client` is simply the boto3 client object.

view raw JSON →