mypy-boto3-docdb-elastic
mypy-boto3-docdb-elastic provides type annotations for the boto3 DocDBElastic service. It ensures static type checking with tools like MyPy, offering improved code quality and developer experience for AWS DocumentDB Elastic Clusters interactions. The current version is 1.42.3, generated with mypy-boto3-builder 8.12.0, and new versions are released in sync with boto3 updates.
Warnings
- breaking Starting with mypy-boto3-builder 8.12.0 (which generated this stub), Python 3.8 support has been removed for all packages. Ensure your project uses Python 3.9 or higher.
- breaking mypy-boto3-builder 8.9.0 introduced breaking changes to TypeDef naming conventions, potentially causing `NameError` or incorrect type resolution for previously used type definitions. Shorter names for packed method arguments and postfix changes for conflicting TypeDefs are common.
- gotcha When using `if TYPE_CHECKING:` for conditional imports to avoid runtime dependencies, Pylint might report 'undefined variable' errors.
- gotcha The `mypy-boto3-*` packages are closely tied to `boto3` versions. To ensure accurate type hints, the version of `mypy-boto3-docdb-elastic` should ideally align with your installed `boto3` version.
- gotcha PyCharm users might experience slow performance with Literal overloads.
Install
-
pip install mypy-boto3-docdb-elastic boto3 mypy -
pip install 'boto3-stubs[docdb-elastic]' boto3 mypy
Imports
- DocDBElasticClient
from mypy_boto3_docdb_elastic import DocDBElasticClient
- ListClustersPaginator
from mypy_boto3_docdb_elastic.paginators import ListClustersPaginator
- ApplyMethodType
from mypy_boto3_docdb_elastic.literals import ApplyMethodType
- ClusterListTypeDef
from mypy_boto3_docdb_elastic.type_defs import ClusterListTypeDef
Quickstart
import boto3
from mypy_boto3_docdb_elastic import DocDBElasticClient
from typing import TYPE_CHECKING
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# For local execution, you might mock credentials or ensure they're available.
# For example, using environment variables:
# os.environ['AWS_ACCESS_KEY_ID'] = 'YOUR_ACCESS_KEY'
# os.environ['AWS_SECRET_ACCESS_KEY'] = 'YOUR_SECRET_KEY'
# os.environ['AWS_REGION'] = 'us-east-1'
if TYPE_CHECKING:
client: DocDBElasticClient = boto3.client('docdb-elastic')
else:
client = boto3.client('docdb-elastic')
try:
# Example: List DocumentDB Elastic clusters
response = client.list_clusters(
maxResults=10
)
print(f"Successfully listed {len(response.get('Clusters', []))} clusters.")
for cluster in response.get('Clusters', []):
print(f" Cluster ARN: {cluster.get('ClusterArn')}, Status: {cluster.get('Status')}")
except client.exceptions.AccessDeniedException as e:
print(f"Authentication or authorization error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")