-
-
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
fix?: recursion error on Sanic subclass initialisation #2072
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2072 +/- ##
=============================================
- Coverage 92.200% 92.184% -0.016%
=============================================
Files 38 38
Lines 3487 3480 -7
Branches 584 582 -2
=============================================
- Hits 3215 3208 -7
Misses 184 184
Partials 88 88
Continue to review full report at Codecov.
|
Would also add a test case for this if subclassing |
@artcg Thanks. Can you add a test? You can drop it at the end of |
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.
This works and makes sense. Nice catch.
But, I want to play with this a little more because I think it might not yet cover all the edge cases.
Let's add the test, and I will swing back on this tomorrow with some more thoughts.
sanic/base.py
Outdated
bases = [ | ||
b for base in type(self).__bases__ for b in base.__bases__ | ||
] | ||
bases = BaseSanic.__bases__ | ||
|
||
for base in bases: |
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.
Since we no longer need the comprehension, no need to have bases
as a variable.
for base in BaseSanic.__bases__:
Is it an optimisation not just to define |
I am pushing a change directly to this branch to remove the metaclass. |
Fixes #2073
Needs someone to take a look at it, not super familiar with
__new__
,but it seems to fix the error and work as expected