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
Simplify code of http_exception_handler
#5323
Conversation
Looking to `JSONResponse.__init__()` function, you can see that `headers` parameter is `None` by default, so it doesn't matter do we pass it here as `None` or do not pass at all. That's why we can safely remove this if-else expression and slightly simplify the code
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5323 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 540 538 -2
Lines 13969 13869 -100
==========================================
- Hits 13969 13869 -100
☔ View full report in Codecov by Sentry. |
📝 Docs preview for commit e9fd538 at: https://630e16343174f0607e6e27a3--fastapi.netlify.app |
📝 Docs preview for commit 3cfb1c3 at: https://631224982328a715fc06019d--fastapi.netlify.app |
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.
LGTM
LGTM but you probably can close it, it doesn't make sense anymore with the latest implementation of fastapi/fastapi/exception_handlers.py Lines 10 to 16 in 97f04ab
|
Thanks @PipeKnight! 🍰 And thanks everyone for the reviews and comments. It seems this was covered in a recent change, so I'll close this one. But thanks for the effort! ☕ |
Looking to
JSONResponse.__init__()
function, you can see thatheaders
parameter isNone
by default, so it doesn't matter do we pass it here asNone
or do not pass at all. That's why we can safely remove this if-else expression and slightly simplify the code