mypy-boto3-lakeformation Type Annotations for AWS LakeFormation
mypy-boto3-lakeformation provides comprehensive type annotations for the AWS LakeFormation service, enhancing static type checking for `boto3` interactions. It ensures compatibility with tools like mypy, pyright, VSCode, and PyCharm by offering type definitions for clients, paginators, literals, and TypeDefs. Currently at version 1.42.79, it is actively maintained with frequent updates, often aligning with new `boto3` releases and driven by the `mypy-boto3-builder` project (version 8.12.0).
Warnings
- breaking Starting with `mypy-boto3-builder` 8.12.0 (and corresponding `mypy-boto3-*` releases like 1.42.79 for LakeFormation), Python 3.8 is no longer supported. Projects must use Python 3.9 or newer.
- gotcha `mypy-boto3-lakeformation` provides only type annotations (`.pyi` stub files). You must also install the `boto3` library itself for your code to run. These stubs do not provide `boto3`'s runtime functionality.
- gotcha For optimal and accurate type checking, the version of `mypy-boto3-lakeformation` should ideally match the major and minor version of your installed `boto3` library. Mismatched versions can lead to incorrect type hints or unresolved references.
- breaking The `mypy-boto3-builder` (which generates this package) introduced breaking changes to `TypeDef` naming conventions in version 8.9.0. If you explicitly imported TypeDefs with older, longer names (e.g., `CreateDistributionRequestRequestTypeDef`), they might have been shortened (e.g., to `CreateDistributionRequestTypeDef`).
Install
-
pip install mypy-boto3-lakeformation -
pip install 'boto3-stubs[lakeformation]'
Imports
- LakeFormationClient
from mypy_boto3_lakeformation.client import LakeFormationClient
- GetDataLakeSettingsResponseTypeDef
from mypy_boto3_lakeformation.type_defs import GetDataLakeSettingsResponseTypeDef
- PrincipalPermissionsTypeDef
from mypy_boto3_lakeformation.type_defs import PrincipalPermissionsTypeDef
Quickstart
import boto3
from mypy_boto3_lakeformation.client import LakeFormationClient
from mypy_boto3_lakeformation.type_defs import (
GetDataLakeSettingsResponseTypeDef,
PrincipalPermissionsTypeDef
)
# Initialize boto3 client with explicit type annotation for static checking
# Make sure to have AWS credentials configured (e.g., via environment variables or ~/.aws/credentials)
client: LakeFormationClient = boto3.client("lakeformation", region_name="us-east-1")
try:
# Example: Get Data Lake Settings
response: GetDataLakeSettingsResponseTypeDef = client.get_data_lake_settings()
print("Successfully retrieved Data Lake Settings:")
# Accessing type-hinted response data
if "DataLakeSettings" in response:
settings = response["DataLakeSettings"]
if "DataLakeAdmins" in settings and settings["DataLakeAdmins"]:
admin: PrincipalPermissionsTypeDef = settings["DataLakeAdmins"][0]
print(f" First Data Lake Admin Principal: {admin['DataPrincipalIdentifier']}")
else:
print(" No Data Lake Admins found.")
else:
print(" 'DataLakeSettings' key not found in response.")
except Exception as e:
print(f"An error occurred: {e}")