mypy-boto3-ssm-contacts
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
- breaking Python 3.8 support has been removed. `mypy-boto3` packages built with `mypy-boto3-builder` version 8.12.0 or newer no longer support Python 3.8.
- breaking All `mypy-boto3` packages, including `mypy-boto3-ssm-contacts`, migrated to PEP 561 packaging. While this is a standard for type stubs, older `mypy` versions or non-standard project setups might encounter issues.
- gotcha This package provides only type annotations. For your code to run, you *must* also have the `boto3` library installed in the same environment.
- breaking When upgrading from very old versions, be aware that `mypy-boto3-builder` version 8.9.0 introduced breaking changes to how some `TypeDef` names are generated (e.g., shortening names or reordering suffixes to resolve conflicts). Your code might need updates if it directly references these specific type names.
- gotcha This package offers static type information only; it does not alter the runtime behavior of `boto3` or introduce new features. Its purpose is purely for static analysis (e.g., `mypy`) and IDE autocompletion.
Install
-
pip install mypy-boto3-ssm-contacts -
pip install mypy-boto3
Imports
- SSMContactsClient
from mypy_boto3_ssm_contacts.client import SSMContactsClient
- ListContactsResponseTypeDef
from mypy_boto3_ssm_contacts.type_defs import ListContactsResponseTypeDef
Quickstart
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}")