{"id":3062,"library":"mypy-boto3-compute-optimizer","title":"mypy-boto3-compute-optimizer","description":"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.","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","compute-optimizer","typing"],"install":[{"cmd":"pip install mypy-boto3-compute-optimizer boto3","lang":"bash","label":"Install with boto3"}],"dependencies":[{"reason":"This package provides type stubs for boto3. The actual boto3 library is required for runtime functionality.","package":"boto3","optional":false}],"imports":[{"note":"Import the typed client for Compute Optimizer to annotate boto3.client('compute-optimizer').","symbol":"ComputeOptimizerClient","correct":"from mypy_boto3_compute_optimizer import ComputeOptimizerClient"},{"note":"Import specific TypeDefs for precise response or request body annotations.","symbol":"DescribeRecommendationSummariesResponseTypeDef","correct":"from mypy_boto3_compute_optimizer.type_defs import DescribeRecommendationSummariesResponseTypeDef"},{"note":"While importing Client directly from the 'client' submodule works, the top-level import is generally preferred and more robust against internal structure changes.","wrong":"from mypy_boto3_compute_optimizer.client import ComputeOptimizerClient","symbol":"Client","correct":"import boto3\nfrom mypy_boto3_compute_optimizer import Client as ComputeOptimizerClientType"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_compute_optimizer import ComputeOptimizerClient\nfrom mypy_boto3_compute_optimizer.type_defs import ListRecommendationSummariesResponseTypeDef\n\n# Ensure boto3 is installed: pip install boto3 mypy-boto3-compute-optimizer\n\ndef get_compute_optimizer_summary():\n    # The type hint 'ComputeOptimizerClient' provides static analysis for client methods.\n    client: ComputeOptimizerClient = boto3.client(\"compute-optimizer\")\n\n    # The type hint 'ListRecommendationSummariesResponseTypeDef' helps with response structure.\n    response: ListRecommendationSummariesResponseTypeDef = client.list_recommendation_summaries()\n\n    print(\"Account Recommendation Summaries:\")\n    for summary in response.get(\"RecommendationSummaries\", []):\n        print(f\"  Account ID: {summary.get('AccountId')}, \")\n        print(f\"  Recommendation Count: {summary.get('RecommendationCount')}\")\n\nif __name__ == \"__main__\":\n    get_compute_optimizer_summary()","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. For projects requiring older Python versions, use an older version of mypy-boto3-compute-optimizer (e.g., <1.42.0) if available, but this is not recommended due to lack of updates.","message":"Support for Python 3.8 has been removed in mypy-boto3-builder version 8.12.0 and subsequent stub packages. Your project must use Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0, mypy-boto3-compute-optimizer >= 1.42.0"},{"fix":"If you directly import `TypeDef` classes and encounter `ModuleNotFoundError` or `AttributeError`, check the `mypy-boto3` documentation or generated stubs for the updated naming pattern, which typically involves shorter names or `Extra` postfix moved to the end.","message":"TypeDef naming conventions changed in mypy-boto3-builder 8.9.0. This might affect explicit imports of TypeDefs (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0, mypy-boto3-compute-optimizer >= 1.35.0 (approx.)"},{"fix":"Always install `boto3` alongside `mypy-boto3-compute-optimizer` (e.g., `pip install boto3 mypy-boto3-compute-optimizer`).","message":"This package provides type stubs only. You must also install the `boto3` library for your code to run at runtime. Without `boto3`, your application will fail with import errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install the specific `mypy-boto3-<service-name>` package for each AWS service you are using in your project.","message":"This is a service-specific stub package for AWS Compute Optimizer. If you need type annotations for other AWS services (e.g., S3, EC2), you must install their respective `mypy-boto3-<service-name>` packages.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}