Registry /
type-stubs / mypy-boto3-compute-optimizer-automation
Install & Compatibility
Where this runs
tested against v1.43.32 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.4MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.7s · import 0.000s · 19MB
71MB installed
● package 71MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ComputeOptimizerAutomationClient
✓ from mypy_boto3_compute_optimizer_automation import ComputeOptimizerAutomationClient
✗ from mypy_boto3_compute_optimizer_automation import ComputeOptimizerAutomationClient
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.
import os
from typing import TYPE_CHECKING
import boto3
# These imports are only for type checking, not for runtime execution
if TYPE_CHECKING:
from mypy_boto3_compute_optimizer_automation import ComputeOptimizerAutomationClient
from mypy_boto3_compute_optimizer_automation.type_defs import ListAutomationRulesResponseTypeDef
def get_compute_optimizer_automation_client() -> "ComputeOptimizerAutomationClient":
"""
Provides a type-hinted ComputeOptimizerAutomation client.
Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set in environment.
"""
session = boto3.Session(
aws_access_key_id=os.environ.get("AWS_ACCESS_KEY_ID", "dummy"),
aws_secret_access_key=os.environ.get("AWS_SECRET_ACCESS_KEY", "dummy"),
region_name=os.environ.get("AWS_REGION", "us-east-1")
)
return session.client("compute-optimizer-automation")
def list_all_automation_rules():
"""Lists all Compute Optimizer Automation rules with type hints."""
# Explicitly type the client for better IDE support and type checking
client: ComputeOptimizerAutomationClient = get_compute_optimizer_automation_client()
print("Attempting to list Compute Optimizer Automation Rules...")
try:
# Type the response for detailed type checking of the result
response: ListAutomationRulesResponseTypeDef = client.list_automation_rules()
rules = response.get("AutomationRules", [])
if rules:
print("Compute Optimizer Automation Rules found:")
for rule in rules:
print(f" - Name: {rule.get('RuleName', 'N/A')}, ARN: {rule.get('RuleArn', 'N/A')}")
else:
print("No Compute Optimizer Automation rules found.")
if response.get("NextToken"):
print(" (More rules available, consider using a paginator for a full list)")
except Exception as e:
print(f"Error listing rules: {e}")
print("Please ensure your AWS credentials and region are correctly configured.")
if __name__ == "__main__":
# Set dummy environment variables if not already set for runnable example
# In a real scenario, these should be valid AWS credentials
os.environ.setdefault('AWS_ACCESS_KEY_ID', 'AKIAIOSFODNN7EXAMPLE')
os.environ.setdefault('AWS_SECRET_ACCESS_KEY', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
os.environ.setdefault('AWS_REGION', 'us-east-1')
list_all_automation_rules()
Debug
Known issues
breakingPython 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.fixUpgrade your Python environment to 3.9 or later.
affects: mypy-boto3-builder >= 8.12.0
breakingIn `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.fixUpdate your TypeDef imports and variable annotations to reflect the new, shorter naming convention.
affects: mypy-boto3-builder >= 8.9.0
gotchaThis 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.fixEnsure `boto3` is installed in your project: `pip install boto3`.
affects: All
gotchaFor 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.fixAdd explicit type hints, e.g., `client: ComputeOptimizerAutomationClient = session.client("compute-optimizer-automation")`, and import the client type from `mypy_boto3_compute_optimizer_automation`. affects: All
gotchaWhen 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`.fixImplement conditional type declarations: `if TYPE_CHECKING: from mypy_boto3_... import ClientType else: ClientType = object`.
affects: All (with Pylint)
Upgrade
Version history
1.43.32latest on PyPI · released Jun 17, 2026
Audit
Dependencies
boto3requiredProvides the underlying AWS SDK for which these are type stubs. Required for runtime execution.