Registry /
type-stubs / mypy-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.95 runs
installs and imports cleanly · install 0.0s · import 0.592s · 51.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.0s · import 0.560s · 52MB
50MB installed
● package 50MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SecretsManagerClient
✓ from mypy_boto3_secretsmanager import SecretsManagerClient
GetSecretValueResponseTypeDef
✓ from mypy_boto3_secretsmanager.type_defs import GetSecretValueResponseTypeDef
✗ from mypy_boto3_secretsmanager import GetSecretValueResponse
Type definitions are typically in the `type_defs` submodule and follow a `*TypeDef` naming convention, not direct imports from the top-level package or `*Response`.
This example demonstrates how to use the type stubs for AWS Secrets Manager. It initializes a `SecretsManagerClient` and calls `get_secret_value`, with full type hinting for the client and the response dictionary. This allows static type checkers like Mypy to validate your code and provides rich autocompletion in IDEs.
import boto3
import os
from mypy_boto3_secretsmanager import SecretsManagerClient
from mypy_boto3_secretsmanager.type_defs import GetSecretValueResponseTypeDef
def get_secret_value_typed(secret_id: str) -> str:
client: SecretsManagerClient = boto3.client("secretsmanager")
try:
response: GetSecretValueResponseTypeDef = client.get_secret_value(SecretId=secret_id)
secret_string = response.get("SecretString")
if secret_string is None:
raise ValueError(f"Secret '{secret_id}' has no SecretString.")
return secret_string
except client.exceptions.ResourceNotFoundException:
print(f"Secret '{secret_id}' not found.")
return ""
except Exception as e:
print(f"Error retrieving secret '{secret_id}': {e}")
return ""
if __name__ == "__main__":
# Replace with a real secret ID or use an environment variable
# Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION env vars or ~/.aws/credentials)
test_secret_id = os.environ.get('TEST_SECRET_ID', 'my-test-secret-id-nonexistent')
print(f"Attempting to retrieve secret: {test_secret_id}")
secret = get_secret_value_typed(test_secret_id)
if secret:
print(f"Retrieved secret (first 10 chars): {secret[:10]}...")
else:
print("Secret retrieval failed or secret not found.")
Debug
Known issues
breakingAs of `mypy-boto3-builder` version 8.12.0 (which generates these stubs), Python 3.8 is no longer supported. Packages built with this builder (including `mypy-boto3-secretsmanager` 1.x.x versions) require Python 3.9 or newer.fixUpgrade your Python environment to 3.9 or higher.
affects: mypy-boto3-secretsmanager >= 1.42.x (and generally any version built with builder 8.12.0+)
gotchaType stubs are designed to match specific `boto3` and `botocore` versions. Mismatched versions between `boto3` (or `botocore`) and `mypy-boto3-secretsmanager` can lead to inaccurate type hints or Mypy errors. Always try to keep them aligned.fixInstall `mypy-boto3-secretsmanager` and `boto3` with compatible versions. Often, installing both at the same time will resolve compatibility by pulling the latest matching `mypy-boto3` stubs.
affects: All versions
breakingFor stubs generated by `mypy-boto3-builder` version 8.9.0 and later, some `TypeDef` names for method arguments and responses might have changed, primarily to shorten names or resolve conflicts (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`).fixConsult the specific service's documentation or use IDE autocompletion to find the correct `TypeDef` names after upgrading. Often, removing redundant `Request` or `Extra` suffixes might be the solution.
affects: mypy-boto3-secretsmanager >= 1.x.x (built with builder 8.9.0+)
deprecatedThe monolithic `mypy-boto3` package (which included all service stubs) is now considered a legacy product. While it still exists, the recommended approach for modern `mypy-boto3-builder` versions is to install specific service packages like `mypy-boto3-secretsmanager` to reduce dependencies and improve build times.fixPrefer installing individual service packages (e.g., `pip install mypy-boto3-secretsmanager`) over the single, large `mypy-boto3` package.
affects: All versions (affects installation strategy)
gotcha`boto3` clients require an AWS region to be specified for successful operation. This can be done explicitly in the `boto3.client()` call, via environment variables (e.g., `AWS_REGION` or `AWS_DEFAULT_REGION`), or through AWS configuration files. Failure to specify a region results in a `botocore.exceptions.NoRegionError`.fixEnsure an AWS region is configured for `boto3`. Set the `AWS_REGION` or `AWS_DEFAULT_REGION` environment variable, or pass `region_name='your-region'` directly to the `boto3.client()` call, or configure it in your AWS CLI configuration files.
affects: All versions (affects boto3 runtime configuration)
gotchaThe `boto3` client failed to initialize because no AWS region was specified. Boto3 requires a region to be set, either explicitly in the client call, via environment variables (`AWS_REGION` or `AWS_DEFAULT_REGION`), or in AWS configuration files (`~/.aws/config`).fixEnsure an AWS region is configured for your Boto3 client. This can be done by setting the `AWS_REGION` environment variable, configuring your AWS CLI, or passing the `region_name` argument directly to `boto3.client('secretsmanager', region_name='your-region')`. affects: All versions
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredProvides the actual AWS SDK runtime functionality; these stubs are for type-checking it.