Skip to content

Examples#

Index > SWF > Examples

Auto-generated documentation for SWF type annotations stubs module mypy-boto3-swf.

Client#

Implicit type annotations#

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

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

# SWFClient usage example

from boto3.session import Session


session = Session()

client = session.client("swf")  # (1)
result = client.count_closed_workflow_executions()  # (2)
  1. client: SWFClient
  2. result: WorkflowExecutionCountTypeDef
# GetWorkflowExecutionHistoryPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("get_workflow_execution_history")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: SWFClient
  2. paginator: GetWorkflowExecutionHistoryPaginator
  3. item: HistoryTypeDef

Explicit type annotations#

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

# SWFClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_swf.client import SWFClient
from mypy_boto3_swf.type_defs import WorkflowExecutionCountTypeDef
from mypy_boto3_swf.type_defs import CountClosedWorkflowExecutionsInputRequestTypeDef


session = Session()

client: SWFClient = session.client("swf")

kwargs: CountClosedWorkflowExecutionsInputRequestTypeDef = {...}
result: WorkflowExecutionCountTypeDef = client.count_closed_workflow_executions(**kwargs)
# GetWorkflowExecutionHistoryPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_swf.client import SWFClient
from mypy_boto3_swf.paginator import GetWorkflowExecutionHistoryPaginator
from mypy_boto3_swf.type_defs import HistoryTypeDef


session = Session()
client: SWFClient = session.client("swf")

paginator: GetWorkflowExecutionHistoryPaginator = client.get_paginator("get_workflow_execution_history")
for item in paginator.paginate(...):
    item: HistoryTypeDef
    print(item)