mypy-boto3-security-ir Type Annotations
This library provides type annotations (stubs) for the `boto3` AWS Security Incident Response service client. It enhances development experience by enabling static type checking with tools like MyPy, catching potential errors early. Currently at version 1.42.3, this package is part of the `mypy-boto3` ecosystem, which generates new versions frequently to keep up with AWS service updates and `boto3` releases.
Warnings
- breaking Python 3.8 support has been removed since `mypy-boto3-builder` version 8.12.0. All generated stubs, including `mypy-boto3-security-ir`, now require Python 3.9 or newer.
- breaking All `mypy-boto3` packages migrated to PEP 561 packaging (namespace packages) in `mypy-boto3-builder` 8.12.0. This change affects how MyPy might locate packages, especially in complex project structures.
- gotcha `mypy-boto3-security-ir` provides *only* type stubs. For runtime functionality, the `boto3` library itself must be installed alongside the stub package.
- gotcha The service name passed to `boto3.client()` must exactly match the expected string, which is `'security-incident-response'` for this service. Mismatches will result in runtime errors from `boto3` and potentially incorrect type hints if a different stub package is inadvertently used.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Specifically, `RequestRequestTypeDef` was shortened to `RequestTypeDef`, and `ExtraRequestTypeDef` became `RequestExtraTypeDef`. If you directly import or refer to these generated TypeDef names, your code might break.
Install
-
pip install boto3 mypy-boto3-security-ir
Imports
- SecurityIncidentResponseClient
from mypy_boto3_security_ir.client import SecurityIncidentResponseClient
- SecurityIncidentResponseServiceName
from mypy_boto3_security_ir.type_defs import SecurityIncidentResponseServiceName
- ListIncidentRecordsOutputTypeDef
from mypy_boto3_security_ir.type_defs import ListIncidentRecordsOutputTypeDef
Quickstart
import boto3
from mypy_boto3_security_ir.client import SecurityIncidentResponseClient
from mypy_boto3_security_ir.type_defs import ListIncidentRecordsOutputTypeDef
import os
# Ensure boto3 is configured, e.g., via environment variables or ~/.aws/credentials
# For demonstration, we'll use a dummy client, but in real-world, provide credentials.
# Boto3 client initialization with type hint
client: SecurityIncidentResponseClient = boto3.client(
"security-incident-response",
region_name=os.environ.get('AWS_REGION', 'us-east-1'),
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'dummy'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'dummy'),
)
# Call a method and type hint its output
try:
response: ListIncidentRecordsOutputTypeDef = client.list_incident_records()
print("Successfully listed incident records (or empty list if none):", response.get('incidentRecords'))
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure your AWS credentials and region are correctly configured and you have permissions.")