mypy-boto3-marketplace-agreement: Type Stubs for AWS Marketplace Agreement Service
mypy-boto3-marketplace-agreement provides a comprehensive set of type annotations for the AWS Marketplace Agreement Service client in boto3. This library is part of the `mypy-boto3-builder` ecosystem, which generates type stubs for all boto3 services, enhancing static type checking capabilities for AWS SDK users. The project actively maintains and updates its stubs, with version 1.42.80 reflecting the latest boto3 API for AgreementService and aligning with `mypy-boto3-builder` version 8.12.0. Releases are frequent, following boto3 updates and builder enhancements.
Warnings
- breaking Support for Python 3.8 has been removed across all `mypy-boto3` packages. Projects targeting `mypy-boto3` builder versions 8.12.0 and above must use Python 3.9 or newer.
- breaking Type definition names (`TypeDef`s) generated by `mypy-boto3-builder` might have changed for some services to use shorter names or resolve conflicts. For instance, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. This could affect code directly importing or referencing these generated type names.
- gotcha The `mypy-boto3-marketplace-agreement` package provides *only* type stubs. You must explicitly install `boto3` (or `aioboto3` for async clients) to have the actual AWS SDK functionality at runtime. The stub package does not pull `boto3` as a runtime dependency.
- gotcha As of `mypy-boto3-builder` 8.12.0, all packages have migrated to PEP 561, becoming `py.typed` packages. While this is a standard and generally beneficial change, older `mypy` configurations or tools that rely on specific `MYPYPATH` setups might need adjustments to correctly locate the stubs.
Install
-
pip install mypy-boto3-marketplace-agreement boto3
Imports
- AgreementServiceClient
from mypy_boto3_marketplace_agreement.client import AgreementServiceClient
- AcceptAgreementRequestRequestTypeDef
from mypy_boto3_marketplace_agreement.type_defs import AcceptAgreementRequestRequestTypeDef
Quickstart
import boto3
from mypy_boto3_marketplace_agreement.client import AgreementServiceClient
from mypy_boto3_marketplace_agreement.type_defs import AcceptAgreementOutputTypeDef, AcceptAgreementRequestRequestTypeDef
import os
def get_agreement_client() -> AgreementServiceClient:
"""Returns a type-hinted boto3 AgreementService client."""
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# For local testing, you might mock this or ensure your environment has AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.
return boto3.client("marketplace-agreement")
def accept_agreement(agreement_id: str) -> AcceptAgreementOutputTypeDef:
"""Accepts a Marketplace agreement using the type-hinted client."""
client: AgreementServiceClient = get_agreement_client()
# Example request payload, adjust as per actual API requirements
request_payload: AcceptAgreementRequestRequestTypeDef = {
"agreementId": agreement_id
}
response: AcceptAgreementOutputTypeDef = client.accept_agreement(**request_payload)
print(f"Agreement accepted: {response.get('agreementId')}")
return response
if __name__ == "__main__":
# Replace with a real agreement ID for actual testing
test_agreement_id = os.environ.get('MARKETPLACE_AGREEMENT_ID', 'ag-xxxxxxxxxxxxxxxxx')
if test_agreement_id == 'ag-xxxxxxxxxxxxxxxxx':
print("Please set the MARKETPLACE_AGREEMENT_ID environment variable for a real test.")
print("Using a placeholder ID.")
try:
# This call will require valid AWS credentials and a real agreement ID to succeed.
# If credentials are not configured or ID is invalid, it will raise a boto3 exception.
accept_agreement(test_agreement_id)
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure 'boto3' is installed and AWS credentials are configured correctly.")