mypy-boto3-pipes Type Annotations

1.42.3 · active · verified Sat Apr 11

mypy-boto3-pipes provides type annotations for the `boto3` EventBridgePipes service, ensuring compatibility with type checkers like Mypy, Pyright, and various IDEs. It is part of the `mypy-boto3` family of projects, generated by `mypy-boto3-builder`, and its version aligns with the corresponding `boto3` version. The library is actively maintained with frequent updates following `boto3` releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` client for EventBridge Pipes with type hints from `mypy-boto3-pipes` and perform a simple `list_pipes` operation. The `TYPE_CHECKING` block ensures that `mypy-boto3-pipes` is only a development dependency.

import boto3
import os
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_pipes.client import PipesClient
    from mypy_boto3_pipes.type_defs import ListPipesResponseTypeDef

# Ensure boto3 is configured, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION
# For this example, we'll just create a client.
# In a real application, ensure credentials are set up (e.g., via environment variables or ~/.aws/credentials)

def get_pipes_client() -> 'PipesClient':
    # The explicit type annotation here (PipesClient) enables type checking and autocompletion
    client: PipesClient = boto3.client(
        "pipes",
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
        region_name=os.environ.get('AWS_REGION', 'us-east-1')
    )
    return client

def list_eventbridge_pipes():
    pipes_client = get_pipes_client()
    try:
        response: ListPipesResponseTypeDef = pipes_client.list_pipes(
            MaxResults=5
        )
        print("Successfully listed pipes:")
        for pipe in response.get('Pipes', []):
            print(f"  Pipe Name: {pipe.get('Name')}, State: {pipe.get('State')}")
    except Exception as e:
        print(f"Error listing pipes: {e}")

if __name__ == "__main__":
    list_eventbridge_pipes()

view raw JSON →