mypy-boto3-datasync Type Stubs

1.42.85 · active · verified Sat Apr 11

mypy-boto3-datasync provides type annotations for `boto3`'s DataSync service client, enhancing static analysis with tools like MyPy. It ensures type safety for `boto3` calls, improving developer experience and catching potential errors pre-runtime. The library closely tracks `boto3` and AWS API releases, leading to frequent updates, currently at version 1.42.85.

Warnings

Install

Imports

Quickstart

This example demonstrates how to import and apply type hints for the DataSync client and its response types. It initializes a `boto3` client and uses `mypy-boto3-datasync` stubs to enable static analysis for operations like `list_tasks`.

import boto3
from mypy_boto3_datasync.client import DataSyncClient
from mypy_boto3_datasync.type_defs import ListTasksResponseTypeDef

# Initialize a boto3 client with type hinting
# (Mypy may warn without # type: ignore, but it's correct for runtime use)
client: DataSyncClient = boto3.client("datasync", region_name="us-east-1")

try:
    # Use the client with type-safe operations
    response: ListTasksResponseTypeDef = client.list_tasks(MaxResults=5)
    print(f"Found {len(response.get('TaskList', []))} DataSync tasks.")
    for task in response.get('TaskList', []):
        print(f"  Task ARN: {task.get('TaskArn')}, Name: {task.get('Name')}")
except Exception as e:
    print(f"An error occurred: {e}")
    print("Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION environment variables or ~/.aws/credentials).")

view raw JSON →