Skip to content

Commit a696720

Browse files
committed
[Fix] lint
1 parent 5cb80dc commit a696720

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/py/extra/handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .http.model import (
1212
HTTPRequest,
1313
HTTPHeaders,
14-
HTTPBodyBlob,
1514
HTTPResponseFile,
1615
HTTPResponseStream,
1716
HTTPResponseAsyncStream,

src/py/extra/http/api.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def notModified(self):
7171
def fail(
7272
self,
7373
content: str | None = None,
74+
*,
7475
status: int = 500,
7576
contentType: str = "text/plain",
7677
):
@@ -87,8 +88,10 @@ def redirect(self, url: str, permanent: bool = False):
8788
def returns(
8889
self,
8990
value: Any,
90-
contentType: str = "application/json",
9191
headers: dict[str, str] | None = None,
92+
*,
93+
status: int = 200,
94+
contentType: str = "application/json",
9295
):
9396
if isinstance(value, bytes):
9497
try:
@@ -101,18 +104,25 @@ def returns(
101104
contentType=contentType,
102105
contentLength=len(payload),
103106
headers=headers,
107+
status=status,
104108
)
105109

106110
def respondText(
107-
self, content: str | bytes | Iterator[str | bytes], contentType="text/plain"
111+
self,
112+
content: str | bytes | Iterator[str | bytes],
113+
contentType="text/plain",
114+
status: int = 200,
108115
):
109-
return self.respond(content=content, contentType=contentType)
116+
return self.respond(content=content, contentType=contentType, status=status)
110117

111-
def respondHTML(self, html: str | bytes | Iterator[str | bytes]):
112-
return self.respond(content=html, contentType="text/html")
118+
def respondHTML(self, html: str | bytes | Iterator[str | bytes], status: int = 200):
119+
return self.respond(content=html, contentType="text/html", status=status)
113120

114121
def respondFile(
115-
self, path: Path | str, status: int = 200, headers: dict[str, str] | None = None
122+
self,
123+
path: Path | str,
124+
headers: dict[str, str] | None = None,
125+
status: int = 200,
116126
):
117127
# TODO: We should have a much more detailed file handling, supporting ranges, etags, etc.
118128
p: Path = path if isinstance(path, Path) else Path(path)
@@ -128,8 +138,9 @@ def respondFile(
128138
def respondError(
129139
self,
130140
content: str | None = None,
131-
status: int = 500,
132141
contentType: str = "text/plain",
142+
*,
143+
status: int = 500,
133144
):
134145
return self.error(status, content, contentType)
135146

src/py/extra/server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from .utils.limits import LimitType, unlimit
77
from .model import Application, Service, mount
88
from .http.model import (
9-
HTTPBodyBlob,
109
HTTPRequest,
1110
HTTPResponse,
1211
HTTPResponseStream,

0 commit comments

Comments
 (0)