-
-
Notifications
You must be signed in to change notification settings - Fork 857
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
Single consistent name for status codes #1088
Conversation
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.
Yup, makes sense 👍
There are some usages in the wild 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.
Sure, httpx.codes is the documented one for now, but...
I personally feel like httpx.StatusCode
would be a less surprising and a more natural option...
I initially thought httpx.codes
meant that we refactored things to have a codes.py
module, with plain functions as well as a .__call__()
function - but then realized that the latter is probably not valid Python?
Anyway, I mean that httpx.codes
looks like a module access, while it actually refers to a standard enum. In my experience enums are generally named after the singular of what they refer to, hence httpx.StatusCode
?
So that would give us:
httpx.StatusCode.OK
httpx.StatusCode(200)
httpx.StatusCode.is_client_error(400)
I'm not absolute on either option though and pretty much bikeshedding at this point... The important bit is that we should have a single status codes enum, that I agree. :) Minimizing breaking changes on |
I've updated this with a more gentle deprecation of |
For consideration.
Currently we're exposing both
httpx.StatusCodes
andhttpx.codes
for working with status codes.We're only documenting
httpx.codes
, and we probably only want a single canonical name here, right?The documentation could also do with being expanded, at the very least in the API section.
Usages are like...