mypy-boto3-payment-cryptography Type Stubs
mypy-boto3-payment-cryptography provides type annotations for the boto3 AWS Payment Cryptography Control Plane service (version 1.42.83). It is part of the `mypy-boto3-builder` project, which automatically generates comprehensive type stubs for boto3 to enable static type checking with tools like MyPy, Pyright, and enhance IDE auto-completion. The project is actively maintained, with releases typically synchronized with upstream boto3 updates.
Warnings
- breaking Python 3.8 support has been removed. `mypy-boto3-builder` version 8.12.0 (which generated this stub) and consequently this stub package now require Python 3.9 or newer. Ensure your environment meets this requirement.
- breaking In `mypy-boto3-builder` version 8.9.0, some generated `TypeDef` names were shortened or had conflicting postfixes moved for consistency (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). While this specific stub is newer, direct usage of `TypeDef` names from older generated versions may break.
- gotcha This package provides type stubs for the **Payment Cryptography Control Plane** service. If you are looking for type annotations for the **Payment Cryptography Data Plane** service, you need to install `mypy-boto3-payment-cryptography-data` instead.
- gotcha It is best practice to wrap `mypy-boto3` stub imports within an `if TYPE_CHECKING:` block. This prevents the stub packages from being imported at runtime, making them purely development dependencies and avoiding potential runtime issues or increased startup times in production environments.
Install
-
pip install mypy-boto3-payment-cryptography -
pip install 'boto3-stubs[payment-cryptography]'
Imports
- PaymentCryptographyControlPlaneClient
from mypy_boto3_payment_cryptography.client import PaymentCryptographyControlPlaneClient
- CreateKeyInputRequestTypeDef
from mypy_boto3_payment_cryptography.type_defs import CreateKeyInputRequestTypeDef
- KeyUsageType
from mypy_boto3_payment_cryptography.literals import KeyUsageType
- Session
from boto3.session import Session
- TYPE_CHECKING
from typing import TYPE_CHECKING
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_payment_cryptography.client import PaymentCryptographyControlPlaneClient
from mypy_boto3_payment_cryptography.type_defs import CreateKeyInputRequestTypeDef
def create_payment_cryptography_key():
# The 'client' variable will be type-checked as PaymentCryptographyControlPlaneClient
client: 'PaymentCryptographyControlPlaneClient' = boto3.client(
'payment-cryptography-control-plane'
)
key_alias = "alias/my-test-key"
# Example of using a TypedDict for a request payload
create_key_params: CreateKeyInputRequestTypeDef = {
"KeyAttributes": {
"KeyUsage": "TR31_K0_CARD_PROCESSING_EMV_COMPATIBILITY",
"KeyClass": "SYMMETRIC_KEY",
"KeyAlgorithm": "AES_128",
"KeyModesOfUse": {
"Encrypt": True,
"Decrypt": True
}
},
"Enabled": True,
"KeyCheckValueAlgorithm": "CMAC"
}
try:
response = client.create_key(**create_key_params)
print(f"Key created successfully with ARN: {response['Key']['KeyArn']}")
# Type checkers will understand the structure of 'response'
except client.exceptions.ConflictException:
print(f"Key alias {key_alias} already exists.")
except Exception as e:
print(f"An error occurred: {e}")
# To run this example, ensure you have AWS credentials configured
# or set environment variables like AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION.
# Example: os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1')
create_payment_cryptography_key()