mypy-boto3-mailmanager

1.42.80 · active · verified Sat Apr 11

mypy-boto3-mailmanager provides type annotations for the `boto3` MailManager service, enabling static type checking with tools like MyPy and enhanced IDE auto-completion. It is part of the `mypy-boto3` ecosystem, automatically generated by `mypy-boto3-builder 8.12.0`, and keeps pace with `boto3` updates to ensure all available MailManager service methods, clients, paginators, literals, and type definitions are fully type-annotated. The current version is 1.42.80.

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize a `boto3` MailManager client with explicit type annotations from `mypy-boto3-mailmanager`. It includes a basic operation (listing addons) and showcases the use of `TYPE_CHECKING` for conditional imports to maintain runtime efficiency. Remember to replace placeholder AWS credentials with actual environment variables or configuration.

from typing import TYPE_CHECKING
import boto3
import os

if TYPE_CHECKING:
    from mypy_boto3_mailmanager import MailManagerClient
    from mypy_boto3_mailmanager.type_defs import CreateAddonResponseTypeDef


def create_mail_manager_client() -> 'MailManagerClient':
    """Creates a typed MailManager client."""
    session = boto3.session.Session(
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
        region_name=os.environ.get('AWS_REGION', 'us-east-1')
    )
    # Explicit type annotation helps mypy and IDEs
    client: MailManagerClient = session.client('mailmanager')
    return client


def list_mail_manager_addons():
    """Lists MailManager addons with type-checked client."""
    client = create_mail_manager_client()
    try:
        response = client.list_addons(PageSize=10)
        # Using TypeDef for response provides further type safety
        addons: list[dict] = response.get('Addons', [])
        print(f"Found {len(addons)} MailManager addons.")
        for addon in addons:
            print(f"  Addon ID: {addon.get('AddonId')}")
    except client.exceptions.ClientError as e:
        print(f"Error listing addons: {e}")

if __name__ == '__main__':
    list_mail_manager_addons()

view raw JSON →