mypy-boto3-pinpoint-sms-voice

1.42.3 · active · verified Sat Apr 11

This library provides essential type annotations for the `boto3` Pinpoint SMS Voice service, generated by `mypy-boto3-builder`. It enables static type checking with tools like Mypy, enhancing code quality and developer experience for AWS interactions. The current version is 1.42.3, and releases are frequent, typically in sync with `boto3` and `botocore` updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` Pinpoint SMS Voice client and how `mypy-boto3` provides type hints for both the client object and specific service request/response type definitions. Code within `if TYPE_CHECKING:` blocks is for static analysis and does not run at runtime. For actual API calls, replace dummy values and ensure AWS credentials are set up.

import boto3
from typing import TYPE_CHECKING, cast
import os

# This package provides type stubs for boto3.client("pinpoint-sms-voice").
# Install `mypy-boto3-pinpoint-sms-voice` and `boto3` for type checking.

# --- Runtime code (runs without stubs, but benefits from them during development) ---
print("--- Runtime code ---")
# Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY env vars)
# or ~/.aws/credentials.

# Example of creating a boto3 client at runtime
pinpoint_client = boto3.client(
    "pinpoint-sms-voice", 
    region_name=os.environ.get('AWS_REGION', 'us-east-1')
)
print(f"Created boto3 client for {pinpoint_client.meta.service_model.service_name}")

# --- Type-checking specific code (only for static analysis tools like mypy) ---
if TYPE_CHECKING:
    from mypy_boto3_pinpoint_sms_voice import PinpointSMSVoiceClient
    from mypy_boto3_pinpoint_sms_voice.type_defs import SendMessagesRequestRequestTypeDef

    # Mypy will understand that pinpoint_client is a PinpointSMSVoiceClient
    # after the stubs are installed. An explicit cast is often not needed,
    # but can be used for stricter checking or clarity.
    typed_client: PinpointSMSVoiceClient = cast(PinpointSMSVoiceClient, pinpoint_client)

    # Example of using a type definition for a request payload. Mypy validates its structure.
    send_messages_request: SendMessagesRequestRequestTypeDef = {
        "ApplicationId": "dummy-app-id", # Replace with your actual Pinpoint Application ID
        "MessageRequest": {
            "Addresses": {"+1234567890": {"ChannelType": "SMS"}}, # Replace with real phone numbers
            "Message": {"Body": "Hello from checklist.day!"},
        },
    }
    print("\n--- Type-checking example (mypy validates this structure) ---")
    print(f"Request structure type: {type(send_messages_request)}")
    # In a type-checked environment, you'd get auto-completion and validation for:
    # typed_client.send_messages(**send_messages_request)
else:
    print("\n--- To enable full type-checking, run `mypy your_script.py` after installation ---")

print("\nQuickstart complete. Ensure AWS credentials are configured for actual API calls.")

view raw JSON →