mypy-boto3-iottwinmaker Type Annotations

1.42.3 · active · verified Sat Apr 11

mypy-boto3-iottwinmaker provides high-quality type annotations for the `boto3` AWS IoTTwinMaker service client. It ensures static type checking with tools like MyPy, helping developers catch errors early and improve code readability for AWS API interactions. The current version is 1.42.3, and it's updated frequently to align with new `boto3` releases and `mypy-boto3-builder` improvements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted IoTTwinMaker client and use it to list workspaces. It leverages the `IoTTwinMakerClient` type from `mypy-boto3-iottwinmaker` for improved type checking.

import boto3
import os
from mypy_boto3_iottwinmaker import IoTTwinMakerClient
from mypy_boto3_iottwinmaker.type_defs import ListWorkspacesResponseTypeDef

# Initialize the IoTTwinMaker client with type annotations
client: IoTTwinMakerClient = boto3.client("iottwinmaker")

print("Listing IoTTwinMaker workspaces:")
try:
    # Use the client with type-checked methods and type definitions
    response: ListWorkspacesResponseTypeDef = client.list_workspaces()
    workspaces = response.get("workspaceSummaries", [])
    if workspaces:
        for ws in workspaces:
            print(f"- {ws.get('workspaceId')} (Status: {ws.get('status', {}).get('state')})")
    else:
        print("No IoTTwinMaker workspaces found in this AWS account/region.")
except Exception as e:
    print(f"An error occurred while listing workspaces: {e}")
    print("Please ensure you have configured AWS credentials and the IoTTwinMaker service is available in your region.")

view raw JSON →