mypy-boto3-ssm-contacts

1.42.3 · active · verified Sat Apr 11

mypy-boto3-ssm-contacts provides comprehensive type annotations for the AWS SSM Contacts service client within the `boto3` library. It enables static type checking with tools like `mypy`, catching potential API misuse or type mismatches at development time for `boto3.client('ssm-contacts')`. This package, currently at version 1.42.3, is part of the `mypy-boto3` ecosystem which generates stubs for all AWS services, updated frequently to mirror `boto3` and AWS API changes, with a rapid release cadence driven by the `mypy-boto3-builder`.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `SSMContactsClient` type to annotate your `boto3` client, enabling static type checking for your SSM Contacts operations. It also shows how to import and use specific `TypeDef` objects for response structures.

import boto3
from mypy_boto3_ssm_contacts.client import SSMContactsClient
from mypy_boto3_ssm_contacts.type_defs import ListContactsResponseTypeDef
from typing import TYPE_CHECKING

# Ensure boto3 is installed: pip install boto3

# Use TYPE_CHECKING guard for runtime performance
if TYPE_CHECKING:
    # Annotate the client for type-checking benefits
    client: SSMContactsClient = boto3.client("ssm-contacts")
else:
    client = boto3.client("ssm-contacts")

try:
    # Example usage with type-checked method calls and parameters
    response: ListContactsResponseTypeDef = client.list_contacts(
        MaxResults=5
    )
    contacts = response.get('Contacts', [])
    print(f"Found {len(contacts)} SSM Contacts:")
    for contact in contacts:
        print(f"  - {contact.get('ContactArn')} (Alias: {contact.get('Alias')})")
    
    next_token = response.get('NextToken')
    if next_token:
        print(f"Next Token: {next_token}")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →