Type Annotations for boto3 SecurityHub

1.42.58 · active · verified Sat Apr 11

mypy-boto3-securityhub provides comprehensive type annotations for the AWS SecurityHub service client in `boto3`. It enhances development with static type checking, auto-completion, and improved error detection for AWS interactions. The library's version typically aligns with the `boto3` version it types, and it is actively developed with a regular release cadence driven by `mypy-boto3-builder` updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `SecurityHubClient` using `boto3` and perform a basic API call. Ensure `boto3` is installed and AWS credentials are configured in your environment.

import boto3
from mypy_boto3_securityhub.client import SecurityHubClient

def get_securityhub_client() -> SecurityHubClient:
    """Initializes and returns a typed AWS SecurityHub client."""
    session = boto3.Session()
    client: SecurityHubClient = session.client("securityhub")
    return client

if __name__ == "__main__":
    # Example usage (requires AWS credentials configured)
    try:
        securityhub_client = get_securityhub_client()
        response = securityhub_client.describe_standards()
        print(f"Successfully retrieved {len(response.get('Standards', []))} Security Hub standards.")
    except Exception as e:
        print(f"Error interacting with SecurityHub: {e}")

view raw JSON →