{"id":3114,"library":"mypy-boto3-meteringmarketplace","title":"mypy-boto3-meteringmarketplace Type Annotations","description":"mypy-boto3-meteringmarketplace provides comprehensive type annotations for the `boto3` MarketplaceMetering service (version 1.42.58). Generated by `mypy-boto3-builder`, these stubs enhance development with static type checking, auto-completion, and error detection in IDEs and tools like mypy and pyright. The library frequently updates to stay in sync with `boto3` and `botocore` releases, ensuring up-to-date type definitions for AWS SDK interactions.","status":"active","version":"1.42.58","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["python","types","mypy","boto3","aws","stub","type-hints","aws-marketplace-metering"],"install":[{"cmd":"pip install mypy-boto3-meteringmarketplace","lang":"bash","label":"Install service stubs"},{"cmd":"pip install boto3 mypy-boto3-meteringmarketplace","lang":"bash","label":"Install with boto3"}],"dependencies":[{"reason":"Runtime dependency for the AWS SDK for Python, which these stubs provide type hints for.","package":"boto3","optional":false}],"imports":[{"note":"Import the typed client for the MarketplaceMetering service.","symbol":"MarketplaceMeteringClient","correct":"from mypy_boto3_meteringmarketplace.client import MarketplaceMeteringClient"},{"note":"Import specific TypedDicts for request/response structures.","symbol":"RegisterUsageOutputTypeDef","correct":"from mypy_boto3_meteringmarketplace.type_defs import RegisterUsageOutputTypeDef"}],"quickstart":{"code":"import os\nimport boto3\nfrom typing import TYPE_CHECKING\n\n# Ensure you have boto3 installed for runtime and mypy-boto3-meteringmarketplace for type checking\n\nif TYPE_CHECKING:\n    from mypy_boto3_meteringmarketplace.client import MarketplaceMeteringClient\n    from mypy_boto3_meteringmarketplace.type_defs import RegisterUsageOutputTypeDef\n\n# Standard boto3 client creation (runtime)\nclient: MarketplaceMeteringClient = boto3.client(\n    \"meteringmarketplace\",\n    region_name=os.environ.get(\"AWS_REGION\", \"us-east-1\"),\n    aws_access_key_id=os.environ.get(\"AWS_ACCESS_KEY_ID\", \"\"),\n    aws_secret_access_key=os.environ.get(\"AWS_SECRET_ACCESS_KEY\", \"\"),\n    aws_session_token=os.environ.get(\"AWS_SESSION_TOKEN\", \"\"),\n)\n\ntry:\n    # Example: Registering usage. Note: ProductCode and UsageAllocations are required.\n    # This is a dummy example; replace with actual logic and valid data.\n    product_code = \"YOUR_PRODUCT_CODE\"\n    usage_allocations = [\n        {\"AllocatedUsageQuantity\": 1, \"Tags\": [{\"Key\": \"Dim\", \"Value\": \"Val\"}]}\n    ]\n\n    response: RegisterUsageOutputTypeDef = client.register_usage(\n        ProductCode=product_code,\n        UsageAllocations=usage_allocations,\n        UsageQuantity=1, # Deprecated, UsageAllocations is preferred\n        Timestamp=int(os.time.time()),\n    )\n    print(f\"Usage registration successful: {response.get('UsageMeteringRecordId')}\")\n\nexcept client.exceptions.ProductCodeNotFoundException:\n    print(f\"Error: Product code '{product_code}' not found.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize a typed `MarketplaceMeteringClient` and make a sample API call like `register_usage`. Type hints are applied for the client and the response, leveraging the installed `mypy-boto3-meteringmarketplace` stubs. Replace placeholder values with actual AWS credentials and valid Marketplace Metering data. The `TYPE_CHECKING` block ensures that stub imports are only active during type checking, avoiding runtime dependencies on stub packages."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Python 3.8 support was removed in `mypy-boto3-builder` version 8.12.0 and later. Ensure your project runs on Python 3.9 or higher. [cite: 8.12.0 release notes]","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Review your explicit `TypedDict` imports and usages, and update names according to the latest generated stubs.","message":"Starting with `mypy-boto3-builder` 8.9.0, some `TypeDef` names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting `TypeDef` postfixes were reordered. [cite: 8.9.0 release notes]","severity":"breaking","affected_versions":">=8.9.0"},{"fix":"Ensure your type checker (e.g., mypy, pyright) is up-to-date and configured to correctly resolve PEP 561 packages. Most modern setups should handle this automatically.","message":"The `mypy-boto3-builder` project migrated to PEP 561 packages in version 8.12.0. This might affect how type checkers discover stubs in complex project setups or older environments. [cite: 8.12.0 release notes]","severity":"gotcha","affected_versions":">=8.12.0"},{"fix":"Install the lite version: `pip install boto3-stubs-lite[meteringmarketplace]` or disable PyCharm's type checker and rely on external tools like mypy/pyright.","message":"If you experience slow performance or high CPU usage with PyCharm, especially with `Literal` overloads, it is recommended to use the `boto3-stubs-lite` version instead. This offers a more RAM-friendly experience at the cost of requiring more explicit type annotations.","severity":"gotcha","affected_versions":"All"},{"fix":"Implement the `if TYPE_CHECKING:` pattern as shown in the quickstart example, ensuring Pylint correctly parses the code during non-type-checking runs.","message":"For Pylint compatibility, if it complains about undefined variables when using type hints, consider wrapping your stub imports with `if TYPE_CHECKING:` blocks and assigning `object` to the types outside the block.","severity":"gotcha","affected_versions":"All"},{"fix":"Consult the official `boto3` documentation or `mypy-boto3-builder` releases for any service name changes and update your imports accordingly.","message":"AWS service names can change or be deprecated (e.g., `sms-voice` was replaced by `pinpoint-sms-voice` in `mypy-boto3-builder` 8.11.0). If a service client or type definition is not found, verify the current service name in `boto3` documentation. [cite: 8.11.0 release notes]","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}