Skip to content

Add deprecation warning to BaseHTTPMiddleware#1679

Closed
adriangb wants to merge 5 commits intoKludex:masterfrom
adriangb:deprecate-basehttpmiddleware
Closed

Add deprecation warning to BaseHTTPMiddleware#1679
adriangb wants to merge 5 commits intoKludex:masterfrom
adriangb:deprecate-basehttpmiddleware

Conversation

@adriangb
Copy link
Contributor

@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
Contributor 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
Contributor 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

Comments