Skip to content

Examples#

Index > SFN > Examples

Auto-generated documentation for SFN type annotations stubs module mypy-boto3-stepfunctions.

Client#

Implicit type annotations#

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

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

# SFNClient usage example

from boto3.session import Session


session = Session()

client = session.client("stepfunctions")  # (1)
result = client.create_activity()  # (2)
  1. client: SFNClient
  2. result: CreateActivityOutputTypeDef
# GetExecutionHistoryPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("get_execution_history")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: SFNClient
  2. paginator: GetExecutionHistoryPaginator
  3. item: GetExecutionHistoryOutputTypeDef

Explicit type annotations#

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

# SFNClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_stepfunctions.client import SFNClient
from mypy_boto3_stepfunctions.type_defs import CreateActivityOutputTypeDef
from mypy_boto3_stepfunctions.type_defs import CreateActivityInputRequestTypeDef


session = Session()

client: SFNClient = session.client("stepfunctions")

kwargs: CreateActivityInputRequestTypeDef = {...}
result: CreateActivityOutputTypeDef = client.create_activity(**kwargs)
# GetExecutionHistoryPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_stepfunctions.client import SFNClient
from mypy_boto3_stepfunctions.paginator import GetExecutionHistoryPaginator
from mypy_boto3_stepfunctions.type_defs import GetExecutionHistoryOutputTypeDef


session = Session()
client: SFNClient = session.client("stepfunctions")

paginator: GetExecutionHistoryPaginator = client.get_paginator("get_execution_history")
for item in paginator.paginate(...):
    item: GetExecutionHistoryOutputTypeDef
    print(item)