Type annotations for boto3 DatabaseMigrationService
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
- breaking Python 3.8 support was removed starting with `mypy-boto3-builder` version 8.12.0. Ensure your project uses Python 3.9 or newer.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Some packed method arguments now use shorter names (e.g., `RequestRequestTypeDef` -> `RequestTypeDef`), and conflicting `Extra` postfixes were moved (`ExtraRequestTypeDef` -> `RequestExtraTypeDef`). While this applies generally to generated service stubs, it may impact DMS TypeDefs if such patterns were used.
- gotcha PyCharm may experience slow performance or high CPU usage with `Literal` overloads, a common pattern in `mypy-boto3` stubs. It is recommended to use `boto3-stubs-lite` or disable PyCharm's internal type checker in favor of `mypy` or `pyright`.
- gotcha While many IDEs offer auto-discovery, explicitly annotating your `boto3.client('dms')` calls with `DatabaseMigrationServiceClient` provides the most robust type checking and autocompletion experience.
- gotcha `mypy-boto3-dms` is a stub-only package (PEP 561) and does not contain any runtime code. It must be installed in the same Python environment as `boto3` and `mypy` for type checkers to correctly find and utilize its type information.
Install
-
pip install mypy-boto3-dms boto3 mypy
Imports
- DatabaseMigrationServiceClient
from mypy_boto3_dms.client import DatabaseMigrationServiceClient
- DescribeReplicationTasksResponseTypeDef
from mypy_boto3_dms.type_defs import DescribeReplicationTasksResponseTypeDef
- AssessmentReportTypeType
from mypy_boto3_dms.literals import AssessmentReportTypeType
Quickstart
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()