mypy-boto3-iotsitewise Type Stubs
mypy-boto3-iotsitewise provides PEP 561 compliant type annotations for the AWS boto3 IoTSiteWise service, generated by the mypy-boto3-builder. It enhances type checking for `boto3.client('iotsitewise')` calls, enabling robust static analysis with tools like mypy and pyright, and improving IDE auto-completion. This library is actively maintained, with versions closely synchronized with upstream boto3 releases.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 or older must upgrade to Python 3.9+ to use packages generated by this builder (including `mypy-boto3-iotsitewise` versions built with 8.12.0+).
- breaking The `mypy-boto3-builder` migrated to PEP 561 compliant package structure in version 8.12.0. This change might affect how some build systems or older type checkers locate or process the stub packages.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Specifically, redundant 'Request' suffixes were removed (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and 'Extra' postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). While the example refers to `Distribution`, this is a general change that may affect explicit references to generated TypeDefs for IoTSiteWise.
- gotcha The `mypy-boto3` ecosystem offers both standalone service packages (e.g., `mypy-boto3-iotsitewise`) and a consolidated `boto3-stubs` package with service-specific extras (e.g., `boto3-stubs[iotsitewise]`). Installing both for the same service can lead to conflicts or larger-than-necessary dependency graphs. Choose one method.
- gotcha If using `boto3-stubs-lite` (a more RAM-friendly variant), explicit type annotations for `session.client` and `session.resource` calls are *required* because it does not provide overloads for auto-discovery, unlike the full `boto3-stubs` or `mypy-boto3-` standalone packages.
Install
-
pip install mypy-boto3-iotsitewise -
pip install 'boto3-stubs[iotsitewise]'
Imports
- IoTSiteWiseClient
from mypy_boto3_iotsitewise.client import IoTSiteWiseClient import boto3 client: IoTSiteWiseClient = boto3.client("iotsitewise")
Quickstart
import boto3
from mypy_boto3_iotsitewise.client import IoTSiteWiseClient
def get_iotsitewise_client() -> IoTSiteWiseClient:
"""Get a type-hinted AWS IoT SiteWise client."""
# Ensure AWS credentials are set up (e.g., via environment variables or ~/.aws/credentials)
client: IoTSiteWiseClient = boto3.client(
"iotsitewise",
region_name="us-east-1", # Replace with your desired region
aws_access_key_id='YOUR_ACCESS_KEY' or os.environ.get('AWS_ACCESS_KEY_ID', ''),
aws_secret_access_key='YOUR_SECRET_KEY' or os.environ.get('AWS_SECRET_ACCESS_KEY', ''),
aws_session_token='YOUR_SESSION_TOKEN' or os.environ.get('AWS_SESSION_TOKEN', '')
)
return client
if __name__ == "__main__":
# Example usage: list assets (requires appropriate permissions)
try:
iotsitewise_client = get_iotsitewise_client()
response = iotsitewise_client.list_assets(maxResults=5)
print("Successfully retrieved IoT SiteWise assets:")
for asset in response.get("assetSummaries", []):
print(f" - {asset['name']} (ID: {asset['id']})")
except Exception as e:
print(f"Error interacting with IoT SiteWise: {e}")