Skip to content

Examples#

Index > CostOptimizationHub > Examples

Auto-generated documentation for CostOptimizationHub type annotations stubs module mypy-boto3-cost-optimization-hub.

Client#

Implicit type annotations#

Can be used with boto3-stubs[cost-optimization-hub] package installed.

Write your CostOptimizationHub code as usual, type checking and code completion should work out of the box.

# CostOptimizationHubClient usage example

from boto3.session import Session


session = Session()

client = session.client("cost-optimization-hub")  # (1)
result = client.get_recommendation()  # (2)
  1. client: CostOptimizationHubClient
  2. result: GetRecommendationResponseTypeDef
# ListEnrollmentStatusesPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("cost-optimization-hub")  # (1)

paginator = client.get_paginator("list_enrollment_statuses")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: CostOptimizationHubClient
  2. paginator: ListEnrollmentStatusesPaginator
  3. item: ListEnrollmentStatusesResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[cost-optimization-hub] or a standalone mypy_boto3_cost_optimization_hub package, you have to explicitly specify client: CostOptimizationHubClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# CostOptimizationHubClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient
from mypy_boto3_cost_optimization_hub.type_defs import GetRecommendationResponseTypeDef
from mypy_boto3_cost_optimization_hub.type_defs import GetRecommendationRequestRequestTypeDef


session = Session()

client: CostOptimizationHubClient = session.client("cost-optimization-hub")

kwargs: GetRecommendationRequestRequestTypeDef = {...}
result: GetRecommendationResponseTypeDef = client.get_recommendation(**kwargs)
# ListEnrollmentStatusesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_cost_optimization_hub.client import CostOptimizationHubClient
from mypy_boto3_cost_optimization_hub.paginator import ListEnrollmentStatusesPaginator
from mypy_boto3_cost_optimization_hub.type_defs import ListEnrollmentStatusesResponseTypeDef


session = Session()
client: CostOptimizationHubClient = session.client("cost-optimization-hub")

paginator: ListEnrollmentStatusesPaginator = client.get_paginator("list_enrollment_statuses")
for item in paginator.paginate(...):
    item: ListEnrollmentStatusesResponseTypeDef
    print(item)