4 ms·
Django has quite a lot of "magic" as well. There is work being done on a mypy plugin to support this magic in addition to type stubs. It is already quite usable
by syastrov 8y ago
Django has quite a lot of "magic" as well. There is work being done on a mypy plugin to support this magic in addition to type stubs. It is already quite usable and supports type-checking many common patterns: https://github.com/mkurnikov/django-stubs https://github.com/mkurnikov/django-stubs
See also mypy's recent blog post on plugins (which are also used for supporting Python 3.7's dataclasses, which are quite dynamic as well): http://mypy-lang.blogspot.com/2019/03/extending-mypy-with-plugins.html http://mypy-lang.blogspot.com/2019/03/extending-mypy-with-pl...
- stefano 8y agoDjango and django rest framework make such a heavy use of metaclasses that I gave up on using mypy for a Python project. My code was littered with annotations and stubs and it still wasn't catching obvious type errors, and I had to fall back to use `Any` in way too many places. Couple that with the horrible typing syntax and the fact that mypy was slow, kept crashing with segfaults and often wouldn't even signal type errors on fully typed functions, and the result was a lot of effort for almost no gain. If I compare that experience to when I switched from JS to TypeScript, it's like night and day. TypeScript is designed to work well with development tools and already existing libraries, while Python's static types feels designed by someone who never worked with static types while completely ignoring code patterns used in existing libraries.