mypy-boto3-marketplace-catalog Type Annotations
mypy-boto3-marketplace-catalog provides type annotations for the `boto3` AWS Marketplace Catalog service, ensuring type-safe interactions with the AWS API. It is part of the `mypy-boto3` project, which frequently releases updates to keep pace with `boto3` and `botocore` changes, generated using `mypy-boto3-builder 8.12.0`.
Warnings
- breaking Python 3.8 support has been removed for all `mypy-boto3` packages starting with `mypy-boto3-builder 8.12.0`. Ensure your project uses Python 3.9 or newer.
- breaking Breaking changes to `TypeDef` naming conventions were introduced in `mypy-boto3-builder 8.9.0`. Type definitions for packed method arguments may use shorter names, and conflicting `Extra` postfixes are now moved to the end.
- gotcha Type stubs are generated for specific `boto3` versions. A mismatch between the installed `mypy-boto3-marketplace-catalog` version and your runtime `boto3` version can lead to incorrect or missing type hints.
- gotcha To avoid introducing runtime dependencies on `mypy-boto3` packages, always wrap type stub imports within an `if TYPE_CHECKING:` block.
- gotcha The `mypy-boto3` project migrated to PEP 561 compliant packages. While generally beneficial for type checkers, ensure your type checking setup is up-to-date.
Install
-
pip install mypy-boto3-marketplace-catalog -
pip install 'boto3-stubs[marketplace-catalog]'
Imports
- MarketplaceCatalogClient
from mypy_boto3_marketplace_catalog.client import MarketplaceCatalogClient
- ListEntitiesResponseTypeDef
from mypy_boto3_marketplace_catalog.type_defs import ListEntitiesResponseTypeDef
Quickstart
import os
from typing import TYPE_CHECKING
import boto3
if TYPE_CHECKING:
from mypy_boto3_marketplace_catalog.client import MarketplaceCatalogClient
from mypy_boto3_marketplace_catalog.type_defs import ListEntitiesResponseTypeDef
# Ensure boto3 is configured, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.
# For local testing, ensure dummy credentials or a valid AWS config exist.
# os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY')
# os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET')
# os.environ['AWS_SESSION_TOKEN'] = os.environ.get('AWS_SESSION_TOKEN', 'DUMMY_TOKEN')
# os.environ['AWS_DEFAULT_REGION'] = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
def list_marketplace_entities() -> list[str]:
client: 'MarketplaceCatalogClient' = boto3.client('marketplace-catalog')
try:
response: 'ListEntitiesResponseTypeDef' = client.list_entities(
Catalog='AWSMarketplace', EntityType='ContainerProduct'
)
entity_ids = [entity['EntityId'] for entity in response.get('EntitySummaryList', [])]
print(f"Found {len(entity_ids)} Marketplace Catalog entities.")
return entity_ids
except Exception as e:
print(f"Error listing entities: {e}")
return []
if __name__ == '__main__':
entities = list_marketplace_entities()
if entities:
print(f"First 3 entity IDs: {entities[:3]}")