Fix many type errors.

This commit is contained in:
Tom Hacohen
2020-12-29 13:22:36 +02:00
parent e13f26ec56
commit 794b5f3983
12 changed files with 87 additions and 64 deletions

View File

@@ -19,13 +19,15 @@ class MsgpackRequest(Request):
class MsgpackResponse(Response):
media_type = "application/msgpack"
def render(self, content: t.Optional[t.Any]) -> t.Optional[bytes]:
def render(self, content: t.Optional[t.Any]) -> bytes:
if content is None:
return b""
if isinstance(content, BaseModel):
content = content.dict()
return msgpack.packb(content, use_bin_type=True)
ret = msgpack.packb(content, use_bin_type=True)
assert ret is not None
return ret
class MsgpackRoute(APIRoute):