Type Annotations for aiobotocore Secrets Manager

3.4.0 · active · verified Tue Apr 14

This library provides a complete set of PEP 561 type annotations for `aiobotocore`'s Secrets Manager service. It enhances development with static type checking, autocompletion, and refactoring support for asynchronous AWS operations. Currently at version 3.4.0, it is part of the `mypy-boto3-builder` ecosystem which follows a frequent release cadence, often aligning with new `aiobotocore` and AWS service updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a typed `SecretsManagerClient` using `aiobotocore.session` and perform a basic asynchronous operation like listing secrets. The `TYPE_CHECKING` block ensures type imports do not add runtime dependencies.

from typing import TYPE_CHECKING
import asyncio
import aiobotocore.session

# These types are only needed for type checking, not at runtime
if TYPE_CHECKING:
    from types_aiobotocore_secretsmanager.client import SecretsManagerClient

async def get_secrets_manager_client():
    session = aiobotocore.session.get_session()
    # Annotate the client with the imported type for full type-checking benefits
    client: SecretsManagerClient
    async with session.client("secretsmanager") as client:
        try:
            response = await client.list_secrets()
            print(f"Secrets: {[s['Name'] for s in response.get('SecretList', [])]}")
        except Exception as e:
            print(f"Error listing secrets: {e}")

if __name__ == "__main__":
    asyncio.run(get_secrets_manager_client())

view raw JSON →