mypy-boto3-datapipeline Type Stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-datapipeline provides static type annotations for the `boto3` DataPipeline service, generated by `mypy-boto3-builder`. It enhances development with type-checking capabilities for `boto3` clients, resources, and waiters, without altering runtime behavior. The current version is 1.42.3, and releases are frequent, typically mirroring new `boto3` versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` DataPipeline client and leverage `mypy-boto3-datapipeline` type stubs for static analysis. It shows the common pattern of obtaining a client via `boto3.client` and how to use `TYPE_CHECKING` for explicit type hints without runtime impact. Ensure both `boto3` and `mypy-boto3-datapipeline` are installed for this example to run and be type-checked.

import boto3
from typing import TYPE_CHECKING

# Ensure both boto3 and mypy-boto3-datapipeline are installed:
# pip install boto3 mypy-boto3-datapipeline

if TYPE_CHECKING:
    # Import the client type for explicit type hints within type-checking blocks
    from mypy_boto3_datapipeline.client import DataPipelineClient

# Obtain a DataPipeline client. Mypy will use the installed stubs for type checking.
datapipeline_client: DataPipelineClient = boto3.client("datapipeline")

print("Attempting to list DataPipeline pipelines:")
try:
    response = datapipeline_client.list_pipelines()
    pipelines = response.get("pipelineIdList", [])
    if pipelines:
        print(f"Found {len(pipelines)} pipelines:")
        for pipeline_info in pipelines:
            # Type checkers will enforce that 'id' and 'name' exist and are strings
            print(f"- ID: {pipeline_info['id']}, Name: {pipeline_info['name']}")
    else:
        print("No DataPipeline pipelines found in this AWS account/region.")
except datapipeline_client.exceptions.ClientError as e:
    print(f"AWS Client Error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

# Mypy will now correctly check types for datapipeline_client methods.
# For example, calling a non-existent method like 'datapipeline_client.non_existent_method()'
# would raise a Mypy error during static analysis.

view raw JSON →