Type annotations for boto3 Glue

1.42.70 · active · verified Thu Apr 09

mypy-boto3-glue provides comprehensive type annotations for the AWS boto3 Glue client, enabling static type checking with tools like MyPy, Pyright, and enhanced IDE auto-completion. It is automatically generated by mypy-boto3-builder and currently aligns with boto3 version 1.42.70, with frequent updates following new boto3 releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `GlueClient` using `mypy-boto3-glue`. It leverages the `TYPE_CHECKING` guard to prevent runtime dependency on the stub package, a common practice for production environments. The primary benefit is improved auto-completion and static analysis for Glue service calls.

import boto3
from typing import TYPE_CHECKING
from mypy_boto3_glue.client import GlueClient

# Ensure boto3 is configured, e.g., via AWS environment variables or ~/.aws/credentials
# client = boto3.client('glue') # Inferred type in modern IDEs/mypy

def get_typed_glue_client() -> GlueClient:
    """Returns a type-hinted Glue client."""
    return boto3.client('glue')

if TYPE_CHECKING:
    # Example usage with type checking
    glue_client: GlueClient = get_typed_glue_client()
    response = glue_client.list_crawlers(MaxResults=10)
    for crawler in response.get('Crawlers', []):
        print(f"Crawler Name: {crawler.get('Name')}")

print("Glue client configured. Run type checker (e.g., mypy) for full benefits.")

view raw JSON →