Type annotations for boto3 DatabaseMigrationService

1.42.80 · active · verified Sat Apr 11

mypy-boto3-dms provides PEP 561 compatible type annotations (stubs) for the `boto3` AWS Database Migration Service (DMS) client. This package helps static type checkers like Mypy, Pyright, and IDEs (VSCode, PyCharm) provide better autocompletion, error detection, and overall developer experience when working with `boto3`'s DMS client. It is currently at version 1.42.80 and is frequently updated to align with `boto3` releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` DMS client with type annotations and perform a simple API call. The `TYPE_CHECKING` block ensures that type-only imports do not incur runtime overhead. Replace placeholder environment variables with actual AWS credentials for real use.

import boto3
from typing import TYPE_CHECKING
from os import environ

if TYPE_CHECKING:
    from mypy_boto3_dms.client import DatabaseMigrationServiceClient
    from mypy_boto3_dms.type_defs import DescribeReplicationTasksResponseTypeDef

def list_dms_replication_tasks() -> "DescribeReplicationTasksResponseTypeDef":
    """Lists DMS replication tasks with type hints."""
    # Explicitly type the client for enhanced IDE support and static analysis.
    client: DatabaseMigrationServiceClient = boto3.client(
        "dms",
        region_name=environ.get("AWS_REGION", "us-east-1"),
        aws_access_key_id=environ.get("AWS_ACCESS_KEY_ID", "TEST_ACCESS_KEY"),
        aws_secret_access_key=environ.get("AWS_SECRET_ACCESS_KEY", "TEST_SECRET_KEY"),
    )
    response = client.describe_replication_tasks()
    print("DMS Replication Tasks:", response.get("ReplicationTasks"))
    return response

if __name__ == "__main__":
    list_dms_replication_tasks()

view raw JSON →