Skip to content

Commit

Permalink
Make pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
ahopkins committed Dec 31, 2023
1 parent 832152f commit 788054d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
8 changes: 6 additions & 2 deletions sanic_ext/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ def __init__(
self.TRACE_EXCLUDED_HEADERS = trace_excluded_headers

if isinstance(self.TRACE_EXCLUDED_HEADERS, str):
self.TRACE_EXCLUDED_HEADERS = tuple(self.TRACE_EXCLUDED_HEADERS.split(","))
self.TRACE_EXCLUDED_HEADERS = tuple(
self.TRACE_EXCLUDED_HEADERS.split(",")
)

if isinstance(self.INJECTION_SIGNAL, str):
self.INJECTION_SIGNAL = Event(self.INJECTION_SIGNAL)

valid_signals = ("http.handler.before", "http.routing.after")
if self.INJECTION_SIGNAL.value not in valid_signals:
raise SanicException(f"Injection signal may only be one of {valid_signals}")
raise SanicException(
f"Injection signal may only be one of {valid_signals}"
)

self.load({key.upper(): value for key, value in kwargs.items()})

Expand Down
4 changes: 0 additions & 4 deletions sanic_ext/extensions/http/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ async def trace_handler(request):
)
return raw(message, content_type="message/http")

<<<<<<< HEAD
@app.before_server_start(priority=PRIORITY)
=======
@app.before_server_start(priority=PRIORITY + 1)
>>>>>>> e3ff389a9284a148ddf38413386aaea602edc911
def _add_handlers(app, _):
nonlocal auto_head
nonlocal auto_options
Expand Down
16 changes: 12 additions & 4 deletions sanic_ext/extensions/injection/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ async def inject_kwargs(request, **_):
request.route.name,
f"{request.route.name}_{request.method.lower()}",
):
dependencies, constants = signature_registry.get(name, (None, None))
dependencies, constants = signature_registry.get(
name, (None, None)
)
if dependencies or constants:
break

Expand Down Expand Up @@ -84,10 +86,14 @@ async def setup_signatures(app, _):
if viewclass:
handlers = [
(f"{route.name}_{name}", member)
for name, member in getmembers(viewclass, _http_method_predicate)
for name, member in getmembers(
viewclass, _http_method_predicate
)
]
for name, handler in handlers:
if route_handler := getattr(handler, "__route_handler__", None):
if route_handler := getattr(
handler, "__route_handler__", None
):
handler = route_handler
if isinstance(handler, partial):
if handler.func == app._websocket_handler:
Expand All @@ -99,7 +105,9 @@ async def setup_signatures(app, _):
except TypeError:
continue

dependencies: Dict[str, Tuple[Type, Optional[Callable[..., Any]]]] = {}
dependencies: Dict[
str, Tuple[Type, Optional[Callable[..., Any]]]
] = {}
constants: Dict[str, Any] = {}
for param, annotation in hints.items():
if annotation in injection_registry:
Expand Down

0 comments on commit 788054d

Please sign in to comment.