Skip to content

Examples#

Index > Transfer > Examples

Auto-generated documentation for Transfer type annotations stubs module mypy-boto3-transfer.

Client#

Implicit type annotations#

Can be used with boto3-stubs[transfer] package installed.

Write your Transfer code as usual, type checking and code completion should work out of the box.

Client method usage example#

# TransferClient usage example

from boto3.session import Session


session = Session()

client = session.client("transfer")  # (1)
result = client.create_access()  # (2)
  1. client: TransferClient
  2. result: CreateAccessResponseTypeDef

Paginator usage example#

# ListAccessesPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("transfer")  # (1)

paginator = client.get_paginator("list_accesses")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: TransferClient
  2. paginator: ListAccessesPaginator
  3. item: ListAccessesResponseTypeDef

Waiter usage example#

# ServerOfflineWaiter usage example

from boto3.session import Session


session = Session()
client = session.client("transfer")  # (1)

waiter = client.get_waiter("server_offline")  # (2)
waiter.wait(...)
  1. client: TransferClient
  2. waiter: ServerOfflineWaiter

Explicit type annotations#

With boto3-stubs-lite[transfer] or a standalone mypy_boto3_transfer package, you have to explicitly specify client: TransferClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

Client method usage example#

# TransferClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_transfer.client import TransferClient
from mypy_boto3_transfer.type_defs import CreateAccessResponseTypeDef
from mypy_boto3_transfer.type_defs import CreateAccessRequestTypeDef


session = Session()

client: TransferClient = session.client("transfer")

kwargs: CreateAccessRequestTypeDef = {...}
result: CreateAccessResponseTypeDef = client.create_access(**kwargs)

Paginator usage example#

# ListAccessesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_transfer.client import TransferClient
from mypy_boto3_transfer.paginator import ListAccessesPaginator
from mypy_boto3_transfer.type_defs import ListAccessesResponseTypeDef


session = Session()
client: TransferClient = session.client("transfer")

paginator: ListAccessesPaginator = client.get_paginator("list_accesses")
for item in paginator.paginate(...):
    item: ListAccessesResponseTypeDef
    print(item)

Waiter usage example#

# ServerOfflineWaiter usage example with type annotations

from boto3.session import Session

from mypy_boto3_transfer.client import TransferClient
from mypy_boto3_transfer.waiter import ServerOfflineWaiter

session = Session()
client: TransferClient = session.client("transfer")

waiter: ServerOfflineWaiter = client.get_waiter("server_offline")
waiter.wait(...)