mypy-boto3-bcm-dashboards Type Annotations
This package provides type annotations (stubs) for the `boto3` AWS SDK, specifically for the 'BillingandCostManagementDashboards' service. It allows static type checkers like `mypy` to validate `boto3` client calls, improving code quality and catching potential errors early. The library is part of the `mypy-boto3-builder` project, which generates stubs for all `boto3` services and releases frequently, often in sync with `boto3` and builder updates. Current version is 1.42.87.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 must upgrade to Python 3.9 or newer to continue receiving updates and fixes for `mypy-boto3` stubs.
- breaking The `mypy-boto3` builder migrated all packages to PEP 561 compliance in version 8.12.0. While this improves packaging and type checker compatibility, it might affect custom packaging setups or older environments. Ensure your `pip` and `setuptools` are up-to-date.
- breaking In `mypy-boto3-builder` version 8.9.0, TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If your code explicitly references these types, you may need to update their names.
- gotcha The installed package name `mypy-boto3-bcm-dashboards` uses hyphens, but the Python import path uses underscores (`mypy_boto3_bcm_dashboards`). Always use underscores in your import statements.
Install
-
pip install mypy-boto3-bcm-dashboards boto3
Imports
- BillingandCostManagementDashboardsClient
from mypy_boto3_bcm_dashboards.client import BillingandCostManagementDashboardsClient
- Client
from boto3.session import Session bcm_client: BillingandCostManagementDashboardsClient = Session().client('billing-cost-management-dashboards')
Quickstart
import boto3
from mypy_boto3_bcm_dashboards.client import BillingandCostManagementDashboardsClient
from typing import List, Dict, Any
def get_dashboards(client: BillingandCostManagementDashboardsClient) -> List[Dict[str, Any]]:
try:
response = client.list_dashboards(
MaxResults=10
)
return response.get('Dashboards', [])
except client.exceptions.ResourceNotFoundException:
print("No dashboards found.")
return []
except Exception as e:
print(f"An error occurred: {e}")
return []
if __name__ == '__main__':
# Example usage with boto3 client
bcm_client: BillingandCostManagementDashboardsClient = boto3.client('billing-cost-management-dashboards')
dashboards = get_dashboards(bcm_client)
print(f"Found {len(dashboards)} dashboards.")
# This code can now be type-checked by mypy for correct API usage