-
Notifications
You must be signed in to change notification settings - Fork 27
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
♻️ Uniform naming of http status codes #5323
♻️ Uniform naming of http status codes #5323
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5323 +/- ##
========================================
- Coverage 87.3% 87.1% -0.2%
========================================
Files 1320 1321 +1
Lines 54063 54152 +89
Branches 1172 1172
========================================
+ Hits 47201 47219 +18
- Misses 6612 6683 +71
Partials 250 250
Flags with carried forward coverage won't be shown. Click here to find out more.
|
27142de
to
410ad70
Compare
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.
Very cool. Thanks a lot!
fc7c062
to
c2cb026
Compare
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.
🎉 very nice!
5966eed
to
1e577fa
Compare
1e577fa
to
09be066
Compare
|
What do these changes do?
I would like to propose some basic conventions and techniques to increase robustness of error handling as well as consistency across service interfaces (regardless whether they are aiohttp or fastapi-based).
Those will be a set of simple concepts but very "noisy" changes. Therefore, I will do it in three different PRs for clarity and to encourage critics/discussion:
aiohttp
. This approach is based on fastapi/starlette exception handling concept extended to automatically document additional responses for each entrypoint.This first PR focuses on using a consistent naming of status codes throughout the entire codebase. Out of the many the many possible variants available:
404
as a raw integeraiohttp.web.HTTPNotFound.status_code
http.HTTPNotFound
ashttp.HttpStatus
which is anIntEnum
httpx.codes.NOT_FOUND
ashttpx.codes
which is anIntEnum
fastapi.status.HTTP_404_NOT_FOUND
asint
I find the latter the most readable since I can easily match both number and name (not sure about you, but I always mix up codes). Moreover conversion to any of the
IntEnum
's above is straighforward if needed. The only inconvenient is that it requires installation ofstarlette
. But fear no more 🦸, this PR introduces the same constants inservicelib.aiohttp.status
module analogous tofastapi.status
but foraiohttp
-based servicesRelated issue/s
How to test
Dev Checklist
DevOps Checklist
None