Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified the way before/teardown functions #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/quart_injector/scope.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
"""
Request :class:`~injector.Scope`.
"""

import typing
Copy link
Member

@danielknell danielknell Jul 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import typing
"""
Request :class:`~injector.Scope`.
"""
import typing

why remove the comment and spacing? this will upset the linters.


import injector
import quart
import werkzeug.local
Expand Down Expand Up @@ -69,8 +64,8 @@ async def before_func() -> None:
async def teardown_func(_: BaseException | None) -> None:
container.get(scope_cls).pop()

app.before_request_funcs[None].insert(0, before_func)
app.before_websocket_funcs[None].insert(0, before_func)
app.before_request_funcs[None] = [(before_func, None)] + app.before_request_funcs[None]
app.before_websocket_funcs[None] = [(before_func, None)] + app.before_websocket_funcs[None]

app.teardown_request_funcs[None].insert(0, teardown_func)
app.teardown_websocket_funcs[None].insert(0, teardown_func)
app.teardown_request_funcs[None] = [(teardown_func, None)] + app.teardown_request_funcs[None]
app.teardown_websocket_funcs[None] = [(teardown_func, None)] + app.teardown_websocket_funcs[None]