mypy-boto3-budgets Type Stubs
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
- breaking Starting with mypy-boto3-builder version 8.12.0 (which generates mypy-boto3-budgets), support for Python 3.8 has been removed across all generated packages. Ensure your Python environment is 3.9 or newer.
- breaking mypy-boto3-builder version 8.9.0 introduced breaking changes to generated TypeDef naming conventions. Packed method arguments now use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes are moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). This may affect explicit `TypeDef` imports.
- gotcha This package provides only type annotations. You must still install the actual `boto3` library for your code to run. `mypy-boto3-budgets` provides no runtime functionality on its own.
- gotcha mypy-boto3-builder migrated to PEP 561 compliant packages with release 8.12.0. While this improves standard compatibility, ensure your `mypy` version is up-to-date to correctly discover and use these stub packages.
- gotcha PyCharm users might experience slow performance with Literal overloads in these stubs (due to PyCharm issue PY-40997). It is recommended to use `boto3-stubs-lite` (if available for the service), or disable PyCharm's type checker and rely on external tools like `mypy` or `pyright`.
Install
-
pip install boto3 mypy-boto3-budgets mypy
Imports
- BudgetsClient
from mypy_boto3_budgets import BudgetsClient
- BudgetsServiceName
from mypy_boto3_budgets.literals import BudgetsServiceName
- BudgetTypeDef
from mypy_boto3_budgets.type_defs import BudgetTypeDef
Quickstart
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}")