mypy-boto3-databrew Type Stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-databrew provides comprehensive type annotations for the AWS GlueDataBrew service, enhancing developer experience with static type checking and IDE auto-completion for boto3. It is part of the `mypy-boto3-builder` ecosystem, which generates stubs for all AWS services. The library is actively maintained with frequent updates to align with boto3 releases and new AWS service features, typically on a monthly cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-databrew` to add type hints to your boto3 GlueDataBrew client. It explicitly imports the `GlueDataBrewClient` type and a sample response `TypedDict` for improved type checking and auto-completion. The example initializes a DataBrew client and lists recipes, showcasing how type annotations benefit method calls and return values.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_databrew.client import GlueDataBrewClient
    from mypy_boto3_databrew.type_defs import ListRecipesResponseTypeDef

def get_databrew_recipes() -> ListRecipesResponseTypeDef:
    # Initialize the DataBrew client with type annotation
    client: GlueDataBrewClient = boto3.client("databrew")
    
    # Use the client with type-hinted methods and expected return types
    response: ListRecipesResponseTypeDef = client.list_recipes(MaxResults=5)
    print(f"Found {len(response['Recipes'])} DataBrew recipes.")
    for recipe in response.get('Recipes', []):
        print(f"- {recipe['Name']} (ARN: {recipe['Arn']})")
    return response

if __name__ == "__main__":
    # Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
    # For a runnable example without actual AWS calls, you might mock boto3 or use a dummy client.
    # This example assumes valid AWS credentials are set up.
    print("Listing DataBrew recipes...")
    try:
        get_databrew_recipes()
    except Exception as e:
        print(f"Error fetching DataBrew recipes: {e}")
        print("Please ensure AWS credentials and region are configured correctly.")

view raw JSON →