Skip to content

Examples#

Index > MWAA > Examples

Auto-generated documentation for MWAA type annotations stubs module mypy-boto3-mwaa.

Client#

Implicit type annotations#

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

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

# MWAAClient usage example

from boto3.session import Session


session = Session()

client = session.client("mwaa")  # (1)
result = client.create_cli_token()  # (2)
  1. client: MWAAClient
  2. result: CreateCliTokenResponseTypeDef
# ListEnvironmentsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_environments")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: MWAAClient
  2. paginator: ListEnvironmentsPaginator
  3. item: ListEnvironmentsOutputTypeDef

Explicit type annotations#

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

# MWAAClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_mwaa.client import MWAAClient
from mypy_boto3_mwaa.type_defs import CreateCliTokenResponseTypeDef
from mypy_boto3_mwaa.type_defs import CreateCliTokenRequestRequestTypeDef


session = Session()

client: MWAAClient = session.client("mwaa")

kwargs: CreateCliTokenRequestRequestTypeDef = {...}
result: CreateCliTokenResponseTypeDef = client.create_cli_token(**kwargs)
# ListEnvironmentsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_mwaa.client import MWAAClient
from mypy_boto3_mwaa.paginator import ListEnvironmentsPaginator
from mypy_boto3_mwaa.type_defs import ListEnvironmentsOutputTypeDef


session = Session()
client: MWAAClient = session.client("mwaa")

paginator: ListEnvironmentsPaginator = client.get_paginator("list_environments")
for item in paginator.paginate(...):
    item: ListEnvironmentsOutputTypeDef
    print(item)