Type Annotations for Boto3 DLM Service
mypy-boto3-dlm (version 1.42.84) provides static type annotations for the AWS Data Lifecycle Manager (DLM) service within the `boto3` library. It enables static analysis tools like MyPy and Pyright, and IDEs such as VSCode and PyCharm, to offer robust autocomplete, early error detection, and improved code quality for your `boto3` interactions. This package is automatically generated and kept in sync with `boto3` updates by the `mypy-boto3` project.
Warnings
- breaking Starting with `mypy-boto3-builder` version 8.12.0 (which generates `mypy-boto3-dlm` versions like 1.42.84), support for Python 3.8 has been removed across all `mypy-boto3` packages. Projects must use Python 3.9 or newer.
- breaking Type definition (TypeDef) naming conventions underwent breaking changes in `mypy-boto3-builder` version 8.9.0. If you were directly referencing generated TypeDefs by their full names (e.g., in custom code generation or by relying on old names), your code might break.
- gotcha The `mypy-boto3-dlm` package provides only type annotations. You must also install the `boto3` library itself for your code to function at runtime.
- gotcha Users of PyCharm might experience slow performance or high CPU usage due to PyCharm's handling of `Literal` overloads in `mypy-boto3` packages. This is a known PyCharm issue (PY-40997).
- gotcha Pylint can sometimes report `undefined-variable` warnings when `mypy-boto3` imports are only used within `if TYPE_CHECKING:` blocks. This is because Pylint may not correctly interpret these type-checking-only imports at runtime.
Install
-
pip install mypy-boto3-dlm boto3
Imports
- DLMClient
from mypy_boto3_dlm import DLMClient
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_dlm import DLMClient
# Instantiate the boto3 client with type hints
client: DLMClient = boto3.client("dlm", region_name="us-east-1")
# Example usage with type-checked methods and arguments
try:
response = client.get_lifecycle_policies(
PolicyIds=["policy-0123456789abcdef0"]
)
print("Successfully retrieved DLM policies:", response["Policies"])
except client.exceptions.ResourceNotFoundException as e:
print(f"Policy not found: {e}")
except Exception as e:
print(f"An error occurred: {e}")