mypy-boto3-pinpoint-sms-voice-v2 Type Annotations
mypy-boto3-pinpoint-sms-voice-v2 provides type annotations for the boto3 Pinpoint SMS Voice V2 service, generated by mypy-boto3-builder. These stubs enhance type checking for AWS SDK usage, preventing common runtime errors. The current version is 1.42.80, with releases synchronized with boto3 versions.
Warnings
- breaking Python 3.8 is no longer supported. The `mypy-boto3-builder` and all generated stub packages, including this one, removed support for Python 3.8 as of version 8.12.0.
- gotcha This library provides *type stubs* only. You must also install the `boto3` library for your code to execute at runtime. Without `boto3` installed, your application will fail with import errors.
- gotcha AWS has multiple services related to SMS and Voice messaging (e.g., `pinpoint-sms-voice`, `sms-voice`, `pinpoint-sms-voice-v2`). Ensure you install the `mypy-boto3-*` package that precisely matches the `boto3.client()` service name you are using. Confusing service names can lead to incorrect type hints or runtime errors.
- breaking The `mypy-boto3-builder` changed TypeDef naming conventions in version 8.9.0. Specifically, packed method arguments may use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This could affect explicit imports of TypeDefs.
Install
-
pip install mypy-boto3-pinpoint-sms-voice-v2 -
pip install boto3
Imports
- PinpointSMSVoiceV2Client
from mypy_boto3_pinpoint_sms_voice_v2.client import PinpointSMSVoiceV2Client
- Service Resource TypeDefs
from mypy_boto3_pinpoint_sms_voice_v2.type_defs import SendVoiceMessageRequestRequestTypeDef
Quickstart
import boto3
from mypy_boto3_pinpoint_sms_voice_v2.client import PinpointSMSVoiceV2Client
import os
# Instantiate a boto3 session and client
# mypy will use the installed stubs to provide type hints for 'client'
region = os.environ.get('AWS_REGION', 'us-east-1')
session = boto3.Session(region_name=region)
client: PinpointSMSVoiceV2Client = session.client("pinpoint-sms-voice-v2")
# Example of using the typed client (replace with actual values and error handling)
try:
response = client.send_voice_message(
DestinationPhoneNumber="+15551234567", # Replace with a valid E.164 number
OriginationIdentity="MyVoiceSenderId", # Your registered origination identity
MessageBody="Hello from mypy-boto3-pinpoint-sms-voice-v2!",
ConfigurationSetName="Default", # Your existing configuration set
CallerId="+15559876543" # Optional, if you have a caller ID
)
print(f"Voice message sent. Message ID: {response['MessageId']}")
except client.exceptions.ResourceNotFoundException as e:
print(f"Error: Resource not found: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")