Skip to content

Examples#

Index > STS > Examples

Auto-generated documentation for STS type annotations stubs module types-aiobotocore-sts.

Client#

Implicit type annotations#

Can be used with types-aiobotocore[sts] package installed.

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

# STSClient usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("sts") as client:  # (1)
    result = await client.assume_role()  # (2)
  1. client: STSClient
  2. result: AssumeRoleResponseTypeDef

Explicit type annotations#

With types-aiobotocore-lite[sts] or a standalone types_aiobotocore_sts package, you have to explicitly specify client: STSClient 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.

# STSClient usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_sts.client import STSClient
from types_aiobotocore_sts.type_defs import AssumeRoleResponseTypeDef
from types_aiobotocore_sts.type_defs import AssumeRoleRequestRequestTypeDef


session = get_session()

async with session.create_client("sts") as client:
    client: STSClient
    kwargs: AssumeRoleRequestRequestTypeDef = {...}
    result: AssumeRoleResponseTypeDef = await client.assume_role(**kwargs)