mypy-boto3-finspace Type Annotations
mypy-boto3-finspace provides type annotations (type stubs) for the boto3 Finspace service, enabling static type checking with tools like MyPy. It ensures your boto3 code interacting with AWS Finspace is type-safe. The current version is 1.42.3, which aligns with a specific boto3 version, and updates are released regularly in sync with new boto3 releases and the underlying mypy-boto3-builder.
Warnings
- breaking Python 3.8 is no longer supported. Packages generated by `mypy-boto3-builder` version 8.12.0 and later, including `mypy-boto3-finspace` 1.42.3, require Python 3.9 or higher.
- gotcha This library provides type *stubs* for boto3, not the boto3 library itself. You must install `boto3` separately for your code to run.
- breaking Many generated TypeDef names were shortened by `mypy-boto3-builder` (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This can break explicit references to these types.
- gotcha The version of `mypy-boto3-finspace` (e.g., `1.42.3`) is primarily tied to the `boto3` version that defines the Finspace service client, not the `mypy-boto3-builder`'s semantic versioning. This can lead to confusion when tracking updates.
Install
-
pip install mypy-boto3-finspace
Imports
- FinspaceClient
from mypy_boto3_finspace.client import FinspaceClient
- ListEnvironmentsRequestRequestTypeDef
from mypy_boto3_finspace.type_defs import ListEnvironmentsRequestRequestTypeDef
Quickstart
import boto3
import os
from typing import TYPE_CHECKING
# Only import type stubs when type checking
if TYPE_CHECKING:
from mypy_boto3_finspace.client import FinspaceClient
from mypy_boto3_finspace.type_defs import ListEnvironmentsResponseTypeDef
# Create a boto3 client (runtime object)
client = boto3.client(
"finspace",
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
region_name=os.environ.get('AWS_REGION', 'us-east-1')
)
# Type hint the client for static analysis (optional at runtime, crucial for mypy)
if TYPE_CHECKING:
finspace_client: FinspaceClient = client
else:
finspace_client = client
try:
# Use the client with type-checked arguments and return types
response: ListEnvironmentsResponseTypeDef = finspace_client.list_environments()
print("Finspace Environments:")
for env in response.get('environments', []):
print(f" - {env.get('name')} ({env.get('status')})")
except Exception as e:
print(f"Error listing Finspace environments: {e}")