Type annotations for aiobotocore Step Functions
This package provides type annotations for the `aiobotocore` library's Step Functions (SFN) client. It is part of the `mypy-boto3-builder` project, which automatically generates type stubs for all `aiobotocore` services. The versioning of `types-aiobotocore-stepfunctions` aligns with the corresponding `aiobotocore` version, currently 3.4.0. The project maintains an active release cadence, driven by updates to `aiobotocore` and improvements in the `mypy-boto3-builder` itself, ensuring up-to-date type support.
Warnings
- breaking Python 3.8 is no longer supported. Packages generated by `mypy-boto3-builder` (including `types-aiobotocore-stepfunctions`) now require Python >=3.9.
- breaking The `mypy-boto3-builder`, which generates these types, migrated to PEP 561 compliant packages. While this is a standard improvement, it might affect custom build pipelines or type checker configurations that relied on older stub distribution methods.
- breaking Generated `TypeDef` names were shortened and conflicting names disambiguated in `mypy-boto3-builder` 8.9.0. If you explicitly imported specific `TypeDef` classes from previous versions of `types-aiobotocore-*` packages, their names might have changed (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).
- gotcha PyCharm users might experience slow performance and high CPU usage due to PyCharm's type checker with `Literal` overloads. It is recommended to either disable PyCharm's type checker and use `mypy` or `pyright`, or install `types-aiobotocore-lite` instead for a more RAM-friendly experience.
Install
-
pip install types-aiobotocore-stepfunctions -
pip install 'aiobotocore[stepfunctions]' 'types-aiobotocore[stepfunctions]'
Imports
- SFNClient
from types_aiobotocore_stepfunctions.client import SFNClient
- StepFunctionsServiceName
from types_aiobotocore_stepfunctions.literals import StepFunctionsServiceName
- get_session
from aiobotocore.session import get_session
- StartExecutionOutputTypeDef
from types_aiobotocore_stepfunctions.type_defs import StartExecutionOutputTypeDef
Quickstart
import asyncio
import os
from typing import TYPE_CHECKING
from aiobotocore.session import get_session
# These imports are only for type checking and will not be present at runtime
if TYPE_CHECKING:
from types_aiobotocore_stepfunctions.client import SFNClient
from types_aiobotocore_stepfunctions.type_defs import StartExecutionOutputTypeDef
async def start_step_function_execution(state_machine_arn: str, execution_name: str, input_data: str):
session = get_session()
async with session.create_client(
"stepfunctions",
region_name=os.environ.get('AWS_REGION', 'us-east-1'),
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
) as client:
# client is implicitly typed as SFNClient by mypy/pyright after installing types-aiobotocore-stepfunctions
if TYPE_CHECKING:
client: SFNClient
print(f"Starting execution '{execution_name}' for state machine '{state_machine_arn}'")
response: StartExecutionOutputTypeDef = await client.start_execution(
stateMachineArn=state_machine_arn,
name=execution_name,
input=input_data,
)
print(f"Execution ARN: {response['executionArn']}")
print(f"Start Date: {response['startDate']}")
if __name__ == "__main__":
# Replace with your actual State Machine ARN and desired execution details
STATE_MACHINE_ARN = os.environ.get('STATE_MACHINE_ARN', 'arn:aws:states:us-east-1:123456789012:stateMachine:MyStateMachine')
EXECUTION_NAME = os.environ.get('EXECUTION_NAME', 'my-test-execution-123')
INPUT_DATA = os.environ.get('INPUT_DATA', '{"key": "value"}')
asyncio.run(start_step_function_execution(STATE_MACHINE_ARN, EXECUTION_NAME, INPUT_DATA))