mypy-boto3-bcm-dashboards Type Annotations

1.42.87 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

Demonstrates how to initialize a `boto3` client and type-hint it with `mypy-boto3-bcm-dashboards` for static analysis. This allows `mypy` to verify the client's methods and parameters.

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

view raw JSON →