Type annotations for aiobotocore KMS
Type annotations for `aiobotocore KMS` service, compatible with various type checkers and IDEs like VSCode, PyCharm, and mypy. Generated by `mypy-boto3-builder`, it currently provides stubs for `aiobotocore 3.4.0` and is generated with `mypy-boto3-builder 8.12.0`. Releases are frequent, typically mirroring `mypy-boto3-builder` and underlying `aiobotocore` updates.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0, which affects `types-aiobotocore-kms`. Projects requiring Python 3.8 must use an older version of the stubs or upgrade their Python interpreter.
- breaking In `mypy-boto3-builder` version 8.9.0, `TypeDef` naming conventions changed. Argument `TypeDefs` use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes moved (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`). This is a breaking change for code explicitly referencing these `TypeDef` names.
- gotcha The `types-aiobotocore-kms` package version is tied to the `aiobotocore` version it provides stubs for. Mismatches between the installed stub package and the runtime `aiobotocore` version can lead to type checking errors or missing types, as method signatures or available operations might differ.
- gotcha Due to known performance issues in PyCharm with `Literal` overloads (issue PY-40997), it is recommended to use `types-aiobotocore-lite` for better IDE performance if you experience slowness or high CPU usage with PyCharm's type checker.
- gotcha As of `mypy-boto3-builder` 8.12.0, all packages migrated to PEP 561. This generally improves type checker compatibility but might require re-evaluation of import paths or stub discovery configurations in complex or highly customized type-checking setups.
Install
-
pip install types-aiobotocore-kms -
pip install 'types-aiobotocore[kms]'
Imports
- KMSClient
from types_aiobotocore_kms.client import KMSClient
- get_session
from aiobotocore.session import get_session
Quickstart
import asyncio
import os
from aiobotocore.session import get_session
from types_aiobotocore_kms.client import KMSClient
async def describe_key_example():
session = get_session()
async with session.create_client(
"kms",
region_name=os.environ.get('AWS_REGION', 'us-east-1'),
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'test'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'test'),
aws_session_token=os.environ.get('AWS_SESSION_TOKEN', None),
) as client: # type: KMSClient
# Replace with a valid KMS Key ID or ARN for real usage
key_id = "arn:aws:kms:us-east-1:123456789012:key/your-key-id" # Placeholder
try:
response = await client.describe_key(KeyId=key_id)
print(f"Key description: {response.get('KeyMetadata', {})}")
except Exception as e:
print(f"Error describing key {key_id}: {e}")
if __name__ == "__main__":
# Ensure AWS credentials and region are set in environment variables
# or configure aiobotocore session appropriately.
# For this example, placeholders are used, but for real AWS interaction,
# valid credentials and a valid KeyId are required.
asyncio.run(describe_key_example())