Run black and manually break up some text lines to correct linting

This commit is contained in:
Adam Hopkins 2019-06-04 13:18:05 +03:00
parent daf42c5f43
commit 0d9a21718f

View File

@ -104,19 +104,23 @@ class Lifespan:
if "before_server_start" in self.asgi_app.sanic_app.listeners: if "before_server_start" in self.asgi_app.sanic_app.listeners:
warnings.warn( warnings.warn(
'You have set a listener for "before_server_start" in ASGI mode. ' 'You have set a listener for "before_server_start" '
'It will be executed as early as possible, but not before ' "in ASGI mode. "
'the ASGI server is started.' "It will be executed as early as possible, but not before "
"the ASGI server is started."
) )
if "after_server_stop" in self.asgi_app.sanic_app.listeners: if "after_server_stop" in self.asgi_app.sanic_app.listeners:
warnings.warn( warnings.warn(
'You have set a listener for "after_server_stop" in ASGI mode. ' 'You have set a listener for "after_server_stop" '
'It will be executed as late as possible, but not after ' "in ASGI mode. "
'the ASGI server is stopped.' "It will be executed as late as possible, but not after "
"the ASGI server is stopped."
) )
async def pre_startup(self) -> None: async def pre_startup(self) -> None:
for handler in self.asgi_app.sanic_app.listeners["before_server_start"]: for handler in self.asgi_app.sanic_app.listeners[
"before_server_start"
]:
response = handler( response = handler(
self.asgi_app.sanic_app, self.asgi_app.sanic_app.loop self.asgi_app.sanic_app, self.asgi_app.sanic_app.loop
) )
@ -124,7 +128,9 @@ class Lifespan:
await response await response
async def startup(self) -> None: async def startup(self) -> None:
for handler in self.asgi_app.sanic_app.listeners["before_server_start"]: for handler in self.asgi_app.sanic_app.listeners[
"before_server_start"
]:
response = handler( response = handler(
self.asgi_app.sanic_app, self.asgi_app.sanic_app.loop self.asgi_app.sanic_app, self.asgi_app.sanic_app.loop
) )
@ -290,7 +296,9 @@ class ASGIApp:
type(response), type(response),
) )
exception = ServerError("Invalid response type") exception = ServerError("Invalid response type")
response = self.sanic_app.error_handler.response(self.request, exception) response = self.sanic_app.error_handler.response(
self.request, exception
)
headers = [ headers = [
(str(name).encode("latin-1"), str(value).encode("latin-1")) (str(name).encode("latin-1"), str(value).encode("latin-1"))
for name, value in response.headers.items() for name, value in response.headers.items()
@ -307,7 +315,10 @@ class ASGIApp:
if response.cookies: if response.cookies:
cookies = SimpleCookie() cookies = SimpleCookie()
cookies.load(response.cookies) cookies.load(response.cookies)
headers += [(b"set-cookie", cookie.encode("utf-8")) for name, cookie in response.cookies.items()] headers += [
(b"set-cookie", cookie.encode("utf-8"))
for name, cookie in response.cookies.items()
]
await self.transport.send( await self.transport.send(
{ {