mypy-boto3-backup: Type Annotations for AWS Backup Service

1.42.86 · active · verified Sat Apr 11

mypy-boto3-backup provides static type annotations for the AWS Backup 1.42.86 service, generated with mypy-boto3-builder 8.12.0. It enhances developer experience by offering type checking and auto-completion for `boto3` clients, resources, paginators, waiters, and specific type definitions for the Backup service, compatible with `mypy`, `pyright`, VSCode, and PyCharm.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` Backup client and call an API method (`list_backup_plans`) with the benefit of type annotations from `mypy-boto3-backup`. It includes conditional imports to ensure type-checking dependencies are not present at runtime, a common pattern for stub packages.

import boto3
from typing import TYPE_CHECKING

# These imports are only for type checking and won't be bundled in production
if TYPE_CHECKING:
    from mypy_boto3_backup.client import BackupClient
    from mypy_boto3_backup.type_defs import ListBackupPlansOutputTypeDef

def get_backup_plans() -> ListBackupPlansOutputTypeDef:
    """Lists AWS Backup plans and returns the response."""
    # Type annotation for the client for better IDE support and mypy checking
    client: BackupClient = boto3.client("backup")
    
    response = client.list_backup_plans(
        MaxResults=5, # Example parameter
        # Add other filters or parameters as needed
    )
    return response

if __name__ == "__main__":
    try:
        backup_plans = get_backup_plans()
        print(f"Successfully retrieved {len(backup_plans.get('BackupPlansList', []))} backup plans.")
        for plan in backup_plans.get('BackupPlansList', [])[:2]: # Print first 2 for brevity
            print(f"  - Plan ID: {plan.get('BackupPlanId')}, Name: {plan.get('BackupPlanName')}")
    except Exception as e:
        print(f"Error listing backup plans: {e}")

view raw JSON →