Examples#
Auto-generated documentation for Polly type annotations stubs module types-boto3-polly.
Client#
Implicit type annotations#
Can be used with types-boto3[polly]
package installed.
Write your Polly
code as usual,
type checking and code completion should work out of the box.
# PollyClient usage example
from boto3.session import Session
session = Session()
client = session.client("polly") # (1)
result = client.describe_voices() # (2)
- client: PollyClient
- result: DescribeVoicesOutputTypeDef
# DescribeVoicesPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("polly") # (1)
paginator = client.get_paginator("describe_voices") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: PollyClient
- paginator: DescribeVoicesPaginator
- item: DescribeVoicesOutputTypeDef
Explicit type annotations#
With types-boto3-lite[polly]
or a standalone types_boto3_polly
package, you have to explicitly specify client: PollyClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
# PollyClient usage example with type annotations
from boto3.session import Session
from types_boto3_polly.client import PollyClient
from types_boto3_polly.type_defs import DescribeVoicesOutputTypeDef
from types_boto3_polly.type_defs import DescribeVoicesInputRequestTypeDef
session = Session()
client: PollyClient = session.client("polly")
kwargs: DescribeVoicesInputRequestTypeDef = {...}
result: DescribeVoicesOutputTypeDef = client.describe_voices(**kwargs)
# DescribeVoicesPaginator usage example with type annotations
from boto3.session import Session
from types_boto3_polly.client import PollyClient
from types_boto3_polly.paginator import DescribeVoicesPaginator
from types_boto3_polly.type_defs import DescribeVoicesOutputTypeDef
session = Session()
client: PollyClient = session.client("polly")
paginator: DescribeVoicesPaginator = client.get_paginator("describe_voices")
for item in paginator.paginate(...):
item: DescribeVoicesOutputTypeDef
print(item)