{"id":3567,"library":"mypy-boto3-compute-optimizer-automation","title":"mypy-boto3-compute-optimizer-automation Type Stubs","description":"This library provides type annotations (stubs) for the `boto3` AWS SDK, specifically for the `ComputeOptimizerAutomation` service. It enables static type checking with tools like Mypy and enhances IDE auto-completion for `boto3` operations, improving code quality and reducing runtime errors. The current version is 1.42.3, and it is part of the frequently updated `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","compute-optimizer-automation","typing"],"install":[{"cmd":"pip install mypy-boto3-compute-optimizer-automation","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install boto3","lang":"bash","label":"Install boto3 (runtime dependency)"}],"dependencies":[{"reason":"Provides the underlying AWS SDK for which these are type stubs. Required for runtime execution.","package":"boto3","optional":false}],"imports":[{"note":"Import the type for the client.","symbol":"ComputeOptimizerAutomationClient","correct":"from mypy_boto3_compute_optimizer_automation import ComputeOptimizerAutomationClient"},{"note":"Import specific TypeDefs for request/response bodies.","symbol":"ListAutomationRulesResponseTypeDef","correct":"from mypy_boto3_compute_optimizer_automation.type_defs import ListAutomationRulesResponseTypeDef"},{"note":"Import paginator types if using `get_paginator`.","symbol":"ComputeOptimizerAutomationPaginator","correct":"from mypy_boto3_compute_optimizer_automation.paginator import ListAutomationRulesPaginator"}],"quickstart":{"code":"import os\nfrom typing import TYPE_CHECKING\nimport boto3\n\n# These imports are only for type checking, not for runtime execution\nif TYPE_CHECKING:\n    from mypy_boto3_compute_optimizer_automation import ComputeOptimizerAutomationClient\n    from mypy_boto3_compute_optimizer_automation.type_defs import ListAutomationRulesResponseTypeDef\n\ndef get_compute_optimizer_automation_client() -> \"ComputeOptimizerAutomationClient\":\n    \"\"\"\n    Provides a type-hinted ComputeOptimizerAutomation client.\n    Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set in environment.\n    \"\"\"\n    session = boto3.Session(\n        aws_access_key_id=os.environ.get(\"AWS_ACCESS_KEY_ID\", \"dummy\"),\n        aws_secret_access_key=os.environ.get(\"AWS_SECRET_ACCESS_KEY\", \"dummy\"),\n        region_name=os.environ.get(\"AWS_REGION\", \"us-east-1\")\n    )\n    return session.client(\"compute-optimizer-automation\")\n\ndef list_all_automation_rules():\n    \"\"\"Lists all Compute Optimizer Automation rules with type hints.\"\"\"\n    # Explicitly type the client for better IDE support and type checking\n    client: ComputeOptimizerAutomationClient = get_compute_optimizer_automation_client()\n    \n    print(\"Attempting to list Compute Optimizer Automation Rules...\")\n    try:\n        # Type the response for detailed type checking of the result\n        response: ListAutomationRulesResponseTypeDef = client.list_automation_rules()\n        \n        rules = response.get(\"AutomationRules\", [])\n        if rules:\n            print(\"Compute Optimizer Automation Rules found:\")\n            for rule in rules:\n                print(f\"  - Name: {rule.get('RuleName', 'N/A')}, ARN: {rule.get('RuleArn', 'N/A')}\")\n        else:\n            print(\"No Compute Optimizer Automation rules found.\")\n        \n        if response.get(\"NextToken\"):\n            print(\" (More rules available, consider using a paginator for a full list)\")\n    except Exception as e:\n        print(f\"Error listing rules: {e}\")\n        print(\"Please ensure your AWS credentials and region are correctly configured.\")\n\nif __name__ == \"__main__\":\n    # Set dummy environment variables if not already set for runnable example\n    # In a real scenario, these should be valid AWS credentials\n    os.environ.setdefault('AWS_ACCESS_KEY_ID', 'AKIAIOSFODNN7EXAMPLE')\n    os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')\n    os.environ.setdefault('AWS_REGION', 'us-east-1')\n    list_all_automation_rules()","lang":"python","description":"This quickstart demonstrates how to initialize a type-hinted `ComputeOptimizerAutomationClient` and use it to list automation rules, leveraging type annotations for improved developer experience and static analysis. It uses environment variables for AWS credentials, suitable for local execution and CI/CD pipelines."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later.","message":"Python 3.8 support was removed from `mypy-boto3-builder` version `8.12.0` (which generates these stubs). Projects using this library now require Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0"},{"fix":"Update your TypeDef imports and variable annotations to reflect the new, shorter naming convention.","message":"In `mypy-boto3-builder` version `8.9.0`, TypeDef naming conventions were changed (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This might break existing explicit type annotations in your code.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0"},{"fix":"Ensure `boto3` is installed in your project: `pip install boto3`.","message":"This package provides *type stubs* for static analysis with tools like Mypy or IDEs. It does *not* include the `boto3` library itself. `boto3` must be installed separately for your application to run at runtime.","severity":"gotcha","affected_versions":"All"},{"fix":"Add explicit type hints, e.g., `client: ComputeOptimizerAutomationClient = session.client(\"compute-optimizer-automation\")`, and import the client type from `mypy_boto3_compute_optimizer_automation`.","message":"For optimal IDE support (VSCode, PyCharm) and robust static type checking, it is often recommended to use *explicit type annotations* for `boto3.client` and `boto3.session.client` calls, rather than relying solely on implicit type discovery.","severity":"gotcha","affected_versions":"All"},{"fix":"Implement conditional type declarations: `if TYPE_CHECKING: from mypy_boto3_... import ClientType else: ClientType = object`.","message":"When using `mypy-boto3` packages with `pylint`, you might encounter 'undefined variable' warnings if types are guarded by `if TYPE_CHECKING:`. A common workaround is to conditionally set types to `object` outside of the `TYPE_CHECKING` block to satisfy `pylint`.","severity":"gotcha","affected_versions":"All (with Pylint)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}