Type annotations for boto3 Cost and Usage Report (CUR)

1.42.3 · active · verified Sat Apr 11

mypy-boto3-cur provides type annotations for the boto3 Cost and Usage Report (CUR) service, ensuring static type checking compatibility for your AWS Python applications. It aligns with the boto3 version 1.42.3 and is generated using mypy-boto3-builder 8.12.0. The library helps catch potential type-related errors at development time.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted CUR client and use it to list report definitions. Explicit type annotations on the client and response objects leverage the type stubs for improved autocompletion and static analysis.

import boto3
from mypy_boto3_cur.client import CURClient
from mypy_boto3_cur.type_defs import DescribeReportDefinitionsResponseTypeDef
import os

def get_cur_client() -> CURClient:
    """Returns a typed CUR client."""
    session = boto3.Session(region_name=os.environ.get('AWS_REGION', 'us-east-1'))
    client: CURClient = session.client("cur")
    return client

def list_cur_definitions():
    """Lists Cost and Usage Report definitions with type hints."""
    cur_client = get_cur_client()
    response: DescribeReportDefinitionsResponseTypeDef = cur_client.describe_report_definitions()
    print("Report Definitions:")
    for report in response.get("ReportDefinitions", []):
        print(f"  - {report['ReportName']} (Status: {report['ReportStatus']})")

if __name__ == "__main__":
    # Ensure AWS credentials/region are configured in environment or ~/.aws/credentials
    # For example: export AWS_REGION='us-east-1'
    # To run this, you would typically need 'boto3' installed alongside 'mypy-boto3-cur'
    list_cur_definitions()

view raw JSON →