Type Annotations for boto3 SimSpace Weaver
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
- breaking Python 3.8 support was removed, and packages migrated to PEP 561. This affects all generated `mypy-boto3` stubs.
- breaking TypeDef names for method arguments (e.g., `CreateDistributionRequestRequestTypeDef`) were shortened or had `Extra` postfixes moved. This change can break explicit type hint references in existing code.
- gotcha This package provides only type stubs and is not intended for runtime import or direct use. Its purpose is to enhance `boto3`'s static analysis capabilities.
- gotcha The version of `mypy-boto3-simspaceweaver` is designed to align with the `boto3` version it provides stubs for. Mismatching versions can lead to incorrect or missing type hints.
Install
-
pip install mypy-boto3-simspaceweaver
Imports
- SimSpaceWeaverClient
from mypy_boto3_simspaceweaver.client import SimSpaceWeaverClient
- CreateSpaceInputRequestTypeDef
from mypy_boto3_simspaceweaver.type_defs import CreateSpaceInputRequestTypeDef
Quickstart
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.