Registry / type-stubs / mypy-boto3-ce

mypy-boto3-ce

JSON →
library1.43.22pypypi✓ verified 25d ago

mypy-boto3-ce provides comprehensive type annotations for the AWS Boto3 Cost Explorer (CE) service, ensuring static type checking for your Python code. It is automatically generated by `mypy-boto3-builder` (currently version 8.12.0) and is updated frequently to align with `boto3` and `botocore` releases, enhancing code quality and developer experience by catching potential AWS-related errors before runtime.

pip install mypy-boto3-ce
INSTALL
IMPORT
SIG · MYPY-BOTO3-CE
M
mypy-boto3-ce
type-stubspythonv1.43.22
Install
3.5s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.43.22 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.5s · import 0.000s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CostExplorerClient
from mypy_boto3_ce import CostExplorerClient
from mypy_boto3_ce import CostExplorerClient

This quickstart demonstrates how to initialize a Boto3 Cost Explorer client with type hints from `mypy-boto3-ce` and use it to retrieve cost and usage data. It uses the `TYPE_CHECKING` guard to ensure `mypy-boto3-ce` is only a development dependency.

from typing import TYPE_CHECKING import boto3 import os if TYPE_CHECKING: from mypy_boto3_ce.client import CostExplorerClient from mypy_boto3_ce.type_defs import GetCostAndUsageResponseTypeDef # It's recommended to use explicit type hints for boto3.client for better IDE support # and type checking, especially if not using the 'boto3-stubs' full package. def get_cost_explorer_data(client: "CostExplorerClient") -> "GetCostAndUsageResponseTypeDef": # Example: Retrieve cost and usage data for the last 7 days response = client.get_cost_and_usage( TimePeriod={ 'Start': '2023-01-01', 'End': '2023-01-08' }, Granularity='DAILY', Metrics=['BlendedCost', 'UnblendedCost'], # Add other parameters as needed, e.g., Filter, GroupBy ) return response if __name__ == '__main__': # Ensure AWS credentials are configured (e.g., via environment variables or AWS CLI config) # For this example, we'll create a client. In a real app, you might pass an existing client. print("Initializing Boto3 Cost Explorer client...") ce_client: "CostExplorerClient" = boto3.client( "ce", region_name=os.environ.get('AWS_REGION', 'us-east-1'), aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'), aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET') ) try: # The `get_cost_explorer_data` function now benefits from type hints # for both the client object and the response structure. costs_data = get_cost_explorer_data(ce_client) print("Successfully retrieved Cost Explorer data (truncated for brevity):") # In a real scenario, you'd process costs_data. For this example, just print a key. if costs_data and 'ResultsByTime' in costs_data: print(f"First result time period: {costs_data['ResultsByTime'][0]['TimePeriod']}") else: print("No results or unexpected response structure.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingSupport for Python 3.8 was officially removed with `mypy-boto3-builder` version 8.12.0. Ensure your project runs on Python 3.9 or higher.
fix
Upgrade your Python environment to 3.9 or newer.
affects: mypy-boto3-builder >= 8.12.0
breakingTypeDef naming conventions were changed in `mypy-boto3-builder` 8.9.0. This could affect existing type hints for method arguments (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting TypeDef postfixes (e.g., `CreateDistributionExtraRequestTypeDef` to `CreateDistributionRequestExtraTypeDef`).
fix
Review and update type hint imports and usage in your codebase to match the new naming conventions. Static analysis tools will highlight these changes.
affects: mypy-boto3-builder >= 8.9.0
gotchaExplicit type annotations are highly recommended for `boto3.client`, `boto3.session.client`, `client.get_waiter`, and `client.get_paginator` calls. While some IDEs (like PyCharm) and static analyzers (like Mypy) might infer types, VSCode's Python extension might not fully support function overloads, leading to a lack of auto-completion and type checking without explicit hints.
fix
Always explicitly type-hint your Boto3 clients and resources (e.g., `client: CostExplorerClient = boto3.client("ce")`).
affects: All
gotchaTo avoid a runtime dependency on `mypy-boto3-ce` in production environments, it is common practice to guard imports with `if TYPE_CHECKING:` from the `typing` module.
fix
Wrap type-only imports within `if TYPE_CHECKING:` blocks and provide runtime fallbacks (e.g., `Client = object`) if necessary, although for simple client usage, it's often not needed at runtime.
affects: All
deprecatedThe `mypy-boto3-builder` project occasionally removes or renames service stubs (e.g., `sms-voice` was removed in 8.11.0 and replaced by `pinpoint-sms-voice`). While `mypy-boto3-ce` is stable, be aware that services may change, requiring updates to your stub installations.
fix
Monitor `mypy-boto3-builder` release notes and `boto3` documentation for service changes. Update your `pip install` commands and import paths accordingly if a service you use is affected.
affects: mypy-boto3-builder >= 8.11.0 (general warning for ecosystem)
Upgrade
Version history
1.43.22latest on PyPI · released Jun 3, 2026
Audit
Dependencies
boto3requiredProvides the AWS SDK for Python that these stubs type-annotate.
mypyoptionalPrimary static type checker for which these annotations are designed.
typing-extensionsoptionalRequired for some advanced type features on Python versions older than 3.9, though 3.8 support has been removed.
Agent activity
26 hits · last 30 days
node
22
OpenAI (training)
1
Resources
mypy-boto3-ce — pip install mypy-boto3-ce · libregistry