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

Add deprecation warning to BaseHTTPMiddleware #1679

Closed
wants to merge 5 commits into from

Conversation

adriangb
Copy link
Member

@adriangb adriangb commented Jun 9, 2022

Implements #1678

@adriangb adriangb requested a review from Kludex June 9, 2022 20:28
@adriangb adriangb marked this pull request as draft June 15, 2022 05:37
@adriangb
Copy link
Member Author

Idea: if/when #1691 gets merged, we could do something like this (a bit cleaner obviously) so that users can copy-paste the fixed code to migrate:

import inspect

async def dispatch(request, call_next):
    await call_next(request)

def replace(dispatch):
    req_name, call_next_name = inspect.signature(dispatch).parameters.keys()
    source = inspect.getsource(dispatch)
    pattern = f"await {call_next_name}({req_name})"
    source = source.replace(f", {call_next_name}", "")
    new_source = source.replace(pattern, f"yield")
    print(new_source)

This can be included as part of the warning.
Not sure it's a great idea, but it's possible!

@adriangb
Copy link
Member Author

adriangb commented Jul 2, 2022

Closing this for now, not enough traction for this to happen anytime soon if ever

@adriangb adriangb closed this Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant