{"id":3571,"library":"mypy-boto3-cost-optimization-hub","title":"mypy-boto3-cost-optimization-hub Type Annotations","description":"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.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-stubs","cost-optimization-hub","typing"],"install":[{"cmd":"pip install mypy-boto3-cost-optimization-hub","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install 'boto3-stubs[cost-optimization-hub]'","lang":"bash","label":"Install as boto3-stubs extra"}],"dependencies":[{"reason":"Provides the underlying AWS SDK runtime functionality that these type stubs annotate.","package":"boto3","optional":false}],"imports":[{"note":"Imports for type stubs should ideally be guarded by `if TYPE_CHECKING:` to avoid runtime dependencies on stub packages.","symbol":"CostOptimizationHubClient","correct":"from typing import TYPE_CHECKING\nif TYPE_CHECKING:\n    from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient"},{"note":"TypeDefs provide precise type hints for API response structures and should also be guarded by `if TYPE_CHECKING:`.","symbol":"ResponseMetadataTypeDef","correct":"from typing import TYPE_CHECKING\nif TYPE_CHECKING:\n    from mypy_boto3_cost_optimization_hub.type_defs import ResponseMetadataTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient\n    from mypy_boto3_cost_optimization_hub.type_defs import ListRecommendationSummariesResponseTypeDef\n\ndef get_cost_optimization_client() -> CostOptimizationHubClient:\n    \"\"\"Returns a type-hinted CostOptimizationHub client.\"\"\"\n    session = boto3.session.Session()\n    return session.client(\"cost-optimization-hub\")\n\nclient: CostOptimizationHubClient = get_cost_optimization_client()\n\ntry:\n    # Example: List recommendation summaries\n    response: ListRecommendationSummariesResponseTypeDef = client.list_recommendation_summaries()\n    print(f\"Recommendations found: {len(response.get('RecommendationSummaries', []))}\")\n    for summary in response.get('RecommendationSummaries', []):\n        print(f\"  - {summary.get('RecommendationTarget')}: {summary.get('EstimatedSavings', {}).get('Amount')}\")\nexcept client.exceptions.AccessDeniedException as e:\n    print(f\"Error: Access Denied. Ensure you have permissions for Cost Optimization Hub. Details: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")","lang":"python","description":"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."},"warnings":[{"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.","message":"Python 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.","severity":"breaking","affected_versions":">=1.42.3 (for this package), >=8.12.0 (for mypy-boto3-builder)"},{"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.","message":"The `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.","severity":"breaking","affected_versions":">=1.42.3 (for this package), >=8.12.0 (for mypy-boto3-builder)"},{"fix":"Modify your imports to use the `if TYPE_CHECKING:` pattern: `from typing import TYPE_CHECKING\nif TYPE_CHECKING:\n    from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient`.","message":"To 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Across 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.","severity":"breaking","affected_versions":">=1.42.3 (for this package), >=8.9.0 (for mypy-boto3-builder)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}