mypy-boto3-pinpoint: Type Annotations for AWS Pinpoint with boto3
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
- breaking Support for Python 3.8 was removed starting with mypy-boto3-builder v8.12.0, which affects all generated stub packages including mypy-boto3-pinpoint. The minimum required Python version is now 3.9.
- breaking Specific TypeDef names were changed for consistency and brevity (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`) in mypy-boto3-builder v8.9.0. If your code explicitly references these verbose TypeDefs, it will break.
- gotcha mypy-boto3-pinpoint provides *only* type annotations. The actual `boto3` library must be installed separately for the code to run at runtime. Failure to install `boto3` will result in `ModuleNotFoundError` or similar runtime errors.
- gotcha The versioning of individual `mypy-boto3-*` service stub packages (like `mypy-boto3-pinpoint`) is tied to the `boto3` version they annotate. However, the `mypy-boto3-builder` tool, which generates these stubs, has its own independent versioning.
- gotcha While many IDEs and recent `mypy` versions can infer types without explicit stub imports, using `if TYPE_CHECKING:` guards the stub imports. This prevents adding the stub package as a runtime dependency and can avoid potential import conflicts or performance issues with some tooling.
Install
-
pip install mypy-boto3-pinpoint boto3
Imports
- PinpointClient
from mypy_boto3_pinpoint.client import PinpointClient
Quickstart
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.