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:
parent
ac784759d5
commit
021da38373
13
sanic/app.py
13
sanic/app.py
@ -30,6 +30,7 @@ from typing import (
|
|||||||
List,
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
Set,
|
Set,
|
||||||
|
Tuple,
|
||||||
Type,
|
Type,
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
@ -411,7 +412,13 @@ class Sanic(BaseSanic):
|
|||||||
|
|
||||||
self.websocket_enabled = enable
|
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.
|
"""Register a blueprint on the application.
|
||||||
|
|
||||||
:param blueprint: Blueprint object or (list, tuple) thereof
|
:param blueprint: Blueprint object or (list, tuple) thereof
|
||||||
@ -869,7 +876,7 @@ class Sanic(BaseSanic):
|
|||||||
*,
|
*,
|
||||||
debug: bool = False,
|
debug: bool = False,
|
||||||
auto_reload: Optional[bool] = None,
|
auto_reload: Optional[bool] = None,
|
||||||
ssl: Union[dict, SSLContext, None] = None,
|
ssl: Union[Dict[str, str], SSLContext, None] = None,
|
||||||
sock: Optional[socket] = None,
|
sock: Optional[socket] = None,
|
||||||
workers: int = 1,
|
workers: int = 1,
|
||||||
protocol: Optional[Type[Protocol]] = None,
|
protocol: Optional[Type[Protocol]] = None,
|
||||||
@ -999,7 +1006,7 @@ class Sanic(BaseSanic):
|
|||||||
port: Optional[int] = None,
|
port: Optional[int] = None,
|
||||||
*,
|
*,
|
||||||
debug: bool = False,
|
debug: bool = False,
|
||||||
ssl: Union[dict, SSLContext, None] = None,
|
ssl: Union[Dict[str, str], SSLContext, None] = None,
|
||||||
sock: Optional[socket] = None,
|
sock: Optional[socket] = None,
|
||||||
protocol: Type[Protocol] = None,
|
protocol: Type[Protocol] = None,
|
||||||
backlog: int = 100,
|
backlog: int = 100,
|
||||||
|
@ -146,10 +146,10 @@ class Blueprint(BaseSanic):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def group(
|
def group(
|
||||||
*blueprints,
|
*blueprints: Union[Blueprint, BlueprintGroup],
|
||||||
url_prefix="",
|
url_prefix: Optional[str] = None,
|
||||||
version=None,
|
version: Optional[Union[int, str, float]] = None,
|
||||||
strict_slashes=None,
|
strict_slashes: Optional[bool] = None,
|
||||||
version_prefix: str = "/v",
|
version_prefix: str = "/v",
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user