Registry /
type-stubs / types-boto3-secretsmanager
Install & Compatibility
Where this runs
tested against v1.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 69MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 3.3s · import 0.000s · 19MB
67MB installed
● package 67MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SecretsManagerClient
✓ from types_boto3_secretsmanager import SecretsManagerClient
✗ from mypy_boto3_secretsmanager import SecretsManagerClient
This quickstart demonstrates how to initialize a `boto3` Secrets Manager client and retrieve a secret value with the benefit of static type checking provided by `types-boto3-secretsmanager`. The `if TYPE_CHECKING:` block ensures that `mypy_boto3_secretsmanager` is only used for type analysis and not as a runtime dependency.
import boto3
from typing import TYPE_CHECKING
import os
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# 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:
from mypy_boto3_secretsmanager import SecretsManagerClient
def get_secret_value_typed(secret_name: str, region_name: str) -> str:
session = boto3.session.Session()
client: SecretsManagerClient = session.client(
service_name='secretsmanager',
region_name=region_name,
)
try:
response = client.get_secret_value(
SecretId=secret_name
)
if 'SecretString' in response:
return response['SecretString']
elif 'SecretBinary' in response:
return response['SecretBinary'].decode('utf-8') # Assuming UTF-8 encoded binary
except client.exceptions.ResourceNotFoundException:
print(f"Secret '{secret_name}' not found.")
except client.exceptions.ClientError as e:
print(f"An AWS client error occurred: {e}")
return ""
# Example usage (uncomment and replace with valid secret name and region)
# if __name__ == "__main__":
# secret = get_secret_value_typed("my-test-secret", os.environ.get('AWS_REGION', 'us-east-1'))
# if secret:
# print(f"Retrieved secret: {secret}")
Debug
Known issues
breakingStarting with `mypy-boto3-builder` version 8.12.0 (which generated this package), Python 3.8 is no longer supported for generated stub packages. This applies to `types-boto3-secretsmanager` versions built with builder 8.12.0 or newer.fixUpgrade your Python environment to 3.9 or newer.
affects: mypy-boto3-builder >= 8.12.0 (and corresponding types-boto3-secretsmanager versions)
breakingFollowing the migration to PEP 561 packages in `mypy-boto3-builder` 8.12.0, ensure your `mypy` or other type checker is up-to-date. Older versions might not correctly discover or utilize the stubs, leading to `Missing type stub` errors or incorrect type inference.fixUpdate your type checker (e.g., `pip install --upgrade mypy`) and ensure it's configured to recognize PEP 561-compliant stub packages.
affects: mypy-boto3-builder >= 8.12.0 (and corresponding types-boto3-secretsmanager versions)
breakingIn `mypy-boto3-builder` version 8.9.0, type definition (TypeDef) naming conventions changed. This includes shorter names for packed method arguments and revised postfix handling for conflicting `TypeDef` names (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`).fixUpdate your code to use the new `TypeDef` names as per the latest stub documentation. Your IDE or type checker should highlight these if you are using explicit type hints.
affects: mypy-boto3-builder >= 8.9.0 (and corresponding types-boto3-secretsmanager versions)
gotchaThese packages provide only type stubs and are not intended for runtime use. To avoid adding `types-boto3-secretsmanager` as a production dependency and ensure it's only used by static analysis tools, wrap your type imports within an `if TYPE_CHECKING:` block.fixUse `from typing import TYPE_CHECKING; if TYPE_CHECKING: from mypy_boto3_secretsmanager import SecretsManagerClient` (and similar for other types), with fallback assignments to `object` in the `else` block if `pylint` complains.
affects: All versions
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredProvides runtime functionality for which these are type stubs.
pythonrequiredMinimum Python version required for generated stubs.