Install & Compatibility
Where this runs
tested against v1.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.586s · 51.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.8s · import 0.546s · 52MB
50MB installed
● package 50MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PollyClient
✓ from mypy_boto3_polly.client import PollyClient
✗ from boto3.client import PollyClient
While `boto3.client('polly')` returns a client object, directly importing `PollyClient` from `boto3.client` does not provide the specific type hints. The `mypy-boto3-polly` package provides the fully typed `PollyClient`.
DescribeVoicesPaginator
✓ from mypy_boto3_polly.paginator import DescribeVoicesPaginator
AudioEventTypeDef
✓ from mypy_boto3_polly.type_defs import AudioEventTypeDef
This quickstart demonstrates how to use the `mypy-boto3-polly` type stubs with a standard boto3 client. It explicitly types the Polly client and its response, allowing type checkers to validate usage and provide intelligent autocomplete.
import boto3
from mypy_boto3_polly.client import PollyClient
from mypy_boto3_polly.type_defs import SynthesizeSpeechOutputTypeDef
import os
def synthesize_and_save(text: str, output_path: str):
# Ensure AWS credentials are available (e.g., via environment variables or ~/.aws/credentials)
# For local testing, ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION are set.
# Explicitly type the client for full type-checking benefits
client: PollyClient = boto3.client("polly", region_name=os.environ.get('AWS_REGION', 'us-east-1'))
response: SynthesizeSpeechOutputTypeDef = client.synthesize_speech(
Text=text,
OutputFormat='mp3',
VoiceId='Joanna'
)
# In a real application, handle the 'AudioStream' which is a StreamingBody
# For this quickstart, we'll just demonstrate the typing of the response.
if response['AudioStream']:
print(f"Successfully received audio stream with content type: {response['ContentType']}")
# Example: to save to a file (simplified, error handling omitted)
# with open(output_path, 'wb') as f:
# f.write(response['AudioStream'].read())
# print(f"Audio saved to {output_path}")
else:
print("No audio stream received.")
# Example usage (requires AWS setup for actual execution)
# synthesize_and_save("Hello, world! This is a typed Polly client example.", "output.mp3")
print("Quickstart code demonstrates type hinting for boto3 Polly client.")
Debug
Known issues
breakingSupport for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 or older will need to upgrade their Python version.fixUpgrade your Python environment to 3.9 or newer.
affects: >=8.12.0
breakingTypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0. This led to shorter names for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and reordered suffixes for conflicting TypeDefs. Code relying on exact TypeDef names may break.fixReview and update TypeDef imports and usage in your codebase to match the new naming conventions. Consult the `mypy-boto3-polly` documentation for the correct TypeDef names.
affects: >=8.9.0
gotcha`mypy-boto3-polly` is a stub-only package (PEP 561). It *must* be installed alongside the `boto3` library itself. Mypy and IDEs will automatically find these stubs, but if `boto3` is not present, the type stubs will have no implementation to apply to.fixAlways ensure `boto3` is installed in the same environment as `mypy-boto3-polly` (e.g., `pip install boto3 mypy-boto3-polly`).
affects: All versions
gotchaFor optimal autocomplete and type checking in some IDEs (especially older versions of PyCharm or VSCode without the Pylance extension), it is recommended to explicitly type your `boto3.client()` calls, even with stubs installed.fixWhen creating a client, explicitly add the type annotation: `client: PollyClient = boto3.client("polly")`. affects: All versions, depends on IDE/type checker configuration
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredRuntime dependency for the type stubs to be functional, as this package only provides type annotations, not the implementation.
mypyoptionalThe primary type checker for which these stubs are designed. Other type checkers like Pyright also benefit.