4 ms·
My big question is django support. Django has a lot of magic that makes type checking more difficult than it should be. I'm not really expecting anything, eve
by ehutch79 2y ago
My big question is django support.
Django has a lot of magic that makes type checking more difficult than it should be.
I'm not really expecting anything, even just the speed bump will be nice.
- claytonjy 2y agois Django working towards using native types instead of all they stuff they invented before type hints existed?
- rtpg 2y agoI am not part of the DSF or anything but I can say with a good amount of confidence that the answer to this is “No”. Moving to a Pydantic-style model would be a whole different ballgame. Hell of a lot of work, and meanwhile we can’t even really get to “let’s have type hints in some of the Django infernals”. But! I do think someone who wants to have fun could try to build a type hint based Model subclass as a third party lib! There’s a looooot of stuff to resolve in that world but for any proposal like that the general vibe is “prove the feasibility with a third party package first”.
- c-fe 2y agoI think there is potential for a new python web framework with batteries included (like django) but using newer paradigms (typing, …). Fastapi itself is a nice concept but its a bit of a mess (the main author just keeps closing bug issues and adds somewhat useless things (just check the git commit log)), and also it requires db tooling (sqlalchemy) and other things
- IceWreck 2y agoYou should check out litestar It's essentially what you described and it's growing in popularity.
- c-fe 2y agoThanks, ill check it out!
- physicsguy 2y agoIt's really nothing like Django, which is a full stack development framework. This is more akin to Django REST Framework or Django Ninja which are REST API frameworks that sit on top of Django.
- rtpg 2y agoI kind of agree, though at least Django with type stubs gets me 95% of the way there. At the end of the day I end up writing a service layer over everything so I'm not super bugged by most of this. But it's busywork when first starting up a project.
- physicsguy 2y agoIt's also super clunky if you get into certain advanced things because it's built on top of Starlette and piggybacks off much of that. Want to adjust how many background threads you want running? Oh wait, you can't, it's a Starlette setting that's not really exposed.
- physicsguy 2y agoDjango's magic is that you can set various class variables as either a value or a method. So typing that becomes incredibly hard, everything is effectively Union typed.
- adsharma 2y agoIt should be much easier to type check this: https://adsharma.github.io/fquery-meets-sqlmodel/ https://adsharma.github.io/fquery-meets-sqlmodel/ https://github.com/adsharma/fastapi-shopping/blob/main/models.py https://github.com/adsharma/fastapi-shopping/blob/main/model...
- aleksanb 2y agoAgree with this. All type checkers other than mypy (e.g. pyright, intellij) have ignored the level of plugin support necessary to make django work well, and so they are DOA for any large existing django codebase. Unless ruff decides to support such a dynamic interface as mypy's, it'll fare no better. We use mypy with [django-stubs](https://github.com/typeddjango/django-stubs https://github.com/typeddjango/django-stubs) which works ok nowadays. There was an effort to create a typechecking plugin interface for dataclass-style transforms for python type checkers, but what was merged was so lacking that one couldn't even make something close to django-stubs with it.
- aitchnyu 2y agoWill django-stubs work with other typecheckers? Tangential, I'm waiting for Edgedb to become next SQL so all ORM moats like Django's are drained. https://github.com/typeddjango/django-stubs https://github.com/typeddjango/django-stubs