{"id":3153,"library":"mypy-boto3-swf","title":"Type Annotations for Boto3 SWF","description":"mypy-boto3-swf provides a set of type annotations (stubs) for the boto3 SWF (Simple Workflow Service) client. It enables static type checking with tools like MyPy for `boto3` interactions, enhancing code reliability and developer experience. The library is actively maintained, with new versions released frequently in sync with `boto3` updates and `mypy-boto3-builder` developments.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","type-hints","stubs","swf","type-checking"],"install":[{"cmd":"pip install boto3 mypy-boto3-swf","lang":"bash","label":"Install `boto3` runtime and SWF stubs"}],"dependencies":[{"reason":"This package provides type stubs for the 'boto3' library. 'boto3' itself must be installed for runtime execution.","package":"boto3","optional":false}],"imports":[{"note":"Import for type-hinting the boto3 SWF client object.","symbol":"SWFClient","correct":"from mypy_boto3_swf.client import SWFClient"},{"note":"Import for type-hinting specific response objects or other TypeDefs.","symbol":"ListDomainsResponseTypeDef","correct":"from mypy_boto3_swf.type_defs import ListDomainsResponseTypeDef"},{"note":"The actual client object comes from `boto3`; `mypy-boto3-swf` provides only the type definitions for it.","wrong":"from mypy_boto3_swf import client as swf_client","symbol":"boto3.client('swf')","correct":"import boto3; client: SWFClient = boto3.client('swf')"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_swf.client import SWFClient\nfrom mypy_boto3_swf.type_defs import ListDomainsResponseTypeDef, DomainInfoTypeDef\n\n# Create a typed SWF client\n# Note: boto3 itself needs to be installed, mypy-boto3-swf only provides type stubs.\nclient: SWFClient = boto3.client(\"swf\")\n\ntry:\n    # List registered domains and type-hint the response\n    response: ListDomainsResponseTypeDef = client.list_domains(\n        registrationStatus=\"REGISTERED\",\n        maximumPageSize=5\n    )\n    print(f\"Registered SWF Domains: {response.get('domainInfos', [])}\")\n\n    # Example of processing specific domain info with a TypeDef\n    def process_domain_info(domain_info: DomainInfoTypeDef) -> None:\n        print(f\"Domain Name: {domain_info['name']}, Status: {domain_info['status']}\")\n\n    if 'domainInfos' in response and response['domainInfos']:\n        process_domain_info(response['domainInfos'][0])\n\nexcept Exception as e:\n    print(f\"Error listing domains: {e}\")\n","lang":"python","description":"This example demonstrates how to initialize a type-hinted SWF client using `boto3.client` and then use it with `mypy-boto3-swf`'s stubs for static analysis. It shows how to import and apply `SWFClient` for the client object and `ListDomainsResponseTypeDef` for API call responses, ensuring type safety for your `boto3` interactions."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Python 3.8 support has been officially removed starting with `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-swf` 1.42.3). Projects using these stubs now require Python 3.9 or higher.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-swf >=1.42.3"},{"fix":"Ensure your project's `pyproject.toml` or `setup.cfg` is correctly configured for PEP 561 stub packages, and update your type checker to a recent version.","message":"All `mypy-boto3` packages, including `mypy-boto3-swf`, migrated to PEP 561 compliant distributions with `mypy-boto3-builder` 8.12.0. This might affect how type checkers locate and use stubs in specific build or environment configurations.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0, mypy-boto3-swf >=1.42.3"},{"fix":"Always ensure both `boto3` and `mypy-boto3-swf` are installed in your project (e.g., `pip install boto3 mypy-boto3-swf`).","message":"`mypy-boto3-swf` provides *only* type annotations (stubs). It does not include the `boto3` runtime itself. For your code to run, you must install `boto3` as well.","severity":"gotcha","affected_versions":"All"},{"fix":"Replace `mypy-boto3` with `mypy-boto3-<service>` packages for specific AWS services you use, e.g., `pip install mypy-boto3-swf`.","message":"Older projects using the monolithic `mypy-boto3` package for all services should migrate to service-specific stub packages like `mypy-boto3-swf`. The builder changed to separate products in 8.9.0.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0 (for generating), users migrating from older `mypy-boto3` monolithic package."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}