mypy-boto3-transfer
mypy-boto3-transfer provides type annotations for the `boto3` Transfer service, generated with `mypy-boto3-builder`. It ensures `mypy` can correctly validate usage of the `boto3` Transfer client and associated data types. The library is actively maintained, with releases typically synchronized with `boto3` updates and `mypy-boto3-builder` enhancements, currently at version 1.42.84.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will need to upgrade to Python 3.9 or newer to use the latest `mypy-boto3-transfer` stubs.
- gotcha `mypy-boto3-transfer` provides type stubs only. You must also install the actual `boto3` library (`pip install boto3`) for your code to run at runtime. Without `boto3`, your application will encounter runtime import errors.
- breaking `mypy-boto3-builder` version 8.9.0 introduced breaking changes to `TypeDef` naming conventions (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). If you directly imported specific `TypeDef` classes by their full names, these imports may break.
- breaking `mypy-boto3-builder` version 8.12.0 migrated all packages, including `mypy-boto3-transfer`, to be PEP 561 compliant. While this improves standard type-checking workflows, custom build systems or specific tooling that relied on previous package structures might need adjustments.
Install
-
pip install mypy-boto3-transfer -
pip install boto3
Imports
- TransferClient
from mypy_boto3_transfer.client import TransferClient
- ListServersResponseTypeDef
from mypy_boto3_transfer.type_defs import ListServersResponseTypeDef
Quickstart
import boto3
from mypy_boto3_transfer.client import TransferClient
from mypy_boto3_transfer.type_defs import ListServersResponseTypeDef
from typing import TYPE_CHECKING
if TYPE_CHECKING:
# These imports are for type checking only and will not be executed at runtime
# They provide type hints for boto3 service clients and responses.
client: TransferClient = boto3.client("transfer")
response: ListServersResponseTypeDef = client.list_servers()
print(f"Found {len(response['Servers'])} Transfer servers.")
# Example of actual runtime usage (uncomment to run)
# client = boto3.client("transfer")
# response = client.list_servers()
# print(f"Runtime: Found {len(response['Servers'])} Transfer servers.")