Type Check your Django app
[EuroPython 2021 - Talk - 2021-07-28 - Ni]
[Online]
By Kracekumar
Python 3 introduced type hints and it's optional to use. The decision to use the type-hints in the python community is in two different camps - Embrace and skeptical.
Adding type-hints has practical problems. One such example is the working of type-checker, mypy, and CPython interpreter. mypy behaves like a statically typed language (strict with type declaration and modification) whereas Python run-time is lenient.
Example
a: int = 23
a = 'Django'
Mypy will complain about the above code whereas Python run-time will not complain.
In this talk, I'll cover the following topics:
how to add type-hints to Django project - views, models, and queryset.
Tools to help to add type-hints.
Adding type-hints to user-defined code.
Current limitation of the type-hints.
Tuning mypy to suit your needs - strict and lenient checking.
All the example code snippets will run on Python 3.9.4+.
References:
Type Hints: https://docs.python.org/3/library/typ...
Mypy - http://mypy-lang.org/
Django: https://www.djangoproject.com/
Django Stubs - https://github.com/TypedDjango/django...
Django Restframeowrk - https://www.django-rest-framework.org/
Django Restframework stubs - https://github.com/typeddjango/django...
License: This video is licensed under the CC BY-NC-SA 4.0 license: https://creativecommons.org/licenses/...
Please see our speaker release agreement for details: https://ep2021.europython.eu/events/s...
Смотрите видео Kracekumar - Type Check your Django app онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь EuroPython Conference 27 Сентябрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 835 раз и оно понравилось 15 людям.