From df78a06d0feca2e5dca6f9eb07da2df5f1d860c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 11 Feb 2023 23:17:46 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- robyn/__init__.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/robyn/__init__.py b/robyn/__init__.py index b58797106..3b5b730d3 100644 --- a/robyn/__init__.py +++ b/robyn/__init__.py @@ -22,6 +22,7 @@ logger = logging.getLogger(__name__) + class Robyn: """This is the python wrapper for the Robyn binaries.""" @@ -167,7 +168,6 @@ def terminating_signal_handler(_sig, _frame): observer.stop() observer.join() - def add_view(self, endpoint: str, view, const: bool = False): """ [This is base handler for the view decorators] @@ -175,18 +175,27 @@ def add_view(self, endpoint: str, view, const: bool = False): :param endpoint [str]: [endpoint for the route added] :param handler [function]: [represents the function passed as a parent handler for single route with different route types] """ + def get_functions(view): functions = get_all_nested(view) output = [] - for (name, handler) in functions: + for name, handler in functions: route_type = name.upper() - if route_type in ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']: + if route_type in [ + "GET", + "POST", + "PUT", + "DELETE", + "PATCH", + "HEAD", + "OPTIONS", + ]: output.append((route_type.upper(), handler)) return output handlers = get_functions(view) routes = [] - for (route_type, handler) in handlers: + for route_type, handler in handlers: routes.append(self._add_route(route_type, endpoint, handler, const)) return routes @@ -196,6 +205,7 @@ def view(self, endpoint: str, const: bool = False): :param endpoint str: endpoint to server the route """ + def inner(handler): return self.add_view(endpoint, handler, const)