10
10
import typing # TypeAlias, py3.10
11
11
from datetime import datetime , timezone
12
12
from enum import Enum , auto , unique
13
- from typing import Any , AsyncIterator , Iterator , Optional , Union , TypeVar
13
+ from typing import Any , AsyncIterator , Awaitable , Iterator , Optional , Union
14
14
15
15
import httpx
16
16
import structlog
@@ -483,13 +483,16 @@ async def handle_event_stream(
483
483
break
484
484
return self .response
485
485
486
+ async def noop (self ) -> None :
487
+ pass
488
+
486
489
def event_to_handle_future (self , event : PublicEventType ) -> Awaitable [None ]:
487
490
if isinstance (event , Heartbeat ):
488
491
# Heartbeat events exist solely to ensure that we have a
489
492
# regular opportunity to check for cancelation and
490
493
# timeouts.
491
494
# We don't need to do anything with them.
492
- return
495
+ return self . noop ()
493
496
if isinstance (event , Log ):
494
497
return self .append_logs (event .message )
495
498
@@ -500,9 +503,9 @@ def event_to_handle_future(self, event: PublicEventType) -> Awaitable[None]:
500
503
if self ._output_type .multi :
501
504
return self .set_output ([])
502
505
if isinstance (event , PredictionOutput ):
503
- if output_type is None :
506
+ if self . _output_type is None :
504
507
return self .failed (error = "Predictor returned unexpected output" )
505
- if output_type .multi :
508
+ if self . _output_type .multi :
506
509
return self .append_output (event .payload )
507
510
return self .set_output (event .payload )
508
511
if isinstance (event , Done ): # pyright: ignore reportUnnecessaryIsinstance
0 commit comments