{"id":3366,"library":"mypy-boto3-iotevents","title":"Type annotations for boto3 IoTEvents","description":"mypy-boto3-iotevents provides type annotations for the boto3 IoTEvents service (version 1.42.3), generated by mypy-boto3-builder 8.12.0. It enhances developer experience by enabling static type checking with tools like MyPy, Pyright, VSCode, and PyCharm, improving code quality, readability, and allowing for early detection of potential runtime errors in AWS SDK for Python (boto3) interactions.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","typing","iotevents","stubs","type-hints"],"install":[{"cmd":"pip install boto3 mypy-boto3-iotevents","lang":"bash","label":"Install with boto3"}],"dependencies":[{"reason":"This package provides type stubs for the boto3 library, which must be installed separately for runtime functionality.","package":"boto3","optional":false},{"reason":"Required for static type checking of Python code.","package":"mypy","optional":true},{"reason":"Alternative static type checker.","package":"pyright","optional":true}],"imports":[{"symbol":"IoTEventsClient","correct":"from mypy_boto3_iotevents import IoTEventsClient"},{"note":"Type definitions for service responses are typically found in the `type_defs` submodule.","symbol":"ListDetectorModelsResponseTypeDef","correct":"from mypy_boto3_iotevents.type_defs import ListDetectorModelsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_iotevents import IoTEventsClient\nfrom mypy_boto3_iotevents.type_defs import ListDetectorModelsResponseTypeDef\nimport os\n\ndef get_iotevents_client() -> IoTEventsClient:\n    \"\"\"Initializes and returns a type-hinted IoTEvents client.\"\"\"\n    # AWS credentials are typically configured via environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)\n    # or AWS CLI configuration.\n    # Using os.environ.get for example purposes; in production, boto3 handles credential resolution.\n    client: IoTEventsClient = boto3.client(\n        \"iotevents\",\n        region_name=os.environ.get('AWS_REGION', 'us-east-1')\n    )\n    return client\n\nif __name__ == \"__main__\":\n    try:\n        iotevents_client = get_iotevents_client()\n        print(\"Successfully initialized IoTEvents client.\")\n\n        # Example: List detector models with type-hinted response\n        response: ListDetectorModelsResponseTypeDef = iotevents_client.list_detector_models()\n        print(f\"Found {len(response.get('detectorModelSummaries', []))} detector models.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize a type-hinted boto3 IoTEvents client and make a simple API call. It shows how to import the specific client type and a response type definition for improved static analysis and IDE autocomplete. Ensure `boto3` is installed alongside `mypy-boto3-iotevents`."},"warnings":[{"fix":"Upgrade to Python 3.9 or newer.","message":"Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 should update their Python version or use an older version of `mypy-boto3-iotevents` if available.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder (which generates this package)"},{"fix":"Review your code for any explicit `TypeDef` imports and update names according to the latest definitions.","message":"In `mypy-boto3-builder` version 8.9.0, some TypeDef names were shortened or reordered (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). While not specific to `iotevents`, this general change in naming conventions for packed method arguments can break existing type hints if specific TypeDefs are imported.","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder (which generates this package)"},{"fix":"Always add explicit type annotations when creating boto3 clients or resources.","message":"For optimal type checking and IDE support (especially in VSCode and PyCharm), it is recommended to explicitly type annotate `boto3.client()` and `boto3.session.client()` calls with the imported client type (e.g., `client: IoTEventsClient = boto3.client(\"iotevents\")`).","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure `boto3` is installed via `pip install boto3` alongside `mypy-boto3-iotevents`.","message":"This package only provides type annotations. You must install the `boto3` library separately for your code to function at runtime.","severity":"gotcha","affected_versions":"All"},{"fix":"Consider `boto3-stubs-lite`, an alternative type checker (MyPy/Pyright), or adjusting PyCharm's type checking settings.","message":"PyCharm users might experience slow performance with `Literal` overloads (issue PY-40997). If this occurs, `boto3-stubs-lite` is suggested as a more RAM-friendly alternative (though it requires more explicit type annotations), or disabling PyCharm's type checker and relying on an external tool like MyPy or Pyright.","severity":"gotcha","affected_versions":"All, specifically PyCharm users"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}