Type Annotations for aiobotocore Secrets Manager
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
- breaking Python 3.8 support has been dropped starting with `mypy-boto3-builder` version 8.12.0. This means `types-aiobotocore-secretsmanager` versions built with 8.12.0 or later (including 3.4.0) require Python 3.9 or higher.
- gotcha It is crucial to align the version of `types-aiobotocore-secretsmanager` with the version of `aiobotocore` (and potentially `types-aiobotocore`) you are using at runtime. Mismatched versions can lead to incorrect types or missing attributes/methods, causing static analysis errors or runtime issues that type checking might miss.
- breaking The `mypy-boto3-builder` (which generates this package) introduced breaking changes in `8.9.0` regarding TypeDef naming conventions, such as `CreateDistributionRequestRequestTypeDef` becoming `CreateDistributionRequestTypeDef`. While this specific example is not for Secrets Manager, similar changes may occur in future versions for other service TypeDefs, if names become too long or conflicting.
- gotcha This package is a type stub package (`py.typed`) and provides only type annotations. It does not include the actual runtime implementation of the `aiobotocore` Secrets Manager client. You must install `aiobotocore` separately for the code to run.
Install
-
pip install types-aiobotocore-secretsmanager
Imports
- SecretsManagerClient
from types_aiobotocore_secretsmanager.client import SecretsManagerClient
- AioSession
import aiobotocore.session
Quickstart
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())