Type Annotations for boto3 SimSpace Weaver

1.42.3 · active · verified Sat Apr 11

mypy-boto3-simspaceweaver provides static type annotations for the `boto3` SimSpace Weaver service. It enhances development with `boto3` by offering compile-time type checking, auto-completion, and error detection in IDEs. The library is part of the `mypy-boto3-builder` ecosystem, which follows a frequent release cadence, often aligning with `boto3` updates. The current version, `1.42.3`, corresponds to the `boto3` version it provides stubs for.

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize a `boto3` client with type hints from `mypy-boto3-simspaceweaver` and use specific TypeDefs for input payloads. This enables advanced static analysis and autocompletion without altering runtime behavior.

import boto3
from mypy_boto3_simspaceweaver.client import SimSpaceWeaverClient
from mypy_boto3_simspaceweaver.type_defs import CreateSpaceInputRequestTypeDef

# mypy-boto3-simspaceweaver provides type hints for the boto3 SimSpaceWeaver client.
# It does not need to be imported directly for runtime functionality;
# simply installing it adds type information to your boto3 usage.

# Step 1: Initialize a boto3 client with type hints
# This enables IDE autocompletion and static type checking for SimSpaceWeaver operations.
client: SimSpaceWeaverClient = boto3.client("simspaceweaver")

# Step 2: Use the client (ensure you have AWS credentials configured, e.g., via ~/.aws/credentials)
try:
    # Example: List existing SimSpace Weaver spaces
    response = client.list_spaces(MaxResults=5)
    print("Successfully listed SimSpace Weaver spaces:")
    for space in response.get("Spaces", []):
        print(f"- {space.get('Name')} (Status: {space.get('Status')})")
except Exception as e:
    print(f"Could not list spaces. Ensure AWS credentials are configured. Error: {e}")

# Step 3: Use specific TypeDefs for request/response objects for stricter type checking
# This demonstrates type safety for a hypothetical request payload, without making an actual call.
hypothetical_create_space_request: CreateSpaceInputRequestTypeDef = {
    "Name": "MyTestSimSpace",
    "RoleArn": "arn:aws:iam::123456789012:role/SimSpaceWeaverRole", # Replace with a valid ARN if performing actual calls
    "Description": "A simulated space for testing.",
    "MaximumDuration": 3600,
    "Tags": {"Project": "MyProject"}
}
print("\nDemonstrating TypeDef for CreateSpaceInputRequestTypeDef:")
print(f"  Name: {hypothetical_create_space_request['Name']}")
print(f"  RoleArn: {hypothetical_create_space_request['RoleArn']}")

# With mypy-boto3-simspaceweaver installed, a type checker (like mypy) would
# flag issues if 'Name' or 'RoleArn' were missing or had incorrect types.

view raw JSON →