mypy-boto3-cloud9 Type Annotations

1.42.3 · active · verified Sat Apr 11

Provides type annotations for the `boto3` Cloud9 service, enabling static type checking with tools like `mypy`, as well as enhanced auto-completion in IDEs. It is part of the `mypy-boto3-builder` ecosystem, with versions typically aligning with `boto3` releases, ensuring up-to-date type stubs for AWS services.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `mypy-boto3-cloud9` to type-hint a `boto3` Cloud9 client and its response. It lists the available Cloud9 environments in a specified AWS region. Run `mypy cloud9_example.py` to check for type errors.

import boto3
from mypy_boto3_cloud9.client import Cloud9Client
from mypy_boto3_cloud9.type_defs import ListEnvironmentsResultTypeDef

def get_cloud9_environments(region: str) -> ListEnvironmentsResultTypeDef:
    """Lists AWS Cloud9 environments with type annotations."""
    client: Cloud9Client = boto3.client("cloud9", region_name=region)
    response: ListEnvironmentsResultTypeDef = client.list_environments()
    return response

if __name__ == "__main__":
    # Replace with your desired region, or use environment variable/config
    aws_region = "us-east-1"
    try:
        environments = get_cloud9_environments(aws_region)
        print(f"Cloud9 environments in {aws_region}:")
        for env_id in environments.get("environmentIds", []):
            print(f"- {env_id}")
    except Exception as e:
        print(f"Error listing environments: {e}")

# To run with mypy:
# save as cloud9_example.py
# mypy cloud9_example.py

view raw JSON →