-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Python 3.11, support new http.HTTPMethod enum in action and view #8995
Comments
If you're able to add tests which confirm that DRF doesn't experience unexpected behavior when the enums are used instead of the strings (so new tests, don't just change existing tests) then I would be willing to review those. At that point we should be able to update the type stubs to reflect that as supported behavior. |
@kevin-brown Do you think that test I have drafted here is enough? ![]() |
that would be a good start |
@auvipy Do you think some other changes are needed? Code below passes which I think proofs that everything below line 146 on image above behaves same for from http import HTTPMethod
assert isinstance(HTTPMethod.POST.lower(), str) |
Just a heads-up, we are using this Side note: for Thanks for looking into it @pavelkraleu |
Thank you for the confirmation @sshishov, I will make this change into final PR 💪 |
@auvipy Could you look into it please? 👆 |
thanks for the test and documentation update. |
Bug report
When using python 3.11, instead of hardcoding HTTP verbs, now we can use official enum:
HTTPMethod
as well asHTTPStatus
for statusesWhat's wrong
We would like to use it in
decorators.action(methods=[HTTPMethod.POST])
for instance.Currently it does not work and produce the following error (with
djangorestframework-stubs
package):How is that should be
No
mypy
error should be reportedSystem information
python
version: 3.11django
version: 3.2.18mypy
version: 1.2.0django-stubs
version: 1.16.0djangorestframework-stubs
version: 1.10.0Original issue:
The issue was originally reported against the stub project, but recommended to move the issue/discussion over here: typeddjango/djangorestframework-stubs#396
The text was updated successfully, but these errors were encountered: