Skip to content

Examples#

Index > DataExchange > Examples

Auto-generated documentation for DataExchange type annotations stubs module mypy-boto3-dataexchange.

Client#

Implicit type annotations#

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

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

# DataExchangeClient usage example

from boto3.session import Session


session = Session()

client = session.client("dataexchange")  # (1)
result = client.cancel_job()  # (2)
  1. client: DataExchangeClient
  2. result: EmptyResponseMetadataTypeDef
# ListDataSetRevisionsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_data_set_revisions")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: DataExchangeClient
  2. paginator: ListDataSetRevisionsPaginator
  3. item: ListDataSetRevisionsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[dataexchange] or a standalone mypy_boto3_dataexchange package, you have to explicitly specify client: DataExchangeClient 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.

# DataExchangeClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_dataexchange.client import DataExchangeClient
from mypy_boto3_dataexchange.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_dataexchange.type_defs import CancelJobRequestRequestTypeDef


session = Session()

client: DataExchangeClient = session.client("dataexchange")

kwargs: CancelJobRequestRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.cancel_job(**kwargs)
# ListDataSetRevisionsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_dataexchange.client import DataExchangeClient
from mypy_boto3_dataexchange.paginator import ListDataSetRevisionsPaginator
from mypy_boto3_dataexchange.type_defs import ListDataSetRevisionsResponseTypeDef


session = Session()
client: DataExchangeClient = session.client("dataexchange")

paginator: ListDataSetRevisionsPaginator = client.get_paginator("list_data_set_revisions")
for item in paginator.paginate(...):
    item: ListDataSetRevisionsResponseTypeDef
    print(item)