Type Annotations for boto3 Voice ID
mypy-boto3-voice-id provides static type annotations for the AWS Voice ID service within the `boto3` library. It enhances developer experience with tools like MyPy, Pyright, and IDEs, offering features like autocompletion and static type checking for `boto3.client('voice-id')` calls. This package, currently at version 1.42.3, is automatically generated by the `youtype/mypy_boto3_builder` project, ensuring type definitions are kept up-to-date with the corresponding `boto3` releases.
Warnings
- breaking The underlying `mypy_boto3_builder` project (which generates this package) removed support for Python 3.8 in version 8.12.0. `mypy-boto3-voice-id` versions generated with `builder` 8.12.0 or newer require Python 3.9 or higher.
- breaking In `mypy_boto3_builder` version 8.9.0, the naming convention for TypeDefs used for packed method arguments was shortened. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. This affects explicit type hints in your code.
- gotcha When using `TYPE_CHECKING` guards to conditionally import type stubs (a common pattern for production deployments), Pylint may report `undefined-variable` errors for the type-hinted objects.
- gotcha PyCharm has known performance issues when dealing with Python's `Literal` overloads, which are extensively used in `mypy-boto3` type stubs. This can lead to slower IDE performance.
Install
-
pip install mypy-boto3-voice-id -
pip install 'boto3-stubs[voice-id]'
Imports
- VoiceIDClient
from mypy_boto3_voice_id.client import VoiceIDClient
- VoiceIDPaginator
from mypy_boto3_voice_id.paginators import VoiceIDPaginator
- CreateDomainRequestTypeDef
from mypy_boto3_voice_id.type_defs import CreateDomainRequestTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
# Recommended: Use TYPE_CHECKING to avoid runtime dependency on mypy-boto3-voice-id
if TYPE_CHECKING:
from mypy_boto3_voice_id.client import VoiceIDClient
from mypy_boto3_voice_id.type_defs import ListDomainsResponseTypeDef
def list_voice_id_domains():
# Type-hint the boto3 client for static analysis
client: VoiceIDClient = boto3.client("voice-id")
# The response will also be type-checked
response: ListDomainsResponseTypeDef = client.list_domains()
print("Voice ID Domains:")
for domain in response.get("DomainSummaries", []):
print(f" ID: {domain['DomainId']}, Name: {domain['Name']}")
if __name__ == "__main__":
# Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
# or AWS CLI config for this to run successfully.
list_voice_id_domains()