mypy-boto3-devops-guru Type Stubs
mypy-boto3-devops-guru provides type annotations for the AWS boto3 DevOps Guru service, generated with mypy-boto3-builder. It enhances type checking for boto3 clients, resources, and various service-specific data structures. The current version is 1.42.3, and it follows a frequent release cadence, often aligning with new boto3 releases and updates to the mypy-boto3-builder.
Warnings
- breaking Starting with `mypy-boto3-builder` version 8.12.0 (which generated current stubs), Python 3.8 support was removed for all generated `mypy-boto3-*` packages. Ensure your project uses Python 3.9 or newer.
- gotcha These packages provide only type stubs. You must install `boto3` (and optionally `botocore`) separately for the runtime functionality. Not installing `boto3` will lead to `ModuleNotFoundError` at runtime, even if type checks pass.
- gotcha Mismatched versions between `boto3` and `mypy-boto3-*` stubs can lead to `mypy` errors or incorrect type hints. The stubs are generated based on specific `boto3` service definitions.
- gotcha AWS service names can change over time, or have variations (e.g., `sms-voice` vs. `pinpoint-sms-voice`). This can lead to `ModuleNotFoundError` for the stub package or `botocore.exceptions.ClientError` at runtime if the service name in `boto3.client()` is incorrect.
Install
-
pip install mypy-boto3-devops-guru -
pip install boto3
Imports
- DevOpsGuruClient
from mypy_boto3_devops_guru import DevOpsGuruClient
- DescribeAccountHealthResponseTypeDef
from mypy_boto3_devops_guru.type_defs import DescribeAccountHealthResponseTypeDef
Quickstart
import boto3
from mypy_boto3_devops_guru import DevOpsGuruClient
from mypy_boto3_devops_guru.type_defs import DescribeAccountHealthResponseTypeDef
# Instantiate the boto3 client, typed with mypy-boto3 stubs
client: DevOpsGuruClient = boto3.client(
"devops-guru",
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
region_name=os.environ.get('AWS_REGION', 'us-east-1')
)
try:
# Call a service method
response: DescribeAccountHealthResponseTypeDef = client.describe_account_health()
print(f"Account health details: {response}")
except Exception as e:
print(f"Error describing account health: {e}")