Skip to content

Examples#

Index > SWF > Examples

Auto-generated documentation for SWF type annotations stubs module types-aiobotocore-swf.

Client#

Implicit type annotations#

Can be used with types-aiobotocore[swf] package installed.

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

Client method usage example#

# SWFClient usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("swf") as client:  # (1)
    result = await client.count_closed_workflow_executions()  # (2)
  1. client: SWFClient
  2. result: WorkflowExecutionCountTypeDef

Paginator usage example#

# GetWorkflowExecutionHistoryPaginator usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("swf") as client:  # (1)
    paginator = client.get_paginator("get_workflow_execution_history")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: SWFClient
  2. paginator: GetWorkflowExecutionHistoryPaginator
  3. item: HistoryTypeDef

Explicit type annotations#

With types-aiobotocore-lite[swf] or a standalone types_aiobotocore_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.

Client method usage example#

# SWFClient usage example with type annotations

from aiobotocore.session import get_session

from types_aiobotocore_swf.client import SWFClient
from types_aiobotocore_swf.type_defs import WorkflowExecutionCountTypeDef
from types_aiobotocore_swf.type_defs import CountClosedWorkflowExecutionsInputTypeDef


session = get_session()

async with session.create_client("swf") as client:
    client: SWFClient
    kwargs: CountClosedWorkflowExecutionsInputTypeDef = {...}
    result: WorkflowExecutionCountTypeDef = await client.count_closed_workflow_executions(**kwargs)

Paginator usage example#

# GetWorkflowExecutionHistoryPaginator usage example with type annotations

from aiobotocore.session import get_session

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


session = get_session()

async with session.create_client("swf") as client:
    client: SWFClient
    paginator: GetWorkflowExecutionHistoryPaginator = client.get_paginator("get_workflow_execution_history")
    async for item in paginator.paginate(...):
        item: HistoryTypeDef
        print(item)