mypy-boto3-budgets Type Stubs

1.42.33 · active · verified Sat Apr 11

Type annotations for `boto3` AWS Budgets service, generated by `mypy-boto3-builder`. It provides type checking support for `boto3` clients, paginators, literals, and type definitions, compatible with various IDEs and type checkers like `mypy` and `pyright`. The library's version directly corresponds to the `boto3` version it types.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `BudgetsClient` type annotation with a `boto3` client. It shows how to correctly type-hint a client and then use it with a common operation like `describe_budgets`, benefiting from autocompletion and static type checking. Replace '123456789012' with a valid AWS account ID or use `os.environ.get` for programmatic access.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_budgets import BudgetsClient
    from mypy_boto3_budgets.type_defs import DescribeBudgetsOutputTypeDef

# Initialize a boto3 session and client
session = boto3.session.Session()
client: BudgetsClient = session.client("budgets")

# Example usage with type-hinted client
try:
    response: DescribeBudgetsOutputTypeDef = client.describe_budgets(AccountId="123456789012")
    print("Budgets found:")
    for budget in response.get('Budgets', []):
        print(f"  - {budget.get('BudgetName')}: {budget.get('BudgetType')}")
except client.exceptions.NotFoundException:
    print("No budgets found for account.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →