mypy-boto3-iottwinmaker Type Annotations
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
- breaking Python 3.8 support has been removed for all `mypy-boto3-*` packages generated by `mypy-boto3-builder` version 8.12.0 and later. If you are using Python 3.8, you must pin to an older version of `mypy-boto3-iottwinmaker`.
- gotcha For optimal type checking, your `mypy-boto3-iottwinmaker` package version should closely match your `boto3` runtime version (specifically, the minor version, e.g., `boto3==1.42.x` with `mypy-boto3-iottwinmaker==1.42.y`). Significant mismatches can lead to incorrect or missing type hints.
- gotcha While `mypy-boto3-iottwinmaker` provides stubs for a specific service, the recommended approach for complete `boto3` stubs is to install `boto3-stubs` with service extras (e.g., `pip install boto3-stubs[iottwinmaker]`). Installing both `boto3-stubs` and individual `mypy-boto3-*` packages can lead to conflicts or redundant stubs.
- breaking Type definition names for packed method arguments were shortened and conflicting `Extra` postfixes were moved to the end. For example, `CreateDistributionRequestRequestTypeDef` might become `CreateDistributionRequestTypeDef`. This affects code that explicitly imports and uses these `TypeDef`s.
Install
-
pip install mypy-boto3-iottwinmaker -
pip install boto3-stubs[iottwinmaker]
Imports
- IoTTwinMakerClient
from mypy_boto3_iottwinmaker import IoTTwinMakerClient
- CreateWorkspaceRequestRequestTypeDef
from mypy_boto3_iottwinmaker.type_defs import CreateWorkspaceRequestRequestTypeDef
Quickstart
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.")