mypy-boto3-synthetics Type Stubs for AWS Synthetics

1.42.3 · active · verified Sat Apr 11

mypy-boto3-synthetics provides comprehensive type annotations for the AWS Synthetics service within the boto3 library. It enables static type checking with tools like MyPy and Pyright, enhancing developer experience with features such as auto-completion and early bug detection in IDEs like VSCode and PyCharm. The package, currently at version 1.42.3, is generated by mypy-boto3-builder and is actively maintained, with updates often aligned with boto3 releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted AWS Synthetics client and use it to call an API method (e.g., `get_canary`). Explicit type annotations are shown for clarity and to ensure full type checking capabilities.

import boto3
from mypy_boto3_synthetics.client import SyntheticsClient
from mypy_boto3_synthetics.type_defs import GetCanaryResponseTypeDef


def get_synthetics_client() -> SyntheticsClient:
    """Returns a type-hinted AWS Synthetics client."""
    session = boto3.Session()
    client: SyntheticsClient = session.client("synthetics")
    return client


if __name__ == "__main__":
    synthetics_client = get_synthetics_client()

    try:
        canary_name = "my-test-canary"
        response: GetCanaryResponseTypeDef = synthetics_client.get_canary(Name=canary_name)
        print(f"Successfully retrieved canary '{canary_name}':")
        print(response)
    except synthetics_client.exceptions.NotFoundException:
        print(f"Canary '{canary_name}' not found.")
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →