Move reset method to above; try fix lint

This commit is contained in:
Zhiwei Liang 2021-08-06 13:27:19 -05:00
parent 84f9659998
commit 0e90d9cdb6

View File

@ -91,6 +91,15 @@ class Blueprint(BaseSanic):
self.version = version self.version = version
self.version_prefix = version_prefix self.version_prefix = version_prefix
def reset(self):
self._apps: Set[Sanic] = set()
self.exceptions: List[RouteHandler] = []
self.listeners: Dict[str, List[ListenerType]] = {}
self.middlewares: List[MiddlewareType] = []
self.routes: List[Route] = []
self.statics: List[RouteHandler] = []
self.websocket_routes: List[Route] = []
def __repr__(self) -> str: def __repr__(self) -> str:
args = ", ".join( args = ", ".join(
[ [
@ -157,7 +166,8 @@ class Blueprint(BaseSanic):
:param name: unique name of the blueprint :param name: unique name of the blueprint
:param url_prefix: URL to be prefixed before all route URLs :param url_prefix: URL to be prefixed before all route URLs
:param version: Blueprint Version :param version: Blueprint Version
:param version_prefix: the prefix of the version number shown in the URL. :param version_prefix: the prefix of the version number shown in the
URL.
:param strict_slashes: Enforce the API urls are requested with a :param strict_slashes: Enforce the API urls are requested with a
trailing */* trailing */*
:param with_registration: whether register new blueprint instance with :param with_registration: whether register new blueprint instance with
@ -194,8 +204,8 @@ class Blueprint(BaseSanic):
if with_registration: if with_registration:
if len(new_bp._future_statics) > 0 and len(self._apps) > 0: if len(new_bp._future_statics) > 0 and len(self._apps) > 0:
raise Exception( raise Exception(
"Static routes registered with the old blueprint instance, " "Static routes registered with the old blueprint instance,"
"cannot be registered again." " cannot be registered again."
) )
for app in self._apps: for app in self._apps:
app.blueprint(new_bp) app.blueprint(new_bp)
@ -355,15 +365,6 @@ class Blueprint(BaseSanic):
*[app.dispatch(*args, **kwargs) for app in self.apps] *[app.dispatch(*args, **kwargs) for app in self.apps]
) )
def reset(self):
self._apps: Set[Sanic] = set()
self.exceptions: List[RouteHandler] = []
self.listeners: Dict[str, List[ListenerType]] = {}
self.middlewares: List[MiddlewareType] = []
self.routes: List[Route] = []
self.statics: List[RouteHandler] = []
self.websocket_routes: List[Route] = []
def event(self, event: str, timeout: Optional[Union[int, float]] = None): def event(self, event: str, timeout: Optional[Union[int, float]] = None):
events = set() events = set()
for app in self.apps: for app in self.apps: