Examples#
Auto-generated documentation for STS type annotations stubs module types-boto3-sts.
Client#
Implicit type annotations#
Can be used with types-boto3[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)
- client: STSClient
- result: AssumeRoleResponseTypeDef
Explicit type annotations#
With types-boto3-lite[sts]
or a standalone types_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 types_boto3_sts.client import STSClient
from types_boto3_sts.type_defs import AssumeRoleResponseTypeDef
from types_boto3_sts.type_defs import AssumeRoleRequestRequestTypeDef
session = Session()
client: STSClient = session.client("sts")
kwargs: AssumeRoleRequestRequestTypeDef = {...}
result: AssumeRoleResponseTypeDef = client.assume_role(**kwargs)