Registry / type-stubs / mypy-boto3-cost-optimization-hub

mypy-boto3-cost-optimization-hub

JSON →
library1.43.25pypypi✓ verified 22d ago

This library provides comprehensive type annotations for the `boto3` AWS SDK's Cost Optimization Hub service. Generated by `mypy-boto3-builder`, it ensures full type checking compatibility with tools like MyPy, Pyright, VSCode, and PyCharm, enabling developers to write more robust and error-free AWS-interacting Python code. The current version is 1.42.3, following the active and frequent release cadence of the underlying `mypy-boto3-builder` project.

pip install mypy-boto3-cost-optimization-hub
INSTALL
IMPORT
SIG · MYPY-BOTO3-COST-OP
M
mypy-boto3-cost-optimization-hub
type-stubspythonv1.43.25
Install
3.3s avg
Import
11ms
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.25 · 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.010s · 19.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.3s · import 0.006s · 20MB
18MB installed
● package 18MB
Code
Verified usage

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

CostOptimizationHubClient
from typing import TYPE_CHECKING if TYPE_CHECKING: from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient
Imports for type stubs should ideally be guarded by `if TYPE_CHECKING:` to avoid runtime dependencies on stub packages.
ResponseMetadataTypeDef
from typing import TYPE_CHECKING if TYPE_CHECKING: from mypy_boto3_cost_optimization_hub.type_defs import ResponseMetadataTypeDef
TypeDefs provide precise type hints for API response structures and should also be guarded by `if TYPE_CHECKING:`.

This quickstart demonstrates how to instantiate a type-hinted `CostOptimizationHubClient` and perform a basic API call, `list_recommendation_summaries`. It includes the recommended `TYPE_CHECKING` guard for stub imports and basic error handling.

import boto3 from typing import TYPE_CHECKING if TYPE_CHECKING: from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient from mypy_boto3_cost_optimization_hub.type_defs import ListRecommendationSummariesResponseTypeDef def get_cost_optimization_client() -> CostOptimizationHubClient: """Returns a type-hinted CostOptimizationHub client.""" session = boto3.session.Session() return session.client("cost-optimization-hub") client: CostOptimizationHubClient = get_cost_optimization_client() try: # Example: List recommendation summaries response: ListRecommendationSummariesResponseTypeDef = client.list_recommendation_summaries() print(f"Recommendations found: {len(response.get('RecommendationSummaries', []))}") for summary in response.get('RecommendationSummaries', []): print(f" - {summary.get('RecommendationTarget')}: {summary.get('EstimatedSavings', {}).get('Amount')}") except client.exceptions.AccessDeniedException as e: print(f"Error: Access Denied. Ensure you have permissions for Cost Optimization Hub. Details: {e}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingPython 3.8 support was removed starting with `mypy-boto3-builder` version 8.12.0. Consequently, `mypy-boto3-cost-optimization-hub` version 1.42.3 and newer require Python 3.9 or higher.
fix
Upgrade your Python environment to 3.9 or a newer supported version. If unable to upgrade, you must pin to an older version of `mypy-boto3-cost-optimization-hub` that supported Python 3.8.
affects: >=1.42.3 (for this package), >=8.12.0 (for mypy-boto3-builder)
breakingThe `mypy-boto3` ecosystem migrated to PEP 561 compliant packages with `mypy-boto3-builder` version 8.12.0. While this improves packaging standards, it might affect custom build processes or older environments directly consuming `mypy-boto3-builder` outputs, though direct `pip install` users should see minimal impact.
fix
Ensure your project's packaging and type-checking configurations are up-to-date with PEP 561 standards. For most users, simply updating `pip` and installing the latest stubs should suffice.
affects: >=1.42.3 (for this package), >=8.12.0 (for mypy-boto3-builder)
gotchaTo avoid runtime dependencies on `mypy-boto3-cost-optimization-hub` and prevent potential Pylint warnings, always wrap type-specific imports (e.g., `CostOptimizationHubClient`, `TypeDefs`) within an `if TYPE_CHECKING:` block.
fix
Modify your imports to use the `if TYPE_CHECKING:` pattern: `from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient`.
affects: All versions
breakingAcross the `mypy-boto3` family, `TypeDef` naming conventions changed with `mypy-boto3-builder` version 8.9.0. This involved shortening packed method argument TypeDefs (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`) and moving 'Extra' postfixes.
fix
Review your code for direct usage of specific `TypeDef` names. If you encounter `NameError` or type-checking issues with `TypeDef`s, consult the `mypy-boto3` documentation for the updated naming conventions for Cost Optimization Hub types.
affects: >=1.42.3 (for this package), >=8.9.0 (for mypy-boto3-builder)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'mypy_boto3_cost_optimization_hub'
The `mypy-boto3-cost-optimization-hub` package, or its parent `boto3-stubs` with the specific service extra, is not installed in the Python environment being used.
fix
Install the package using pip: `python -m pip install mypy-boto3-cost-optimization-hub` or `python -m pip install 'boto3-stubs[cost-optimization-hub]'`.
error: Cannot find implementation or library stub for module named 'boto3.client.costoptimizationhub'
MyPy is unable to locate or properly utilize the installed type stubs for `boto3` or the specific `cost-optimization-hub` service. This often happens if MyPy is running in a different Python environment than where the stubs are installed, or due to MyPy's import resolution challenges.
fix
Ensure `mypy-boto3-cost-optimization-hub` (or `boto3-stubs[cost-optimization-hub]`) is correctly installed in the active virtual environment. Verify that MyPy is configured to use the correct Python executable or environment. If issues persist, explicitly add the stub's path to `MYPYPATH` or use the `--python-executable` flag when running MyPy.
error: Incompatible types in assignment (expression has type "Any", variable has type "CostOptimizationHubClient")
When `boto3.client('cost-optimization-hub')` is called, MyPy often infers the client object's type as `Any` if explicit type annotations are not provided, leading to type checking errors when assigning it to a specific `mypy-boto3` client type. This also applies when passing an `Any`-typed client to a function expecting a typed client.
fix
Explicitly annotate the `boto3.client` call with the correct client type imported from `mypy_boto3_cost_optimization_hub`. For example: `from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient; client: CostOptimizationHubClient = boto3.client('cost-optimization-hub')`.
Upgrade
Version history
1.43.25latest on PyPI · released Jun 8, 2026
Audit
Dependencies
boto3requiredProvides the underlying AWS SDK runtime functionality that these type stubs annotate.
Agent activity
21 hits · last 30 days
node
16
OpenAI (training)
2
Amazon
1
Resources
mypy-boto3-cost-optimization-hub — pip install mypy-boto3-cost-optimization-hub · libregistry