Skip to content

Examples#

Index > IoTDataPlane > Examples

Auto-generated documentation for IoTDataPlane type annotations stubs module mypy-boto3-iot-data.

Client#

Implicit type annotations#

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

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

# IoTDataPlaneClient usage example

from boto3.session import Session


session = Session()

client = session.client("iot-data")  # (1)
result = client.delete_thing_shadow()  # (2)
  1. client: IoTDataPlaneClient
  2. result: DeleteThingShadowResponseTypeDef
# ListRetainedMessagesPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("iot-data")  # (1)

paginator = client.get_paginator("list_retained_messages")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: IoTDataPlaneClient
  2. paginator: ListRetainedMessagesPaginator
  3. item: ListRetainedMessagesResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[iot-data] or a standalone mypy_boto3_iot_data package, you have to explicitly specify client: IoTDataPlaneClient 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.

# IoTDataPlaneClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_iot_data.client import IoTDataPlaneClient
from mypy_boto3_iot_data.type_defs import DeleteThingShadowResponseTypeDef
from mypy_boto3_iot_data.type_defs import DeleteThingShadowRequestRequestTypeDef


session = Session()

client: IoTDataPlaneClient = session.client("iot-data")

kwargs: DeleteThingShadowRequestRequestTypeDef = {...}
result: DeleteThingShadowResponseTypeDef = client.delete_thing_shadow(**kwargs)
# ListRetainedMessagesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_iot_data.client import IoTDataPlaneClient
from mypy_boto3_iot_data.paginator import ListRetainedMessagesPaginator
from mypy_boto3_iot_data.type_defs import ListRetainedMessagesResponseTypeDef


session = Session()
client: IoTDataPlaneClient = session.client("iot-data")

paginator: ListRetainedMessagesPaginator = client.get_paginator("list_retained_messages")
for item in paginator.paginate(...):
    item: ListRetainedMessagesResponseTypeDef
    print(item)