{"id":3356,"library":"mypy-boto3-detective","title":"mypy-boto3-detective","description":"mypy-boto3-detective provides type annotations for the AWS boto3 Detective service, enhancing static analysis for Python applications using mypy. It's part of the `mypy-boto3-builder` project, which generates stubs for all boto3 services. The library receives frequent updates, typically aligning with new boto3 and botocore releases to ensure up-to-date type definitions.","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","detective","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-detective boto3","lang":"bash","label":"Install stubs and boto3"}],"dependencies":[{"reason":"mypy-boto3-detective provides type stubs for boto3; boto3 itself must be installed for runtime execution.","package":"boto3","optional":false}],"imports":[{"note":"Imports the type for the Detective service client. Specific TypeDefs can be imported from `mypy_boto3_detective.type_defs`.","symbol":"DetectiveClient","correct":"from mypy_boto3_detective import DetectiveClient"}],"quickstart":{"code":"import os\nfrom typing import TYPE_CHECKING\n\nimport boto3\n\n# Ensure boto3 is installed: pip install boto3\n\nif TYPE_CHECKING:\n    from mypy_boto3_detective import DetectiveClient\n    from mypy_boto3_detective.type_defs import ListGraphsResponseTypeDef\n\n\ndef get_detective_client() -> DetectiveClient:\n    # Use environment variables or other boto3 config for credentials\n    return boto3.client(\n        \"detective\",\n        aws_access_key_id=os.environ.get(\"AWS_ACCESS_KEY_ID\", \"\"),\n        aws_secret_access_key=os.environ.get(\"AWS_SECRET_ACCESS_KEY\", \"\"),\n        region_name=os.environ.get(\"AWS_DEFAULT_REGION\", \"us-east-1\")\n    )\n\n\nclient = get_detective_client()\n\ntry:\n    # Example API call with type annotation for the response\n    response: ListGraphsResponseTypeDef = client.list_graphs()\n    print(\"Successfully listed Detective graphs:\")\n    for graph in response.get(\"GraphList\", []):\n        print(f\"  - Graph ARN: {graph['Arn']}\")\nexcept Exception as e:\n    print(f\"Error listing Detective graphs: {e}\")\n\n","lang":"python","description":"Demonstrates how to initialize a boto3 Detective client and use the provided type stubs for type-checking API responses. This example assumes `boto3` is installed and AWS credentials are configured (e.g., via environment variables)."},"warnings":[{"fix":"Upgrade your project's Python interpreter to 3.9 or higher.","message":"Python 3.8 support has been removed across all `mypy-boto3-*` packages with `mypy-boto3-builder` version 8.12.0. Projects using these stubs must target Python 3.9 or newer.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder and generated packages"},{"fix":"Ensure `boto3` is included in your project's dependencies (e.g., `pip install boto3 mypy-boto3-detective`).","message":"`mypy-boto3-detective` provides only type stubs for static analysis. The actual `boto3` library must be installed separately for your application to run at runtime. Failure to install `boto3` will result in runtime import errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Regularly update both `boto3` and `mypy-boto3-detective` to their latest compatible versions. Consult the `mypy-boto3-builder` documentation for version compatibility guidelines.","message":"Mismatched versions between `boto3` and `mypy-boto3-detective` can lead to incorrect or incomplete type checking. It is recommended to keep their versions aligned as closely as possible, especially after significant boto3 updates.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review and update type annotation names for requests, responses, and other TypeDefs according to the new naming conventions if you encounter `NameError` or `mypy` errors related to missing types.","message":"Type definition names generated by `mypy-boto3-builder` were shortened in version 8.9.0 (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If upgrading from older stub versions, existing type annotations might require renaming.","severity":"gotcha","affected_versions":"mypy-boto3-builder >=8.9.0 and generated packages"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}