ruff format

This commit is contained in:
L. Kärkkäinen 2023-10-25 00:22:00 +01:00
parent 209840b771
commit 140d27ef96
10 changed files with 12 additions and 17 deletions

View File

@ -25,5 +25,6 @@ def key_exist_handler(request):
return text("num does not exist in request")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000, debug=True)

View File

@ -69,5 +69,6 @@ async def runner(app: Sanic, app_server: AsyncioServer):
app.is_running = False
app.is_stopping = True
if __name__ == "__main__":
https.run(port=HTTPS_PORT, debug=True)

View File

@ -35,6 +35,7 @@ async def after_server_stop(app, loop):
async def test(request):
return response.json({"answer": "42"})
if __name__ == "__main__":
asyncio.set_event_loop(uvloop.new_event_loop())
serv_coro = app.create_server(

View File

@ -349,8 +349,7 @@ def parse_content_header(value: str) -> Tuple[str, Options]:
options: Dict[str, Union[int, str]] = {}
else:
options = {
m.group(1)
.lower(): (m.group(2) or m.group(3))
m.group(1).lower(): (m.group(2) or m.group(3))
.replace("%22", '"')
.replace("%0D%0A", "\n")
for m in _param.finditer(value[pos:])

View File

@ -14,7 +14,7 @@ class ExceptionMixin(metaclass=SanicMeta):
def exception(
self,
*exceptions: Union[Type[Exception], List[Type[Exception]]],
apply: bool = True
apply: bool = True,
) -> Callable:
"""Decorator used to register an exception handler for the current application or blueprint instance.

View File

@ -25,7 +25,7 @@ class MiddlewareMixin(metaclass=SanicMeta):
attach_to: str = "request",
apply: bool = True,
*,
priority: int = 0
priority: int = 0,
) -> MiddlewareType:
...
@ -36,7 +36,7 @@ class MiddlewareMixin(metaclass=SanicMeta):
attach_to: str = "request",
apply: bool = True,
*,
priority: int = 0
priority: int = 0,
) -> Callable[[MiddlewareType], MiddlewareType]:
...
@ -46,7 +46,7 @@ class MiddlewareMixin(metaclass=SanicMeta):
attach_to: str = "request",
apply: bool = True,
*,
priority: int = 0
priority: int = 0,
) -> Union[MiddlewareType, Callable[[MiddlewareType], MiddlewareType]]:
"""Decorator for registering middleware.

View File

@ -44,12 +44,8 @@ class ConnInfo:
self.server_name = ""
self.cert: Dict[str, Any] = {}
self.network_paths: List[Any] = []
sslobj: Optional[SSLObject] = transport.get_extra_info(
"ssl_object"
) # type: ignore
sslctx: Optional[SSLContext] = transport.get_extra_info(
"ssl_context"
) # type: ignore
sslobj: Optional[SSLObject] = transport.get_extra_info("ssl_object") # type: ignore
sslctx: Optional[SSLContext] = transport.get_extra_info("ssl_context") # type: ignore
if sslobj:
self.ssl = True
self.server_name = getattr(sslobj, "sanic_server_name", None) or ""

View File

@ -57,9 +57,7 @@ class WebsocketFrameAssembler:
self.read_mutex = asyncio.Lock()
self.write_mutex = asyncio.Lock()
self.completed_queue = asyncio.Queue(
maxsize=1
) # type: asyncio.Queue[Data]
self.completed_queue = asyncio.Queue(maxsize=1) # type: asyncio.Queue[Data]
# put() sets this event to tell get() that a message can be fetched.
self.message_complete = asyncio.Event()

View File

@ -1,4 +1,3 @@
from asyncio import CancelledError

View File

@ -57,7 +57,7 @@ def raised_ceiling():
# Chrome, Firefox:
# Content-Disposition: form-data; name="foo%22;bar\"; filename="😀"
'form-data; name="foo%22;bar\\"; filename="😀"',
("form-data", {"name": 'foo";bar\\', "filename": "😀"})
("form-data", {"name": 'foo";bar\\', "filename": "😀"}),
# cgi: ('form-data', {'name': 'foo%22;bar"; filename="😀'})
# werkzeug (pre 2.3.0): ('form-data', {'name': 'foo%22;bar"; filename='})
),