{"id":3103,"library":"mypy-boto3-iot","title":"Type annotations for boto3 IoT service","description":"mypy-boto3-iot provides comprehensive type annotations for the AWS boto3 IoT service, enhancing static analysis, autocompletion, and error detection in Python projects. It is currently at version 1.42.14, generated with mypy-boto3-builder 8.12.0, and follows a release cadence aligned with boto3 updates.","status":"active","version":"1.42.14","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","iot","mypy","type-hints","stubs","cloud"],"install":[{"cmd":"pip install mypy-boto3-iot boto3","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'boto3-stubs[iot]' boto3","lang":"bash","label":"Install via boto3-stubs extras"}],"dependencies":[{"reason":"Provides the AWS SDK for Python; mypy-boto3-iot supplies type stubs for this library.","package":"boto3","optional":false}],"imports":[{"note":"The `IoTClient` type should be imported from `mypy_boto3_iot` for type checking, not directly from `boto3` which doesn't export the typed client.","wrong":"from boto3.client import IoTClient","symbol":"IoTClient","correct":"from mypy_boto3_iot import IoTClient"},{"note":"Specific paginator types are located in the `paginator` submodule.","symbol":"ListThingsPaginator","correct":"from mypy_boto3_iot.paginator import ListThingsPaginator"},{"note":"Type definitions for request/response bodies and other structures are in the `type_defs` submodule.","symbol":"AbortCriteriaTypeDef","correct":"from mypy_boto3_iot.type_defs import AbortCriteriaTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_iot import IoTClient\n    from mypy_boto3_iot.type_defs import ListThingsResponseTypeDef\n\ndef list_iot_things(region_name: str = 'us-east-1') -> ListThingsResponseTypeDef:\n    # Initialize the boto3 client (type-checked by mypy-boto3-iot)\n    client: IoTClient = boto3.client('iot', region_name=region_name)\n    \n    # Example operation: List IoT Things\n    response = client.list_things(maxResults=10)\n    \n    print(f\"Found {len(response.get('things', []))} IoT things.\")\n    for thing in response.get('things', []):\n        print(f\" - {thing['thingName']}\")\n        \n    return response\n\nif __name__ == '__main__':\n    # This assumes AWS credentials are set up (e.g., via environment variables or ~/.aws/credentials)\n    try:\n        list_iot_things()\n    except Exception as e:\n        print(f\"Error listing IoT things: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize an IoT client with type annotations and perform a basic operation like listing IoT things. It uses `TYPE_CHECKING` for conditional imports, ensuring the type stubs are only used during type checking."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Support for Python 3.8 was removed starting with `mypy-boto3-builder` version 8.12.0 (which generates `mypy-boto3-iot` 1.42.14). Projects using Python 3.8 or older will need to upgrade to Python 3.9+.","severity":"breaking","affected_versions":">=8.12.0 (builder), >=1.42.14 (mypy-boto3-iot)"},{"fix":"Ensure your type checker (e.g., Mypy, Pyright) is up-to-date and correctly configured to find PEP 561-compliant stub packages.","message":"The `mypy-boto3-builder` (and consequently `mypy-boto3-iot`) migrated to PEP 561 packages in version 8.12.0. This might change how type checkers discover packages, potentially requiring updates to `mypy` configurations or build systems that explicitly manage stubs.","severity":"breaking","affected_versions":">=8.12.0 (builder), >=1.42.14 (mypy-boto3-iot)"},{"fix":"Review your code for `TypeDef` imports and usage, and update names according to the new conventions (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`).","message":"Version 8.9.0 of `mypy-boto3-builder` introduced breaking changes to `TypeDef` naming conventions, specifically for packed method arguments (shorter names) and conflicting `Extra` postfixes (moved to the end). If you rely on specific `TypeDef` names in your type hints, they may have changed.","severity":"breaking","affected_versions":">=8.9.0 (builder)"},{"fix":"Always use explicit type annotations when defining `boto3` client or resource objects to leverage full type-checking capabilities.","message":"While `boto3-stubs` often provides implicit type annotations, explicit type annotations for client, resource, waiter, and paginator calls (e.g., `client: IoTClient = boto3.client('iot')`) are highly recommended for optimal IDE autocompletion and type checking, especially with tools like PyCharm or when using `boto3-stubs-lite`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement a fallback for type-hinted variables: `if TYPE_CHECKING: from mypy_boto3_iot import IoTClient else: IoTClient = object`.","message":"When using `typing.TYPE_CHECKING` guards to avoid runtime dependency on `mypy-boto3-iot`, Pylint may complain about undefined variables. A common workaround is to assign `object` to the type-hinted variables outside the `TYPE_CHECKING` block.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}