Type Annotations for boto3 SecurityHub
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
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. If you are using Python 3.8, you must upgrade to Python 3.9 or newer, or pin to an older `mypy-boto3-builder` release (and corresponding `mypy-boto3-*` packages).
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0. Some TypeDef names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`), and conflicting postfixes were reordered. Code explicitly referencing these generated type definitions may break.
- gotcha This package provides only type annotations for `boto3`'s SecurityHub service. It does *not* include the `boto3` library itself. You must install `boto3` separately for your code to function at runtime.
- gotcha While `mypy-boto3-securityhub` versions generally aim to match corresponding `boto3` versions, minor discrepancies or specific `requires_dist` in PyPI metadata can lead to `boto3` version incompatibility. Always ensure your `mypy-boto3-securityhub` package is compatible with your installed `boto3` version to avoid type checking errors or runtime issues.
Install
-
pip install mypy-boto3-securityhub -
pip install 'boto3-stubs[securityhub]'
Imports
- SecurityHubClient
from mypy_boto3_securityhub.client import SecurityHubClient
- SecurityHubServiceResource
from mypy_boto3_securityhub.service_resource import SecurityHubServiceResource
- DescribeStandardsPaginator
from mypy_boto3_securityhub.paginator import DescribeStandardsPaginator
- AcceptAdministratorInvitationRequestRequestTypeDef
from mypy_boto3_securityhub.type_defs import AcceptAdministratorInvitationRequestRequestTypeDef
Quickstart
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}")