|
14 | 14 |
|
15 | 15 | from dataclasses import dataclass |
16 | 16 | from datetime import datetime, timezone |
17 | | -from typing import Any, Callable, Final |
| 17 | +from typing import Any, Final |
18 | 18 |
|
19 | 19 | from dateutil.parser import isoparse |
20 | 20 |
|
21 | | -from cloudevents.core.base import BaseCloudEvent |
| 21 | +from cloudevents.core.base import BaseCloudEvent, EventFactory |
22 | 22 | from cloudevents.core.formats.base import Format |
23 | 23 |
|
24 | 24 | # AMQP CloudEvents spec allows both cloudEvents_ and cloudEvents: prefixes |
@@ -149,9 +149,7 @@ def to_binary(event: BaseCloudEvent, event_format: Format) -> AMQPMessage: |
149 | 149 | def from_binary( |
150 | 150 | message: AMQPMessage, |
151 | 151 | event_format: Format, |
152 | | - event_factory: Callable[ |
153 | | - [dict[str, Any], dict[str, Any] | str | bytes | None], BaseCloudEvent |
154 | | - ], |
| 152 | + event_factory: EventFactory, |
155 | 153 | ) -> BaseCloudEvent: |
156 | 154 | """ |
157 | 155 | Parse an AMQP binary content mode message to a CloudEvent. |
@@ -250,9 +248,7 @@ def to_structured(event: BaseCloudEvent, event_format: Format) -> AMQPMessage: |
250 | 248 | def from_structured( |
251 | 249 | message: AMQPMessage, |
252 | 250 | event_format: Format, |
253 | | - event_factory: Callable[ |
254 | | - [dict[str, Any], dict[str, Any] | str | bytes | None], BaseCloudEvent |
255 | | - ], |
| 251 | + event_factory: EventFactory, |
256 | 252 | ) -> BaseCloudEvent: |
257 | 253 | """ |
258 | 254 | Parse an AMQP structured content mode message to a CloudEvent. |
@@ -283,9 +279,7 @@ def from_structured( |
283 | 279 | def from_amqp( |
284 | 280 | message: AMQPMessage, |
285 | 281 | event_format: Format, |
286 | | - event_factory: Callable[ |
287 | | - [dict[str, Any], dict[str, Any] | str | bytes | None], BaseCloudEvent |
288 | | - ], |
| 282 | + event_factory: EventFactory, |
289 | 283 | ) -> BaseCloudEvent: |
290 | 284 | """ |
291 | 285 | Parse an AMQP message to a CloudEvent with automatic mode detection. |
|
0 commit comments