Skip to content

Examples#

Index > WorkMail > Examples

Auto-generated documentation for WorkMail type annotations stubs module mypy-boto3-workmail.

Client#

Implicit type annotations#

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

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

# WorkMailClient usage example

from boto3.session import Session


session = Session()

client = session.client("workmail")  # (1)
result = client.assume_impersonation_role()  # (2)
  1. client: WorkMailClient
  2. result: AssumeImpersonationRoleResponseTypeDef
# ListAliasesPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_aliases")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: WorkMailClient
  2. paginator: ListAliasesPaginator
  3. item: ListAliasesResponseTypeDef

Explicit type annotations#

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

# WorkMailClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_workmail.client import WorkMailClient
from mypy_boto3_workmail.type_defs import AssumeImpersonationRoleResponseTypeDef
from mypy_boto3_workmail.type_defs import AssumeImpersonationRoleRequestRequestTypeDef


session = Session()

client: WorkMailClient = session.client("workmail")

kwargs: AssumeImpersonationRoleRequestRequestTypeDef = {...}
result: AssumeImpersonationRoleResponseTypeDef = client.assume_impersonation_role(**kwargs)
# ListAliasesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_workmail.client import WorkMailClient
from mypy_boto3_workmail.paginator import ListAliasesPaginator
from mypy_boto3_workmail.type_defs import ListAliasesResponseTypeDef


session = Session()
client: WorkMailClient = session.client("workmail")

paginator: ListAliasesPaginator = client.get_paginator("list_aliases")
for item in paginator.paginate(...):
    item: ListAliasesResponseTypeDef
    print(item)