style(app,blueprints): add some type hints (#2196)

* style(app,blueprints): add some type hints

* style(app): option is Any

* style(blueprints): url prefix default value is ``""``

* style(app): backward compatible

* style(app): backward compatible

* style(blueprints): defult is None

* style(app): apply code style (black)
This commit is contained in:
Ryu JuHeon 2021-07-13 16:32:54 +09:00 committed by GitHub
parent ac784759d5
commit 021da38373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -30,6 +30,7 @@ from typing import (
List,
Optional,
Set,
Tuple,
Type,
Union,
)
@ -411,7 +412,13 @@ class Sanic(BaseSanic):
self.websocket_enabled = enable
def blueprint(self, blueprint, **options):
def blueprint(
self,
blueprint: Union[
Blueprint, List[Blueprint], Tuple[Blueprint], BlueprintGroup
],
**options: Any,
):
"""Register a blueprint on the application.
:param blueprint: Blueprint object or (list, tuple) thereof
@ -869,7 +876,7 @@ class Sanic(BaseSanic):
*,
debug: bool = False,
auto_reload: Optional[bool] = None,
ssl: Union[dict, SSLContext, None] = None,
ssl: Union[Dict[str, str], SSLContext, None] = None,
sock: Optional[socket] = None,
workers: int = 1,
protocol: Optional[Type[Protocol]] = None,
@ -999,7 +1006,7 @@ class Sanic(BaseSanic):
port: Optional[int] = None,
*,
debug: bool = False,
ssl: Union[dict, SSLContext, None] = None,
ssl: Union[Dict[str, str], SSLContext, None] = None,
sock: Optional[socket] = None,
protocol: Type[Protocol] = None,
backlog: int = 100,

View File

@ -146,10 +146,10 @@ class Blueprint(BaseSanic):
@staticmethod
def group(
*blueprints,
url_prefix="",
version=None,
strict_slashes=None,
*blueprints: Union[Blueprint, BlueprintGroup],
url_prefix: Optional[str] = None,
version: Optional[Union[int, str, float]] = None,
strict_slashes: Optional[bool] = None,
version_prefix: str = "/v",
):
"""