Skip to content

Examples#

Index > Translate > Examples

Auto-generated documentation for Translate type annotations stubs module mypy-boto3-translate.

Client#

Implicit type annotations#

Can be used with boto3-stubs[translate] package installed.

Write your Translate code as usual, type checking and code completion should work out of the box.

Client method usage example#

# TranslateClient usage example

from boto3.session import Session


session = Session()

client = session.client("translate")  # (1)
result = client.create_parallel_data()  # (2)
  1. client: TranslateClient
  2. result: CreateParallelDataResponseTypeDef

Paginator usage example#

# ListTerminologiesPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("translate")  # (1)

paginator = client.get_paginator("list_terminologies")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: TranslateClient
  2. paginator: ListTerminologiesPaginator
  3. item: ListTerminologiesResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[translate] or a standalone mypy_boto3_translate package, you have to explicitly specify client: TranslateClient 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.

Client method usage example#

# TranslateClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_translate.client import TranslateClient
from mypy_boto3_translate.type_defs import CreateParallelDataResponseTypeDef
from mypy_boto3_translate.type_defs import CreateParallelDataRequestTypeDef


session = Session()

client: TranslateClient = session.client("translate")

kwargs: CreateParallelDataRequestTypeDef = {...}
result: CreateParallelDataResponseTypeDef = client.create_parallel_data(**kwargs)

Paginator usage example#

# ListTerminologiesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_translate.client import TranslateClient
from mypy_boto3_translate.paginator import ListTerminologiesPaginator
from mypy_boto3_translate.type_defs import ListTerminologiesResponseTypeDef


session = Session()
client: TranslateClient = session.client("translate")

paginator: ListTerminologiesPaginator = client.get_paginator("list_terminologies")
for item in paginator.paginate(...):
    item: ListTerminologiesResponseTypeDef
    print(item)