mypy-boto3 Marketplace Entitlement Type Stubs
This library provides type annotations (stubs) for the `boto3` Marketplace Entitlement Service, enhancing development experience with static type checking for AWS SDK usage. It's part of the `mypy-boto3` project, which generates stubs for all `boto3` services. The current version is 1.42.58, generated by `mypy-boto3-builder` 8.12.0, with releases closely following `boto3` service updates.
Warnings
- breaking Python 3.8 support was removed for `mypy-boto3` packages (including this one) starting with `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will experience build failures or missing type information.
- breaking The `mypy-boto3` packages migrated to PEP 561 packaging (namespace packages) with `mypy-boto3-builder` version 8.12.0. This changes how type checkers discover packages, potentially causing issues in complex environments or older `mypy` versions.
- breaking Type definition names for packed method arguments were shortened or adjusted to resolve conflicts starting with `mypy-boto3-builder` version 8.9.0. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`. This could lead to `NameError` for previously existing type annotations.
- gotcha This package provides only type stubs for `boto3`'s MarketplaceEntitlementService. It does not include the runtime `boto3` library itself. Using the stubs without `boto3` installed will result in runtime `ModuleNotFoundError`.
- gotcha Compatibility with `mypy` itself can be a concern. Very old `mypy` versions may not fully understand the generated type stubs, especially with newer Python typing features.
Install
-
pip install mypy-boto3-marketplace-entitlement boto3 mypy
Imports
- MarketplaceEntitlementClient
from mypy_boto3_marketplace_entitlement import MarketplaceEntitlementClient
- GetEntitlementsResultTypeDef
from mypy_boto3_marketplace_entitlement.type_defs import GetEntitlementsResultTypeDef
Quickstart
import boto3
from mypy_boto3_marketplace_entitlement import MarketplaceEntitlementClient
from mypy_boto3_marketplace_entitlement.type_defs import GetEntitlementsResultTypeDef, GetEntitlementsRequestRequestTypeDef
# Instantiate a boto3 client with type hints
client: MarketplaceEntitlementClient = boto3.client("marketplace-entitlement")
# Example usage with type-hinted parameters and return value
request_params: GetEntitlementsRequestRequestTypeDef = {
"ProductCode": os.environ.get('MARKETPLACE_PRODUCT_CODE', 'some-product-code'),
"Filter": {
"CUSTOMER_IDENTIFIER": [
os.environ.get('AWS_ACCOUNT_ID', '123456789012')
]
}
}
try:
response: GetEntitlementsResultTypeDef = client.get_entitlements(**request_params)
print("Successfully retrieved entitlements:")
for entitlement in response.get('Entitlements', []):
print(f" Entitlement: {entitlement.get('ProductCode')} for {entitlement.get('CustomerIdentifier')}")
except Exception as e:
print(f"Error retrieving entitlements: {e}")
# To verify with mypy, save this to a file (e.g., `main.py`) and run `mypy main.py`