mypy-boto3-lakeformation Type Annotations for AWS LakeFormation

1.42.79 · active · verified Fri Apr 10

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` LakeFormation client with explicit type annotations and interact with it. It fetches the Data Lake settings and attempts to print the first Data Lake admin, leveraging `mypy-boto3-lakeformation`'s type definitions for enhanced code completion and error checking.

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}")

view raw JSON →