mypy-boto3-cloud9 Type Annotations
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
- breaking Support for Python 3.8 was officially removed starting with `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will need to upgrade their Python version to 3.9 or newer.
- breaking TypeDef naming conventions were changed in `mypy-boto3-builder` version 8.9.0. This might lead to breaking changes for explicit `TypeDef` imports, where names like `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`.
- gotcha The `mypy-boto3` ecosystem migrated to PEP 561 compliant packages in `mypy-boto3-builder` version 8.12.0. While this generally improves compatibility, ensure your tooling (e.g., `setuptools`, `pip`) is up-to-date to correctly recognize and utilize these new package structures.
- gotcha While `mypy-boto3-cloud9` provides standalone stubs, for comprehensive type-hinting of `boto3.client` and `boto3.resource` calls, using the `boto3-stubs` meta-package (e.g., `pip install 'boto3-stubs[cloud9]'`) is often recommended. Standalone packages might require more explicit type annotations for `boto3.client` return values.
- gotcha AWS services can be renamed or deprecated, leading to corresponding changes in `mypy-boto3` packages. For example, `sms-voice` was excluded in `mypy-boto3-builder` 8.11.0, recommending `pinpoint-sms-voice` instead. Always check release notes if a service package seems to be missing or misbehaving.
Install
-
pip install mypy-boto3-cloud9 boto3 mypy -
pip install 'boto3-stubs[cloud9]' boto3 mypy
Imports
- Cloud9Client
from mypy_boto3_cloud9.client import Cloud9Client
- ListEnvironmentsResultTypeDef
from mypy_boto3_cloud9.type_defs import ListEnvironmentsResultTypeDef
- Cloud9ServiceName
from mypy_boto3_cloud9.literals import Cloud9ServiceName
Quickstart
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