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.
Client method usage example#
# STSClient usage example
from boto3.session import Session
session = Session()
client = session.client("sts") # (1)
result = client.assume_role() # (2)
- client: STSClient
- 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.
Client method usage example#
# 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 AssumeRoleRequestTypeDef
session = Session()
client: STSClient = session.client("sts")
kwargs: AssumeRoleRequestTypeDef = {...}
result: AssumeRoleResponseTypeDef = client.assume_role(**kwargs)