-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow route decorators to stack up again #1764
Conversation
…re inspection crash Fix sanic-org#1742
Codecov Report
@@ Coverage Diff @@
## master #1764 +/- ##
=======================================
Coverage 92.18% 92.18%
=======================================
Files 22 22
Lines 2240 2240
Branches 419 419
=======================================
Hits 2065 2065
Misses 136 136
Partials 39 39
Continue to review full report at Codecov.
|
sanic/app.py
Outdated
@@ -194,6 +194,10 @@ def route( | |||
strict_slashes = self.strict_slashes | |||
|
|||
def response(handler): | |||
if isinstance(handler, (tuple, list)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some comments here for explaining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment explaining it
sanic/app.py
Outdated
@@ -205,7 +209,7 @@ def response(handler): | |||
if stream: | |||
handler.is_stream = stream | |||
|
|||
routes = self.router.add( | |||
new_routes = self.router.add( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_routes seems a little bit weird.. maybe we can just extend in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to inplace extend.
Add test for double-stacked websocket decorator remove introduction of new variable in route wrapper, extend routes in-place. Add explanation of why a handler will be a tuple in the case of a double-stacked route decorator
Pushed some changes, added the same fix for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
Includes commits from: sanic-org#1762 sanic-org#1764 sanic-org#1789
* Cherry pick PRs to backport to 19.12LTS Includes commits from: #1762 #1764 #1789 * Fix type annotation issue; run black and isort * Update Makefile Co-authored-by: Ashley Sommer <[email protected]>
A PR:#1690 broke the ability to stack route decorators.
This PR will allow again route decorators to stack up without causing a function signature inspection crash
Fix #1742
Also adds a test to detect this breakage, and verify its now fixed, and to ensure it stays fixed in the future.