From 2d72874b0b95f58e0ef95358537f041bdb90e2a0 Mon Sep 17 00:00:00 2001 From: Adam Bannister Date: Thu, 12 Dec 2019 17:25:13 +0100 Subject: [PATCH] Add return type to Sanic.create_server for type hinting and docs (#1724) * add type hint and doc when create_server returns AsyncioServer * fix linting --- sanic/app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sanic/app.py b/sanic/app.py index 016ab73d..58c785b0 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -24,7 +24,13 @@ from sanic.handlers import ErrorHandler from sanic.log import LOGGING_CONFIG_DEFAULTS, error_logger, logger from sanic.response import HTTPResponse, StreamingHTTPResponse from sanic.router import Router -from sanic.server import HttpProtocol, Signal, serve, serve_multiple +from sanic.server import ( + AsyncioServer, + HttpProtocol, + Signal, + serve, + serve_multiple, +) from sanic.static import register as static_register from sanic.testing import SanicASGITestClient, SanicTestClient from sanic.views import CompositionView @@ -1166,7 +1172,7 @@ class Sanic: access_log: Optional[bool] = None, return_asyncio_server=False, asyncio_server_kwargs=None, - ) -> None: + ) -> Optional[AsyncioServer]: """ Asynchronous version of :func:`run`. @@ -1206,7 +1212,7 @@ class Sanic: :param asyncio_server_kwargs: key-value arguments for asyncio/uvloop create_server method :type asyncio_server_kwargs: dict - :return: Nothing + :return: AsyncioServer if return_asyncio_server is true, else Nothing """ if sock is None: