mypy-boto3-observabilityadmin type stubs

1.42.88 · active · verified Sat Apr 11

mypy-boto3-observabilityadmin provides type annotations for the boto3 CloudWatchObservabilityAdminService, enabling static type checking with tools like MyPy. It's part of the `mypy-boto3` ecosystem, which generates stubs for all AWS services supported by `boto3`. The current version is 1.42.88, with releases closely tracking `boto3` and `botocore` updates, often multiple times a month.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a typed `ObservabilityAdminClient` and use it. Your IDE and MyPy will now recognize the methods available on the `client` object and provide accurate type hints for arguments and return values, enhancing code quality and reducing runtime errors.

import boto3
from mypy_boto3_observabilityadmin import ObservabilityAdminClient
from mypy_boto3_observabilityadmin.type_defs import ListServiceLevelObjectivesOutputTypeDef

def get_observability_admin_client() -> ObservabilityAdminClient:
    """
    Returns a typed CloudWatchObservabilityAdminService client.
    Your IDE will provide type hints for methods and arguments on 'client'.
    """
    client: ObservabilityAdminClient = boto3.client("observabilityadmin")
    return client

if __name__ == "__main__":
    client = get_observability_admin_client()
    print(f"Successfully created a typed ObservabilityAdminClient: {type(client)}")

    # Example of a typed response (requires AWS credentials and permissions)
    try:
        # MyPy will ensure 'response' conforms to ListServiceLevelObjectivesOutputTypeDef
        response: ListServiceLevelObjectivesOutputTypeDef = client.list_service_level_objectives()
        slo_count = len(response.get('ServiceLevelObjectives', []))
        print(f"Successfully called list_service_level_objectives. Found {slo_count} SLOs.")
    except client.exceptions.ClientError as e:
        print(f"Could not list Service Level Objectives (expected if no permissions or resources): {e}")

    print("\nThis demonstrates how `mypy-boto3-observabilityadmin` provides type hints for your boto3 client interactions.")

view raw JSON →