mypy-boto3-compute-optimizer

1.42.3 · active · verified Sat Apr 11

mypy-boto3-compute-optimizer provides type annotations for the boto3 AWS SDK, specifically for the Compute Optimizer service. It ensures static type checking for your boto3 calls related to Compute Optimizer, improving code reliability and developer experience. The current version is 1.42.3, and it's part of the frequently updated mypy-boto3-builder ecosystem, with new versions often released alongside boto3 updates or builder improvements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` client for Compute Optimizer and use the provided type hints for both the client itself and its method responses. This enables static analysis tools like Mypy to catch potential errors at development time.

import boto3
from mypy_boto3_compute_optimizer import ComputeOptimizerClient
from mypy_boto3_compute_optimizer.type_defs import ListRecommendationSummariesResponseTypeDef

# Ensure boto3 is installed: pip install boto3 mypy-boto3-compute-optimizer

def get_compute_optimizer_summary():
    # The type hint 'ComputeOptimizerClient' provides static analysis for client methods.
    client: ComputeOptimizerClient = boto3.client("compute-optimizer")

    # The type hint 'ListRecommendationSummariesResponseTypeDef' helps with response structure.
    response: ListRecommendationSummariesResponseTypeDef = client.list_recommendation_summaries()

    print("Account Recommendation Summaries:")
    for summary in response.get("RecommendationSummaries", []):
        print(f"  Account ID: {summary.get('AccountId')}, ")
        print(f"  Recommendation Count: {summary.get('RecommendationCount')}")

if __name__ == "__main__":
    get_compute_optimizer_summary()

view raw JSON →