Skip to content

Examples#

Index > EventBridge > Examples

Auto-generated documentation for EventBridge type annotations stubs module mypy-boto3-events.

Client#

Implicit type annotations#

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

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

Client method usage example#

# EventBridgeClient usage example

from boto3.session import Session


session = Session()

client = session.client("events")  # (1)
result = client.activate_event_source()  # (2)
  1. client: EventBridgeClient
  2. result: EmptyResponseMetadataTypeDef

Paginator usage example#

# ListRuleNamesByTargetPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("list_rule_names_by_target")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: EventBridgeClient
  2. paginator: ListRuleNamesByTargetPaginator
  3. item: ListRuleNamesByTargetResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[events] or a standalone mypy_boto3_events package, you have to explicitly specify client: EventBridgeClient 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#

# EventBridgeClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_events.client import EventBridgeClient
from mypy_boto3_events.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_events.type_defs import ActivateEventSourceRequestTypeDef


session = Session()

client: EventBridgeClient = session.client("events")

kwargs: ActivateEventSourceRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.activate_event_source(**kwargs)

Paginator usage example#

# ListRuleNamesByTargetPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_events.client import EventBridgeClient
from mypy_boto3_events.paginator import ListRuleNamesByTargetPaginator
from mypy_boto3_events.type_defs import ListRuleNamesByTargetResponseTypeDef


session = Session()
client: EventBridgeClient = session.client("events")

paginator: ListRuleNamesByTargetPaginator = client.get_paginator("list_rule_names_by_target")
for item in paginator.paginate(...):
    item: ListRuleNamesByTargetResponseTypeDef
    print(item)