Skip to content

Examples#

Index > KafkaConnect > Examples

Auto-generated documentation for KafkaConnect type annotations stubs module mypy-boto3-kafkaconnect.

Client#

Implicit type annotations#

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

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

# KafkaConnectClient usage example

from boto3.session import Session


session = Session()

client = session.client("kafkaconnect")  # (1)
result = client.create_connector()  # (2)
  1. client: KafkaConnectClient
  2. result: CreateConnectorResponseTypeDef
# ListConnectorsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_connectors")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: KafkaConnectClient
  2. paginator: ListConnectorsPaginator
  3. item: ListConnectorsResponseTypeDef

Explicit type annotations#

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

# KafkaConnectClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_kafkaconnect.client import KafkaConnectClient
from mypy_boto3_kafkaconnect.type_defs import CreateConnectorResponseTypeDef
from mypy_boto3_kafkaconnect.type_defs import CreateConnectorRequestRequestTypeDef


session = Session()

client: KafkaConnectClient = session.client("kafkaconnect")

kwargs: CreateConnectorRequestRequestTypeDef = {...}
result: CreateConnectorResponseTypeDef = client.create_connector(**kwargs)
# ListConnectorsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_kafkaconnect.client import KafkaConnectClient
from mypy_boto3_kafkaconnect.paginator import ListConnectorsPaginator
from mypy_boto3_kafkaconnect.type_defs import ListConnectorsResponseTypeDef


session = Session()
client: KafkaConnectClient = session.client("kafkaconnect")

paginator: ListConnectorsPaginator = client.get_paginator("list_connectors")
for item in paginator.paginate(...):
    item: ListConnectorsResponseTypeDef
    print(item)