{"id":3069,"library":"mypy-boto3-datasync","title":"mypy-boto3-datasync Type Stubs","description":"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.","status":"active","version":"1.42.85","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","type-stubs","datasync","typing"],"install":[{"cmd":"pip install mypy-boto3-datasync","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install boto3-stubs[datasync]","lang":"bash","label":"Install as part of boto3-stubs (recommended)"}],"dependencies":[{"reason":"Provides the runtime client for which these are stubs.","package":"boto3"},{"reason":"The static type checker that utilizes these stubs.","package":"mypy","optional":true},{"reason":"Used for compatibility with some advanced type features across Python versions.","package":"typing-extensions","optional":true}],"imports":[{"note":"Client types are nested under the `.client` module.","wrong":"from mypy_boto3_datasync import DataSyncClient","symbol":"DataSyncClient","correct":"from mypy_boto3_datasync.client import DataSyncClient"},{"note":"Service-specific TypedDicts (request/response schemas) are in `.type_defs`.","wrong":"from mypy_boto3_datasync.client import ListTasksResponseTypeDef","symbol":"ListTasksResponseTypeDef","correct":"from mypy_boto3_datasync.type_defs import ListTasksResponseTypeDef"},{"note":"Paginator types are available in the `.paginator` module.","symbol":"ListTasksPaginator","correct":"from mypy_boto3_datasync.paginator import ListTasksPaginator"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_datasync.client import DataSyncClient\nfrom mypy_boto3_datasync.type_defs import ListTasksResponseTypeDef\n\n# Initialize a boto3 client with type hinting\n# (Mypy may warn without # type: ignore, but it's correct for runtime use)\nclient: DataSyncClient = boto3.client(\"datasync\", region_name=\"us-east-1\")\n\ntry:\n    # Use the client with type-safe operations\n    response: ListTasksResponseTypeDef = client.list_tasks(MaxResults=5)\n    print(f\"Found {len(response.get('TaskList', []))} DataSync tasks.\")\n    for task in response.get('TaskList', []):\n        print(f\"  Task ARN: {task.get('TaskArn')}, Name: {task.get('Name')}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION environment variables or ~/.aws/credentials).\")\n","lang":"python","description":"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`."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. For Python 3.8, use `mypy-boto3` versions <8.12.0.","message":"Python 3.8 support has been removed. All `mypy-boto3` packages now require Python 3.9 or newer.","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Update your type import statements to reflect the new `TypeDef` names. Consult the generated stubs for the exact names if `mypy` reports an error.","message":"Some generated `TypeDef` names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting `TypeDef` postfixes were reordered. This can cause `mypy` errors if you explicitly imported these types.","severity":"breaking","affected_versions":">=8.9.0"},{"fix":"Ensure `mypy` is up-to-date. If issues persist, verify `mypy`'s `MYPYPATH` or `pyproject.toml` settings are not conflicting with standard package discovery.","message":"All `mypy-boto3` packages, including `mypy-boto3-datasync`, migrated to PEP 561-compliant packages. While this improves standard stub discovery, older `mypy` configurations or custom stub paths might need adjustment to correctly locate the stubs.","severity":"gotcha","affected_versions":">=8.12.0"},{"fix":"Understand that `mypy-boto3` is a development-time tool. Ensure robust error handling and validation for production `boto3` code.","message":"These packages provide type hints for static analysis only. They do not modify `boto3`'s runtime behavior or add any runtime type checking. Any runtime errors will still occur as per `boto3`'s behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}