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-hubVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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`.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.
Install the package using pip: `python -m pip install mypy-boto3-cost-optimization-hub` or `python -m pip install 'boto3-stubs[cost-optimization-hub]'`.
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.
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')`.