mypy-boto3-dataexchange
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
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0. Projects using `mypy-boto3-dataexchange` (and other `mypy-boto3` packages) must use Python 3.9 or newer.
- breaking Version 8.9.0 of `mypy-boto3-builder` introduced breaking changes in TypeDef naming conventions. Specifically, TypeDefs for packed method arguments use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). This impacts explicit type annotations.
- gotcha PyCharm users might experience slow performance or high CPU usage due to literal overloads. It is recommended to use `boto3-stubs-lite` packages or disable PyCharm's internal type checker and rely on `mypy` or `pyright` instead.
- gotcha When using `TYPE_CHECKING` for conditional imports with `pylint`, it may complain about undefined variables in the runtime block. To avoid this, set types to `object` in the `else` branch of the `TYPE_CHECKING` block.
Install
-
pip install mypy-boto3-dataexchange boto3
Imports
- DataExchangeClient
from mypy_boto3_dataexchange.client import DataExchangeClient
Quickstart
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}")