Skip to content

Examples#

Index > STS > Examples

Auto-generated documentation for STS type annotations stubs module mypy-boto3-sts.

Client#

Implicit type annotations#

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

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

# STSClient usage example

from boto3.session import Session


session = Session()

client = session.client("sts")  # (1)
result = client.assume_role()  # (2)
  1. client: STSClient
  2. result: AssumeRoleResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[sts] or a standalone mypy_boto3_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 boto3.session import Session

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


session = Session()

client: STSClient = session.client("sts")

kwargs: AssumeRoleRequestRequestTypeDef = {...}
result: AssumeRoleResponseTypeDef = client.assume_role(**kwargs)