Skip to content

Commit 43c7976

Browse files
committed
0.7.3
1 parent 34943d3 commit 43c7976

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

ellar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Ellar - Python ASGI web framework for building fast, efficient, and scalable RESTful APIs and server-side applications."""
22

3-
__version__ = "0.7.2"
3+
__version__ = "0.7.3"

ellar/common/responses/models/file.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,18 @@ class FileResponseModelSchema(Serializer):
2222
method: t.Optional[str] = None
2323
content_disposition_type: ContentDispositionType = ContentDispositionType.attachment
2424

25+
2526
class StreamResponseModelSchema(Serializer):
2627
media_type: t.Optional[str] = None
2728
content: t.Any
2829

29-
@field_validator('content', mode='before')
30+
@field_validator("content", mode="before")
3031
def pre_validate_content(cls, value: t.Dict) -> t.Any:
3132
if not isinstance(value, (t.AsyncGenerator, t.Generator)):
32-
raise ValueError(
33-
"Content must typing.AsyncIterable OR typing.Iterable"
34-
)
33+
raise ValueError("Content must typing.AsyncIterable OR typing.Iterable")
3534
return value
3635

3736

38-
3937
class FileResponseModel(ResponseModel):
4038
__slots__ = ("_file_init_schema",)
4139

@@ -116,11 +114,12 @@ def create_response(
116114
response_args, headers = self.get_context_response(
117115
context=context, status_code=status_code
118116
)
119-
data = self.serialize(response_obj)
117+
data = t.cast(StreamResponseModelSchema, self.serialize(response_obj))
120118

121119
response = self._response_type(
122120
**response_args,
123-
headers=headers, content=data.content,
124-
media_type=data.media_type or self.media_type
121+
headers=headers,
122+
content=data.content,
123+
media_type=data.media_type or self.media_type,
125124
)
126125
return response

tests/test_response/test_response_streaming.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
import pytest
55
from ellar.common import Controller, ModuleRouter, file, get, serialize_object
6-
from ellar.common.responses.models import (
7-
StreamingResponseModel
8-
)
6+
from ellar.common.responses.models import StreamingResponseModel
97
from ellar.openapi import OpenAPIDocumentBuilder
108
from ellar.testing import Test
119

@@ -62,11 +60,13 @@ def index(self):
6260
@file(media_type="text/html", streaming=True)
6361
def index3(self):
6462
"""detest its mvc and Looks for ellar/index"""
65-
return {"content": {
66-
"path": f"{BASEDIR}/private/test.css",
67-
"filename": "file-test-css.css",
68-
"content_disposition_type": "whatever",
69-
}}
63+
return {
64+
"content": {
65+
"path": f"{BASEDIR}/private/test.css",
66+
"filename": "file-test-css.css",
67+
"content_disposition_type": "whatever",
68+
}
69+
}
7070

7171

7272
test_module = Test.create_test_module(

0 commit comments

Comments
 (0)