Examples#
Index > ComputeOptimizer > Examples
Auto-generated documentation for ComputeOptimizer type annotations stubs module mypy-boto3-compute-optimizer.
Client#
Implicit type annotations#
Can be used with boto3-stubs[compute-optimizer]
package installed.
Write your ComputeOptimizer
code as usual,
type checking and code completion should work out of the box.
# ComputeOptimizerClient usage example
from boto3.session import Session
session = Session()
client = session.client("compute-optimizer") # (1)
result = client.describe_recommendation_export_jobs() # (2)
# DescribeRecommendationExportJobsPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("compute-optimizer") # (1)
paginator = client.get_paginator("describe_recommendation_export_jobs") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: ComputeOptimizerClient
- paginator: DescribeRecommendationExportJobsPaginator
- item: DescribeRecommendationExportJobsResponseTypeDef
Explicit type annotations#
With boto3-stubs-lite[compute-optimizer]
or a standalone mypy_boto3_compute_optimizer
package, you have to explicitly specify client: ComputeOptimizerClient
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.
# ComputeOptimizerClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_compute_optimizer.client import ComputeOptimizerClient
from mypy_boto3_compute_optimizer.type_defs import DescribeRecommendationExportJobsResponseTypeDef
from mypy_boto3_compute_optimizer.type_defs import DescribeRecommendationExportJobsRequestRequestTypeDef
session = Session()
client: ComputeOptimizerClient = session.client("compute-optimizer")
kwargs: DescribeRecommendationExportJobsRequestRequestTypeDef = {...}
result: DescribeRecommendationExportJobsResponseTypeDef = client.describe_recommendation_export_jobs(**kwargs)
# DescribeRecommendationExportJobsPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_compute_optimizer.client import ComputeOptimizerClient
from mypy_boto3_compute_optimizer.paginator import DescribeRecommendationExportJobsPaginator
from mypy_boto3_compute_optimizer.type_defs import DescribeRecommendationExportJobsResponseTypeDef
session = Session()
client: ComputeOptimizerClient = session.client("compute-optimizer")
paginator: DescribeRecommendationExportJobsPaginator = client.get_paginator("describe_recommendation_export_jobs")
for item in paginator.paginate(...):
item: DescribeRecommendationExportJobsResponseTypeDef
print(item)