Type Annotations for boto3 DocDB
This library provides type annotations for the AWS DocDB (DocumentDB) service client when using boto3. Generated with mypy-boto3-builder 8.12.0, `mypy-boto3-docdb` (current version 1.42.3) enhances static analysis, provides auto-completion in IDEs, and helps catch type-related errors before runtime. It releases in sync with boto3 versions.
Warnings
- breaking Support for Python 3.8 has been removed across all packages generated by `mypy-boto3-builder`, including `mypy-boto3-docdb` versions 8.12.0 and above.
- breaking `mypy-boto3` packages migrated to PEP 561. While this improves how type checkers find stubs, it might affect complex build setups or older type checker versions.
- gotcha `mypy-boto3-docdb` provides *only* type stubs. It does not include the `boto3` runtime library itself. Your application still requires `boto3` to be installed and available at runtime.
- breaking TypeDef names for method arguments may have been shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This can break existing explicit type annotations.
Install
-
pip install boto3 mypy-boto3-docdb mypy
Imports
- DocDBClient
from mypy_boto3_docdb.client import DocDBClient
- DescribeDBInstancesResponseTypeDef
from mypy_boto3_docdb.type_defs import DescribeDBInstancesResponseTypeDef
Quickstart
from typing import TYPE_CHECKING
import boto3
if TYPE_CHECKING:
from mypy_boto3_docdb.client import DocDBClient
from mypy_boto3_docdb.type_defs import DescribeDBInstancesResponseTypeDef
def get_docdb_instances() -> "DescribeDBInstancesResponseTypeDef":
# The type hint 'DocDBClient' is picked up by mypy and IDEs.
# At runtime, you still get the regular boto3 client.
client: DocDBClient = boto3.client("docdb")
response = client.describe_db_instances()
print(f"Found {len(response['DBInstances'])} DocDB instances.")
return response
if __name__ == "__main__":
# This example requires AWS credentials configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
# or ~/.aws/credentials) to run successfully against a real AWS account.
try:
instances_data = get_docdb_instances()
# Further processing with type-checked 'instances_data'
except Exception as e:
print(f"Error describing DocDB instances: {e}")