mypy-boto3-dataexchange

1.42.80 · active · verified Fri Apr 10

mypy-boto3-dataexchange provides type annotations for the `boto3` AWS DataExchange service. It is part of the `types-boto3` family of packages, generated by `mypy-boto3-builder`, offering enhanced type checking and IDE auto-completion for `boto3` clients and resources. The library versions are synchronized with the corresponding `boto3` service versions, ensuring up-to-date type information.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted DataExchange client using `mypy-boto3-dataexchange` and perform a basic operation like listing data sets. The `TYPE_CHECKING` block ensures that the type stub is only imported during type-checking, avoiding runtime dependencies. Remember to configure your AWS credentials.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_dataexchange.client import DataExchangeClient

# Ensure AWS credentials are set up (e.g., via environment variables, ~/.aws/credentials)
# For example, export AWS_ACCESS_KEY_ID='YOUR_ACCESS_KEY_ID'
# export AWS_SECRET_ACCESS_KEY='YOUR_SECRET_ACCESS_KEY'
# export AWS_DEFAULT_REGION='us-east-1'

def get_dataexchange_client() -> DataExchangeClient:
    """Returns a type-hinted DataExchange client."""
    client: DataExchangeClient = boto3.client("dataexchange")
    return client

if __name__ == "__main__":
    dataexchange_client = get_dataexchange_client()
    print(f"Client type: {type(dataexchange_client)}")
    try:
        # Example: List your Data Exchange data sets
        response = dataexchange_client.list_data_sets()
        print(f"Successfully listed {len(response.get('DataSets', []))} data sets.")
        # Accessing typed attributes will be auto-completed and type-checked
        for dataset in response.get('DataSets', []):
            print(f"  - DataSetId: {dataset.get('DataSetId')}, Name: {dataset.get('Name')}")
    except Exception as e:
        print(f"Error listing data sets: {e}")

view raw JSON →