mypy-boto3-rds Type Annotations

1.42.75 · active · verified Sun Apr 05

mypy-boto3-rds provides type annotations for the AWS boto3 RDS service, enhancing static analysis and code completion for `boto3.client("rds")` and related service components. It is automatically generated by `mypy-boto3-builder` and aims to synchronize its version with the corresponding `boto3` release, offering up-to-date type hints for mypy, pyright, and various IDEs. The current version is 1.42.75, reflecting its alignment with `boto3`.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-rds` for type-hinting a `boto3` RDS client. It shows explicit type annotation for the client, an API call with type-hinted response, and usage of a paginator. The `TYPE_CHECKING` block ensures that type-only imports do not affect runtime dependencies. Note that `boto3-stubs[rds]` is the idiomatic way to install type annotations for a specific service.

import boto3
from typing import TYPE_CHECKING

# It is generally recommended to install 'boto3-stubs[rds]' for full integration.
# For explicit type annotation of the client:
if TYPE_CHECKING:
    from mypy_boto3_rds.client import RDSClient
    from mypy_boto3_rds.type_defs import DescribeDBInstancesMessageTypeDef

    # Example of a Paginator
    from mypy_boto3_rds.paginators import DescribeDBInstancesPaginator


# Initialize boto3 client
# For better type inference, explicitly annotate the client if TYPE_CHECKING is True
client: RDSClient = boto3.client("rds") if TYPE_CHECKING else boto3.client("rds")

try:
    # Example API call with type-hinted response
    response = client.describe_db_instances(
        MaxRecords=20
    )
    # The 'response' object will have type hints based on DescribeDBInstancesMessageTypeDef
    print(f"Found {len(response.get('DBInstances', []))} DB instances.")

    # Example usage of a Paginator
    paginator: DescribeDBInstancesPaginator = client.get_paginator("describe_db_instances")
    for page in paginator.paginate():
        print(f"Processing page with {len(page.get('DBInstances', []))} instances.")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →