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

remove overlapping slots from app.Sanic, fix broken slots inherit of HTTPResponse #2387

Merged
merged 3 commits into from
Feb 24, 2022

Conversation

ariebovenberg
Copy link
Contributor

@ariebovenberg ariebovenberg commented Jan 22, 2022

Summary

There are some __slots__-related problems in sanic:

$ slotscheck -m sanic -v
ERROR: 'sanic.app:Sanic' defines overlapping slots.
       - name (sanic.base.root:BaseSanic)
ERROR: 'sanic.response:HTTPResponse' has slots but superclass does not.
       - sanic.response:BaseHTTPResponse
  • Fixing the slot overlap saves a bit of wasted space
  • Fixing the broken slots inheritance ensures HTTPResponse won't get a __dict__ and saves a bit of memory in the process.

Questions

regarding tests: probably not needed. I discovered the slots issue with slotscheck, a tool I maintain. Of course, If you like, I can add it to tox/CI as I've done for instagram/LibCST and dry-python/returns.

@ariebovenberg ariebovenberg requested a review from a team as a code owner January 22, 2022 17:56
prryplatypus
prryplatypus previously approved these changes Jan 22, 2022
Copy link
Member

@prryplatypus prryplatypus left a comment

Choose a reason for hiding this comment

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

Changes lgtm

@codecov
Copy link

codecov bot commented Jan 22, 2022

Codecov Report

Merging #2387 (6f8581d) into main (d4fb44e) will increase coverage by 0.002%.
The diff coverage is 100.000%.

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #2387       +/-   ##
=============================================
+ Coverage   87.107%   87.110%   +0.002%     
=============================================
  Files           60        60               
  Lines         5003      5004        +1     
  Branches       905       905               
=============================================
+ Hits          4358      4359        +1     
  Misses         472       472               
  Partials       173       173               
Impacted Files Coverage Δ
sanic/app.py 89.668% <ø> (ø)
sanic/response.py 89.385% <100.000%> (+0.059%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4fb44e...6f8581d. Read the comment docs.

@ahopkins
Copy link
Member

Thanks. Can you add that to the GH actions pipeline?

@ariebovenberg
Copy link
Contributor Author

ariebovenberg commented Jan 23, 2022

@prryplatypus does the one test failure look at all familiar to you? In theory my change could have affected the cookies in HTTPResponse, but I doubt it would only show up on 3.7 in this way 🤔

@ahopkins
Copy link
Member

ahopkins commented Jan 23, 2022

Agreed. I've never seen that test be flappy, so it is suspicious, but I wouldn't worry about that yet. I'll take a look and see what's going on with it.

Thanks for your effort in reaching out and putting this together. We actually have a lot more slots usage coming around the corner in some refactors, and with all the nesting I appreciate your utility.

@ariebovenberg
Copy link
Contributor Author

@ahopkins awesome! Let me know if you have any ideas for features/improvements.

@ahopkins ahopkins merged commit 7523e87 into sanic-org:main Feb 24, 2022
@ariebovenberg ariebovenberg deleted the fix-slots branch February 24, 2022 18:07
ChihweiLHBird pushed a commit to ChihweiLHBird/sanic that referenced this pull request Jun 1, 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.

3 participants