{"id":3589,"library":"mypy-boto3-inspector2","title":"mypy-boto3-inspector2 Type Annotations for AWS Inspector2","description":"mypy-boto3-inspector2 provides up-to-date type annotations for the AWS Inspector2 service in boto3, enabling static type checking with tools like MyPy. It ensures your boto3 code interacting with Inspector2 is type-safe and helps catch potential errors at development time. The library is part of the mypy-boto3-builder project, which frequently releases new versions to keep pace with boto3 updates and AWS API changes. The current version is 1.42.49.","status":"active","version":"1.42.49","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-annotations","inspector2","static-analysis"],"install":[{"cmd":"pip install boto3 mypy-boto3-inspector2","lang":"bash","label":"Install with boto3"}],"dependencies":[{"reason":"This library provides type annotations for the boto3 library. boto3 itself must be installed to use the AWS SDK functionality.","package":"boto3"}],"imports":[{"note":"Type annotations should be imported from the specific `mypy_boto3_inspector2` package, not directly from `boto3`.","wrong":"from boto3.client import Inspector2","symbol":"Inspector2Client","correct":"from mypy_boto3_inspector2.client import Inspector2Client"},{"note":"TypedDicts and other service-specific type definitions are located in the `type_defs` submodule of `mypy_boto3_inspector2`.","wrong":"from boto3.types.inspector2 import ListFindingsFilter","symbol":"ListFindingsFilterTypeDef","correct":"from mypy_boto3_inspector2.type_defs import ListFindingsFilterTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_inspector2.client import Inspector2Client\nfrom mypy_boto3_inspector2.type_defs import ListFindingsFilterTypeDef\n\ndef get_inspector2_findings(region: str) -> None:\n    # Initialize a boto3 client with type annotations\n    client: Inspector2Client = boto3.client(\"inspector2\", region_name=region)\n\n    # Define a filter using a TypedDict for type safety\n    filters: ListFindingsFilterTypeDef = {\n        \"findingStatus\": {\"comparison\": \"EQUALS\", \"value\": \"ACTIVE\"}\n    }\n\n    print(f\"Listing active Inspector2 findings in {region}...\")\n    try:\n        response = client.list_findings(filter=filters, maxResults=5)\n        for finding in response.get(\"findings\", []):\n            print(f\"  Finding ARN: {finding.get('findingArn')}, Status: {finding.get('status')}\")\n        print(f\"Total findings listed: {len(response.get('findings', []))}\")\n    except client.exceptions.ClientError as e:\n        print(f\"Error listing findings: {e}\")\n\n# Example usage (ensure AWS credentials are configured or in environment)\nif __name__ == \"__main__\":\n    get_inspector2_findings(\"us-east-1\")","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-inspector2` to add type annotations to your boto3 Inspector2 client. It shows importing the `Inspector2Client` type and a `TypeDef` for filtering, ensuring that your client calls and parameter structures are type-checked by MyPy."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or a later version.","message":"Python 3.8 support has been removed for `mypy-boto3-builder` generated packages as of version 8.12.0. Users on Python 3.8 must upgrade to Python 3.9 or newer to receive updates.","severity":"breaking","affected_versions":">=8.12.0 (builder), all generated stubs since then"},{"fix":"If you directly import specific `TypeDef` classes, check the `type_defs.pyi` file for the correct, potentially shorter, names.","message":"TypeDefs for method arguments or conflicting names might have been renamed in `mypy-boto3-builder` version 8.9.0 to use shorter names or move 'Extra' suffixes. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`.","severity":"breaking","affected_versions":">=8.9.0 (builder), potentially affecting specific `TypeDef` imports in generated stubs."},{"fix":"Ensure your type-checking tools and environment are up-to-date and compatible with PEP 561 package distribution. This is generally handled automatically by `pip` and `mypy`.","message":"The `mypy-boto3` ecosystem migrated to PEP 561 compliant packages with `mypy-boto3-builder` version 8.12.0. While `mypy` itself should handle this seamlessly, some other type checkers or tooling might have expected older stub distribution formats.","severity":"gotcha","affected_versions":">=8.12.0 (builder), all generated stubs since then"},{"fix":"Ensure both `boto3` and `mypy-boto3-inspector2` are installed: `pip install boto3 mypy-boto3-inspector2`.","message":"This library provides *only* type annotations. You must install `boto3` separately to get the actual AWS SDK functionality.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the latest `mypy-boto3` documentation or PyPI for the correct package and import paths if a service is not found or has unexpected behavior.","message":"Service names can change over time within the AWS ecosystem (e.g., `sms-voice` became `pinpoint-sms-voice`). While `inspector2` is stable, be aware that other `mypy-boto3` service packages might require updates if the underlying AWS service name changes.","severity":"gotcha","affected_versions":"All versions (general `mypy-boto3` concern)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}