I'd like to use Python type hints in my Django project. What's the proper way to annotate get
/post
methods of a simple class-based view in Django?
I've searched the Django code itself but it doesn't seem to contain any type hints.
There exists this repository which may interest you: https://github.com/machinalis/mypy-django
which will allow you to use annotations like so:
def get(self, request: HttpRequest, question_id: str) -> HttpResponse:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With