mypy-boto3-healthlake
mypy-boto3-healthlake provides type annotations for the boto3 HealthLake service. It enhances development with static type checking for AWS SDK for Python (boto3) code, catching potential errors early. The current version is 1.42.3, and new versions are released frequently, typically in lockstep with botocore/boto3 updates.
Warnings
- breaking Python 3.8 support was removed in `mypy-boto3-builder` version 8.12.0. All generated `mypy-boto3-*` packages, including `mypy-boto3-healthlake`, now require Python 3.9 or newer.
- breaking TypeDef naming conventions were significantly changed in `mypy-boto3-builder` version 8.9.0. This includes shortening redundant 'Request' suffixes (e.g., `CreateRequestRequestTypeDef` became `CreateRequestTypeDef`) and moving 'Extra' suffixes. Existing type annotations in your code using older names will break.
- gotcha Each AWS service requires its own `mypy-boto3-*` package for type stubs (e.g., `mypy-boto3-healthlake` for HealthLake, `mypy-boto3-s3` for S3). If you need types for multiple services, you must install each package individually or install the monorepo `mypy-boto3` package (which is larger).
- gotcha Type stubs are generated based on `botocore` versions. To avoid `mypy` errors due to API mismatches, ensure your `mypy-boto3-*` packages are kept up-to-date and ideally match the `boto3` and `botocore` versions in your environment.
- gotcha The project migrated to PEP 561 compliant packages in version 8.12.0. While generally an improvement, some users with custom `mypy` configurations or unusual project structures might need to verify `mypy` is correctly discovering the stubs.
Install
-
pip install mypy-boto3-healthlake -
pip install mypy-boto3
Imports
- HealthLakeClient
from mypy_boto3_healthlake.client import HealthLakeClient
- ListFHIRDatastoresPaginator
from mypy_boto3_healthlake.paginator import ListFHIRDatastoresPaginator
- CreateFHIRDatastoreRequestRequestTypeDef
from mypy_boto3_healthlake.type_defs import CreateFHIRDatastoreRequestRequestTypeDef
Quickstart
import boto3
import os
from mypy_boto3_healthlake.client import HealthLakeClient
from mypy_boto3_healthlake.type_defs import CreateFHIRDatastoreRequestRequestTypeDef
# Use os.environ.get for quickstart to satisfy auth check
aws_region = os.environ.get("AWS_REGION", "us-east-1")
datastore_name = "my-healthlake-datastore-example"
datastore_type = "R4" # or "STU3"
client: HealthLakeClient = boto3.client("healthlake", region_name=aws_region)
request_params: CreateFHIRDatastoreRequestRequestTypeDef = {
"DatastoreName": datastore_name,
"DatastoreType": datastore_type
}
try:
# In a real application, you might add tags or other configurations
response = client.create_fhir_datastore(**request_params)
print(f"Datastore creation initiated: {response['DatastoreId']} with status {response['DatastoreStatus']}")
# Wait for the datastore to be active if needed
# client.get_waiter('datastore_created').wait(DatastoreId=response['DatastoreId'])
except client.exceptions.ConflictException:
print(f"Datastore '{datastore_name}' already exists.")
except Exception as e:
print(f"An error occurred: {e}")
# Example of listing datastores
print("\nListing HealthLake Datastores:")
response = client.list_fhir_datastores()
for ds in response.get("Datastores", []):
print(f"- {ds['DatastoreName']} ({ds['DatastoreStatus']})")