From 0c5475191ccbddb7e2f8f0120b2282cb1fd9a47c Mon Sep 17 00:00:00 2001 From: Tiago Silva Date: Mon, 25 Nov 2024 13:41:56 +0000 Subject: [PATCH] Update ENCODER_TYPES to read from context var --- esmerald/encoders.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/esmerald/encoders.py b/esmerald/encoders.py index b1798cfc..5651cf33 100644 --- a/esmerald/encoders.py +++ b/esmerald/encoders.py @@ -5,7 +5,7 @@ import msgspec from lilya._utils import is_class_and_subclass from lilya.encoders import ( - ENCODER_TYPES as ENCODER_TYPES, # noqa + ENCODER_TYPES as LILYA_ENCODER_TYPES, # noqa Encoder as LilyaEncoder, # noqa json_encode as json_encode, # noqa register_encoder as register_encoder, # noqa @@ -19,9 +19,10 @@ T = TypeVar("T") +ENCODER_TYPES = LILYA_ENCODER_TYPES.get() -class Encoder(LilyaEncoder[T]): +class Encoder(LilyaEncoder[T]): def is_type(self, value: Any) -> bool: """ Function that checks if the function is @@ -44,7 +45,6 @@ def encode(self, structure: Any, value: Any) -> Any: class MsgSpecEncoder(Encoder): - def is_type(self, value: Any) -> bool: return isinstance(value, Struct) or is_class_and_subclass(value, Struct) @@ -60,7 +60,6 @@ def encode(self, structure: Any, value: Any) -> Any: class PydanticEncoder(Encoder): - def is_type(self, value: Any) -> bool: return isinstance(value, BaseModel) or is_class_and_subclass(value, BaseModel)