Type annotations for boto3 BillingandCostManagementPricingCalculator
Provides type annotations for the `boto3` AWS Billing and Cost Management Pricing Calculator service. It enhances static type checking for `boto3` clients, resources, and their methods, offering improved autocomplete and error detection in IDEs and with tools like `mypy` and `pyright`. This package is part of the `mypy-boto3-builder` ecosystem, which typically releases updates in sync with `boto3` versions.
Warnings
- breaking Python 3.8 support was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 must pin an older version of `mypy-boto3-builder` or `mypy-boto3-bcm-pricing-calculator` if direct installation of this specific stub package is done, or upgrade their Python version.
- breaking The `mypy-boto3-builder` migrated to PEP 561 compliant packages in version 8.12.0. This might affect how some tools discover or interpret type stubs, especially in older or less compliant environments.
- gotcha PyCharm users may experience slow performance or high CPU usage due to `Literal` overloads. It is recommended to use `types-boto3-lite` (if available for this service) or disable PyCharm's type checker and rely on `mypy`/`pyright` for checks.
- gotcha This library provides *only* type annotations. `boto3` itself is a separate runtime dependency and must be installed alongside `mypy-boto3-bcm-pricing-calculator` for your code to run.
- breaking Breaking changes were introduced in `mypy-boto3-builder` 8.9.0, specifically regarding `TypeDef` naming conventions (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). While this specific service might not be directly affected by these exact names, similar changes could impact other generated types.
Install
-
pip install mypy-boto3-bcm-pricing-calculator boto3
Imports
- BillingandCostManagementPricingCalculatorClient
from mypy_boto3_bcm_pricing_calculator.client import BillingandCostManagementPricingCalculatorClient
Quickstart
import boto3
from mypy_boto3_bcm_pricing_calculator.client import BillingandCostManagementPricingCalculatorClient
from typing import TYPE_CHECKING, cast
import os
# Ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials)
# For a runnable example, ensure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION are set.
# Or configure a mock client for testing without actual AWS calls.
if TYPE_CHECKING:
client: BillingandCostManagementPricingCalculatorClient = boto3.client("bcm-pricing-calculator")
else:
client = boto3.client("bcm-pricing-calculator")
try:
# Example: Create a new bill scenario
# The Billing and Cost Management Pricing Calculator API is complex and often requires specific parameters.
# This is a minimal example; adjust parameters as per your actual use case.
scenario_name = f"MyTypeHintedScenario-{os.urandom(4).hex()}"
response = client.create_bill_scenario(
Name=scenario_name,
GroupSharingPreference='OPEN'
)
print(f"Successfully created bill scenario: {response['name']} (ID: {response['id']})")
# Example of retrieving scenarios (if any exist)
list_response = client.list_bill_scenarios()
print("\nExisting Bill Scenarios:")
for scenario in list_response.get('BillScenarios', []):
print(f" - {scenario['name']} (ID: {scenario['id']})")
# For cleanup, you might delete the created scenario:
# client.delete_bill_scenario(Id=response['id'])
# print(f"Deleted scenario {response['id']}")
except client.exceptions.AccessDeniedException:
print("Access Denied. Ensure your AWS credentials have permissions for bcm-pricing-calculator service.")
except Exception as e:
print(f"An error occurred: {e}")