-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use new lilya #439
use new lilya #439
Conversation
@devkral no need for this. I already applied the new version. You can close this |
d694a92
to
5278988
Compare
@@ -1608,7 +1621,15 @@ def extend(self, config: PluggableConfig) -> None: | |||
] = State() | |||
self.async_exit_config = esmerald_settings.async_exit_config | |||
|
|||
self.encoders = self.load_settings_value("encoders", encoders) or [] | |||
self.encoders: list[Union[EncoderProtocol, MoldingProtocol]] = list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the typing here is not actually needed. Did mypy complain?
@@ -2577,13 +2595,16 @@ def default_settings( | |||
""" | |||
return esmerald_settings | |||
|
|||
async def globalise_settings(self) -> None: | |||
async def globalize_settings(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globalise with an S, I wrote in british english. Majority of what you think its an Z and I use S its because of that, so back to globalise, please
""" | ||
Making sure the global settings remain as is | ||
after the request is done. | ||
""" | ||
esmerald_settings.configure(__lazy_settings__._wrapped) | ||
|
||
# typo | ||
globalise_settings = globalize_settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rollback to S and remove this
@@ -2594,7 +2615,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: | |||
|
|||
scope["state"] = {} | |||
await super().__call__(scope, receive, send) | |||
await self.globalise_settings() | |||
await self.globalize_settings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't be making all comments about this but rollback, please
ENCODER_TYPES as LILYA_ENCODER_TYPES, # noqa | ||
Encoder as LilyaEncoder, # noqa | ||
register_encoder as register_encoder, # noqa | ||
ENCODER_TYPES as ENCODER_TYPES_CTX, # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LILYA_ENCODER_TYPES was ok, no need to rename, please rollback
def is_type(self, value: Any) -> bool: | ||
return isinstance(value, BaseModel) or is_class_and_subclass(value, BaseModel) | ||
PydanticEncoder = ModelDumpEncoder | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO need to use the try here. Msgspec is a hard dependency for now. Rollback this
encoder_types = {encoder.__class__.__name__ for encoder in ENCODER_TYPES} | ||
if encoder.__name__ not in encoder_types: | ||
register_encoder(encoder) | ||
json_encoder = json_encode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed everything to use json_encode already, no need to use this. Why? Rollback please
from typing_extensions import Annotated, Doc | ||
|
||
from esmerald.encoders import Encoder, json_encoder | ||
from esmerald.encoders import ENCODER_TYPES_CTX, Encoder, json_encoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once LILYA_ENCODER_TYPES is rolledback, this should be changed.
Literally, why change to json_encoder when the base already was updated to use the json_encode? Rollback all of this.
@@ -17,15 +20,48 @@ class ORJSONResponse(BaseJSONResponse): | |||
In the same way the JSONResponse is used, so is the `ORJSONResponse`. | |||
""" | |||
|
|||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here? The transform should be as it was before. In the Response which is the base class of all of them. This is over complicating. No reason
json_encode( | ||
content, | ||
json_encode_fn=partial( | ||
orjson.dumps, option=orjson.OPT_SERIALIZE_NUMPY | orjson.OPT_OMIT_MICROSECONDS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok to override since you want orjson here but the transform should be at the base as it was before.
@@ -19,7 +20,7 @@ | |||
from orjson import loads | |||
from pydantic import ValidationError, create_model | |||
|
|||
from esmerald.encoders import ENCODER_TYPES, Encoder | |||
from esmerald.encoders import ENCODER_TYPES_CTX, Encoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again , rollback to what it was, Literally, please
if ( | ||
not origin | ||
and hasattr(encoder, "is_type_structure") | ||
and encoder.is_type_structure(annotation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why all the tests are failing its because you removed the custom encoders of Esmerald. They differ a bit from Lilya, intentionally.
Roll everything back to the way it was before. There is a reason why its using the is_type
and not the structure. It was ALL working before.
This was not needed whatsoever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, this will work, despite a bit hacky (subclass check in is_type is a bit unexpected), I think I will undo most
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rollback everything. Esmerald is not Lilya and it operates differently. Not a hack
This PR is too invasive. I close it and do it more smart |
Don't change things that are already working. |
Checklist
Summary or description