mypy-boto3-marketplace-reporting Type Stubs

1.42.3 · active · verified Sat Apr 11

Type annotations for boto3's MarketplaceReportingService. This package, part of the `mypy-boto3` ecosystem, provides static type checking for AWS SDK for Python (boto3) clients, resources, and their associated data structures. It helps improve code quality by enabling IDE autocomplete and early error detection for `MarketplaceReportingService` operations. It is regularly updated to match `boto3` releases and requires Python >= 3.9.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `MarketplaceReportingClient` with type annotations. It shows how to use `TYPE_CHECKING` for conditional stub imports, which is common practice to avoid runtime dependencies on stub packages. The example then performs a `list_entitlements` operation, with the response also type-hinted for improved static analysis.

from typing import TYPE_CHECKING
import boto3

if TYPE_CHECKING:
    from mypy_boto3_marketplace_reporting.client import MarketplaceReportingClient
    from mypy_boto3_marketplace_reporting.type_defs import ListEntitlementsOutputTypeDef

def get_marketplace_reporting_client() -> 'MarketplaceReportingClient':
    """Gets a typed Marketplace Reporting Service client."""
    # boto3 client creation without type hint (type checkers will infer via stubs)
    client = boto3.client('marketplace-reporting')
    return client # type: ignore

client: MarketplaceReportingClient = get_marketplace_reporting_client()

# Example usage: List entitlements with type-hinted response
# Replace 'YOUR_PRODUCT_CODE' with an actual AWS Marketplace Product Code
try:
    response: ListEntitlementsOutputTypeDef = client.list_entitlements(
        ProductCode='YOUR_PRODUCT_CODE',
        MaxResults=5
    )
    print("Successfully listed entitlements:")
    for entitlement in response.get('Entitlements', []):
        print(f"  Entitlement ID: {entitlement.get('EntitlementId')}")
    if response.get('NextToken'):
        print(f"  NextToken: {response['NextToken']}")
except client.exceptions.ClientError as e:
    print(f"Error listing entitlements: {e}")

view raw JSON →