Install & Compatibility
Where this runs
tested against v1.43.12 · 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.010s · 53.2MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 5.3s · import 0.006s · 54MB
52MB installed
● package 52MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
KMSClient
✓ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_kms.client import KMSClient
Importing KMSClient directly without `TYPE_CHECKING` will make `types-boto3-kms` a runtime dependency, which is usually unnecessary and adds overhead.
ListKeysResponseTypeDef
✓ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_kms.type_defs import ListKeysResponseTypeDef
Specific TypeDefs provide precise type checking for boto3 response structures.
This quickstart demonstrates how to use `types-boto3-kms` to add type hints to a `boto3` KMS client. It shows how to import and apply type annotations for the client object and its response structures, enabling static analysis and IDE assistance for KMS API calls. Requires AWS credentials configured to execute.
from typing import TYPE_CHECKING, List
import boto3
if TYPE_CHECKING:
from mypy_boto3_kms.client import KMSClient
from mypy_boto3_kms.type_defs import KeyListEntryTypeDef, ListKeysResponseTypeDef
def get_kms_key_ids() -> List[str]:
"""Lists all KMS key IDs in the current AWS account."""
kms_client: KMSClient = boto3.client("kms")
# The response object is type-hinted for better autocompletion and error checking
response: ListKeysResponseTypeDef = kms_client.list_keys()
key_ids: List[str] = []
for key_entry in response.get("Keys", []):
# key_entry is inferred as KeyListEntryTypeDef
if 'KeyId' in key_entry:
key_ids.append(key_entry['KeyId'])
return key_ids
# To run this function, ensure AWS credentials are configured (e.g., via environment variables, AWS CLI, or IAM role).
# print(get_kms_key_ids())
Debug
Known issues
breakingPython 3.8 support has been removed in `mypy-boto3-builder` version 8.12.0 (and thus `types-boto3-kms`). Projects using Python 3.8 will not receive updates or new packages.fixUpgrade your Python environment to 3.9 or newer.
affects: >=8.12.0
deprecatedThe legacy `mypy-boto3` package, which contained stubs for all services in one package, has been deprecated in favor of the modular `types-boto3` and service-specific packages like `types-boto3-kms`.fixUninstall `mypy-boto3` and install `types-boto3-kms` for specific service stubs, or `types-boto3[all]` for all services.
affects: All versions since `types-boto3` was introduced as successor.
gotchaForgetting the `if TYPE_CHECKING:` guard when importing client types (e.g., `from mypy_boto3_kms.client import KMSClient`) can inadvertently make `types-boto3-kms` a runtime dependency for your application, which is unnecessary and adds overhead.fixAlways wrap type-only imports within an `if TYPE_CHECKING:` block, as shown in the quickstart and import examples.
affects: All
gotchaPyCharm's performance can be slow with `Literal` overloads in `mypy-boto3` packages (issue PY-40997). This can lead to sluggish autocompletion or analysis.fixConsider using `types-boto3-lite` (e.g., `pip install types-boto3-lite[kms]`) which is more RAM-friendly but requires explicit type annotations, until the PyCharm issue is resolved.
affects: All
Upgrade
Version history
1.43.12latest on PyPI · released May 20, 2026
Audit
Dependencies
boto3requiredRuntime dependency; this package provides type stubs for boto3.
mypyoptionalRecommended for static type checking integration.