From a278dbb94443c89006ccac7a4dd8fb2d1a2d818a Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 25 Nov 2024 19:09:24 +0100 Subject: [PATCH] fix typings --- esmerald/applications.py | 16 +++++++++------- esmerald/testclient.py | 9 ++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/esmerald/applications.py b/esmerald/applications.py index ebeca783..7684d5b2 100644 --- a/esmerald/applications.py +++ b/esmerald/applications.py @@ -1032,10 +1032,12 @@ async def another(request: Request) -> str: encoders: Annotated[ Optional[ Sequence[ - EncoderProtocol - | MoldingProtocol - | type[EncoderProtocol] - | type[MoldingProtocol] + Union[ + EncoderProtocol, + MoldingProtocol, + type[EncoderProtocol], + type[MoldingProtocol], + ] ] ], Doc( @@ -1621,9 +1623,9 @@ def extend(self, config: PluggableConfig) -> None: ] = State() self.async_exit_config = esmerald_settings.async_exit_config - self.encoders: deque[EncoderProtocol | MoldingProtocol] = deque( + self.encoders: deque[Union[EncoderProtocol, MoldingProtocol]] = deque( cast( - Iterable[EncoderProtocol | MoldingProtocol], + Iterable[Union[EncoderProtocol, MoldingProtocol]], ( encoder if isclass(encoder) else encoder for encoder in self.load_settings_value("encoders", encoders) or [] @@ -2624,7 +2626,7 @@ def on_event(self, event_type: str) -> Callable: # pragma: nocover def add_event_handler(self, event_type: str, func: Callable) -> None: # pragma: no cover self.router.add_event_handler(event_type, func) - def register_encoder(self, encoder: EncoderProtocol | MoldingProtocol) -> None: + def register_encoder(self, encoder: Union[EncoderProtocol, MoldingProtocol]) -> None: """ Registers a Encoder into the list of predefined encoders of the system. """ diff --git a/esmerald/testclient.py b/esmerald/testclient.py index 032c30c3..e44617fe 100644 --- a/esmerald/testclient.py +++ b/esmerald/testclient.py @@ -137,7 +137,14 @@ def create_client( tags: Optional[List[str]] = None, webhooks: Optional[Sequence["WebhookGateway"]] = None, encoders: Optional[ - Sequence[EncoderProtocol | MoldingProtocol | type[EncoderProtocol] | type[MoldingProtocol]] + Sequence[ + Union[ + EncoderProtocol, + MoldingProtocol, + type[EncoderProtocol], + type[MoldingProtocol], + ] + ] ] = None, ) -> EsmeraldTestClient: return EsmeraldTestClient(