Skip to content

Python 3.11, support new http.HTTPMethod enum in action and view #396

@sshishov

Description

@sshishov

Bug report

When using python 3.11, instead of hardcoding HTTP verbs, now we can use official enum: HTTPMethod as well as HTTPStatus for statuses

What'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:

error: List item 0 has incompatible type "Literal[HTTPMethod.POST]"; expected "Literal['GET', 'POST', 'DELETE', 'PUT', 'PATCH', 'TRACE', 'HEAD', 'OPTIONS', 'get', 'post', 'delete', 'put', 'patch', 'trace', 'head', 'options']"  [list-item]

How is that should be

No mypy error should be reported

System information

  • OS: MacOS / Debian (docker)
  • python version: 3.11
  • django version: 3.2.18
  • mypy version: 1.2.0
  • django-stubs version: 1.16.0
  • djangorestframework-stubs version: 1.10.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions