{"id":3365,"library":"mypy-boto3-inspector","title":"mypy-boto3-inspector: AWS Inspector Type Stubs for Boto3","description":"mypy-boto3-inspector provides PEP 561 compliant type annotations (stubs) for the AWS Inspector service client in boto3, enabling static type checking with tools like MyPy. It is part of the `mypy-boto3-builder` ecosystem, which generates stubs for all AWS services. The library is actively maintained with frequent updates following boto3 and AWS API changes.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hinting","stubs","inspector","typescript"],"install":[{"cmd":"pip install mypy-boto3-inspector","lang":"bash","label":"Install service stubs"},{"cmd":"pip install boto3 mypy","lang":"bash","label":"Install runtime (boto3) and type checker (mypy)"}],"dependencies":[{"reason":"Required for advanced type features, especially on older Python versions.","package":"typing-extensions","optional":false},{"reason":"Provides core boto3 type definitions that this service stub builds upon.","package":"boto3-stubs-core","optional":false},{"reason":"This package provides type stubs; boto3 is required at runtime to execute AWS API calls.","package":"boto3","optional":true},{"reason":"Required to perform static type checking of your Python code against the provided stubs.","package":"mypy","optional":true}],"imports":[{"note":"Imports the type hint for the Inspector service client.","symbol":"InspectorClient","correct":"from mypy_boto3_inspector.client import InspectorClient"},{"note":"Imports specific TypeDef for response bodies, crucial for precise type checking of API responses.","symbol":"DescribeAssessmentRunsResponseTypeDef","correct":"from mypy_boto3_inspector.type_defs import DescribeAssessmentRunsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_inspector.client import InspectorClient\nfrom mypy_boto3_inspector.type_defs import DescribeAssessmentRunsResponseTypeDef\nimport os\n\ndef get_inspector_assessment_runs() -> DescribeAssessmentRunsResponseTypeDef:\n    # Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)\n    # This example requires 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_REGION_NAME'\n    # to be set for boto3 to authenticate.\n    if not all(os.environ.get(key) for key in ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_REGION_NAME']):\n        print(\"Warning: AWS credentials not found in environment. Using default session config.\")\n\n    client: InspectorClient = boto3.client(\"inspector\")\n    print(\"Attempting to describe AWS Inspector assessment runs...\")\n    response = client.describe_assessment_runs()\n    print(f\"Found {len(response['assessmentRuns'])} assessment runs.\")\n    # MyPy will now correctly type-check 'response' against DescribeAssessmentRunsResponseTypeDef\n    # For example, response['assessmentRuns'] is correctly typed as a list of AssessmentRunTypeDef\n    return response\n\nif __name__ == \"__main__\":\n    try:\n        result = get_inspector_assessment_runs()\n        # You can now safely access typed attributes\n        if result['assessmentRuns']:\n            print(f\"First assessment run ARN: {result['assessmentRuns'][0]['arn']}\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to use the type stubs for the AWS Inspector client with boto3. It shows importing the client type and a specific response TypeDef, then using them to type-hint a boto3 client and its method return values. This allows MyPy to catch potential type mismatches or incorrect attribute access at compile time."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. (The `mypy-boto3-inspector` package version itself reflects the builder version it was generated with).","message":"Support for Python 3.8 was removed in version 8.12.0 of the `mypy-boto3-builder` ecosystem, affecting all generated stub packages.","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Review and update any custom type hints that reference specific `TypeDef` names. Consult the `mypy-boto3` documentation or regenerate stubs if you encounter `NameError` for TypeDefs.","message":"TypeDef naming conventions changed in version 8.9.0, specifically for packed method arguments (shorter names) and conflicting `Extra` postfixes (moved to end). This can break existing type hints.","severity":"breaking","affected_versions":">=8.9.0"},{"fix":"Ensure `pip install boto3` is part of your project's dependencies.","message":"`mypy-boto3-inspector` provides *type stubs only*. You must install `boto3` separately for your code to execute against the actual AWS API.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If your service's stubs fail to import or build, consult the latest `mypy-boto3-builder` release notes on GitHub and PyPI for potential service name changes or deprecations, and update your `pip install` commands and import paths accordingly.","message":"AWS service names can sometimes change or be deprecated within the `mypy-boto3` ecosystem (e.g., `sms-voice` became `pinpoint-sms-voice`). While `inspector` is stable, always check release notes for your specific service if imports or package names stop working.","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"}