sbdchd / django-types

:doughnut: Type stubs for Django
MIT License
188 stars 62 forks source link

Prototype of generating type annotations automatically #158

Open syastrov opened 1 year ago

syastrov commented 1 year ago

When using django-types, you need to add a lot of boilerplate in order to fill in the attributes that Django would normally add to your models.

I thought I would share an experiment with you that I made in this direction about a year ago, which will automatically generate this boilerplate using libcst's codemod feature.

A very rough proof-of-concept is available at: https://github.com/syastrov/django_type_gen/

Right now, it will add to your models:

I don't have the time or interest to continue working on this, but if anyone would like to experiment with it, or fork it into something more production-ready, then feel free to do so.