Examples#
Auto-generated documentation for MTurk type annotations stubs module mypy-boto3-mturk.
Client#
Implicit type annotations#
Can be used with boto3-stubs[mturk]
package installed.
Write your MTurk
code as usual,
type checking and code completion should work out of the box.
Client method usage example#
# MTurkClient usage example
from boto3.session import Session
session = Session()
client = session.client("mturk") # (1)
result = client.create_hit() # (2)
- client: MTurkClient
- result: CreateHITResponseTypeDef
Paginator usage example#
# ListAssignmentsForHITPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("mturk") # (1)
paginator = client.get_paginator("list_assignments_for_hit") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: MTurkClient
- paginator: ListAssignmentsForHITPaginator
- item: ListAssignmentsForHITResponseTypeDef
Explicit type annotations#
With boto3-stubs-lite[mturk]
or a standalone mypy_boto3_mturk
package, you have to explicitly specify client: MTurkClient
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#
# MTurkClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_mturk.client import MTurkClient
from mypy_boto3_mturk.type_defs import CreateHITResponseTypeDef
from mypy_boto3_mturk.type_defs import CreateHITRequestTypeDef
session = Session()
client: MTurkClient = session.client("mturk")
kwargs: CreateHITRequestTypeDef = {...}
result: CreateHITResponseTypeDef = client.create_hit(**kwargs)
Paginator usage example#
# ListAssignmentsForHITPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_mturk.client import MTurkClient
from mypy_boto3_mturk.paginator import ListAssignmentsForHITPaginator
from mypy_boto3_mturk.type_defs import ListAssignmentsForHITResponseTypeDef
session = Session()
client: MTurkClient = session.client("mturk")
paginator: ListAssignmentsForHITPaginator = client.get_paginator("list_assignments_for_hit")
for item in paginator.paginate(...):
item: ListAssignmentsForHITResponseTypeDef
print(item)