Skip to content

Commit

Permalink
fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral committed Nov 25, 2024
1 parent eafc554 commit a278dbb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 9 additions & 7 deletions esmerald/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 []
Expand Down Expand Up @@ -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.
"""
Expand Down
9 changes: 8 additions & 1 deletion esmerald/testclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a278dbb

Please sign in to comment.