Hi Kacper. The question of type hints in Django itself is currently under consideration (the draft DEP plus this PR: https://github.com/django/django/pull/12405 <https://github.com/django/django/pull/12405>)
If it weren’t for the current covid-19 situation we would likely already have a more concrete answer for you. I’d suggest the best way forward is via django-stubs. This isn’t really “in Django” but it’s the sort of thing that if the maintainers would agree to mentor, then I’d (personally) think it would be reasonable to consider an application under the Django Org. (That’s out of the norm but…) I hope that helps. Kind Regards, Carlton > On 28 Mar 2020, at 15:51, Kacper Szmigiel <szmigielkac...@gmail.com> wrote: > > Thank you for your response! :) > > I was thinking to start with adding type hints to some basic Django packages, > i.e. django.utils, and then move on with other ones, depending on how much > time I have left. > > But, I'm not sure what way to do this is more reasonable. I wrote an email to > Daniel Moisset (@dmoisset at Github) who used to work on adding type hints to > Django. He suggested to use Mypy stubgen in order to provide .pyi files and > distribute them as PEP 561 package (as part of the django package, or an > officially supported package). In fact, there is a big existing project od > adding stubs to Django (https://github.com/typeddjango/django-stubs > <https://github.com/typeddjango/django-stubs>), and it's being discussed as > DEP 65. This seems to be quite nice solution, but a few months ago Carlton > Gibson described it as "work around" > (https://github.com/django/deps/pull/65#issuecomment-539505849 > <https://github.com/django/deps/pull/65#issuecomment-539505849>) so I hope he > will read this email and give me some feedback on this one. As long as > contributing to https://github.com/typeddjango > <https://github.com/typeddjango> could be considered as contributing to > Django itself, I could reach Maksim Kurnikov (@mkurnikov at Github) to ask > what needs to be done and include it in my proposal. > > So, the other option is to add type hints by integrating the annotations in > the upstream codebase. That would make it easier to maintain, and can have > some benefits from the documentation standpoint. Then adding some integration > of type checking to Django's CI; this would ensure annotations are kept up to > date. I would love to try doing this as my GSoC contribution, but before I > send you my proposal I want to know what you guys think about this. > > Ofcourse I'm aware that adding type hints to such big project as Django is > not a "side project for the weekends", but according to GSoC rules it's not > crucial to get one's commits merged to the project by the end of program. As > a student who's doing well at Uni I'm willing to spend much of my free time > on adding type hints to Django. > > Kindest regards, > Kacper > > On Saturday, March 28, 2020 at 12:54:06 AM UTC+1, Tom Forbes wrote: > As an avid user of type hints I think it would be fantastic. I believe with > the upcoming release we only target Python versions that support type > hinting, which was one of the issues holding us back before. > > I would recommend choosing a specific part of Django and investigating adding > type hints. Django is quite big, and I think most of the value for type hints > comes from user-facing components rather than some internals. > > I would start looking at: > 1. The ORM > 2. Class based views > 3. The Request/Response objects > > And see if you think it’s viable to add a decent amount of type hints to any > of these. There is some “magic” in each of these which might be hard to > express with type hints, but it would be valuable to know how far we could > get. > > Tom > >> On 27 Mar 2020, at 23:07, Kacper Szmigiel <szmigie...@gmail.com <>> wrote: >> >> >> Hello everyone! >> >> My name is Kacper, I'm 22 y.o. CS student from Lodz, Poland. I've started >> researching some nice feature for my GSoC proposal, and I have a few >> questions to you, dear Community :) >> Unfortunately, due to this whole mess caused by covid-19 I had like no time >> to sink into Django codebase and figure some things out by myself (none of >> polish Universities were ready to switch to e-learning). I have a few years >> of experience in using Django for my commercial projects, but I had no >> occasion to contribute to the framework yet. >> >> What I would like to implement is type hinting, as suggested here: >> https://code.djangoproject.com/ticket/29299 >> <https://code.djangoproject.com/ticket/29299> >> >> So, my first question is: what do you think about this one? Does it make >> sense at all? I suppose such feature could be really useful for many of >> developers >> (https://www.willmcgugan.com/blog/tech/post/adding-type-hints-to-the-django-orm/ >> >> <https://www.willmcgugan.com/blog/tech/post/adding-type-hints-to-the-django-orm/>). >> >> As I mentioned, I had no time to read the code and understand how Django >> works. Do you have any tips on where should I start my technical research in >> reference to this feature? I know I have not much time to prepare my >> proposal, but I will do my best during this weekend and send it to get some >> feedback. >> >> Thanks in advance, any tips and tricks welcome! >> >> Kindest regards, >> Kacper Szmigiel >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers (Contributions to Django itself)" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-d...@googlegroups.com <>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-developers/61592cd2-87b5-4d6b-a2f8-52a3dbf3fa21%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-developers/61592cd2-87b5-4d6b-a2f8-52a3dbf3fa21%40googlegroups.com?utm_medium=email&utm_source=footer>. > > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com > <mailto:django-developers+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/54622230-63ae-413e-8931-9fa1b0432252%40googlegroups.com > > <https://groups.google.com/d/msgid/django-developers/54622230-63ae-413e-8931-9fa1b0432252%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/98530DEB-2DA6-4CD5-986E-CEE055A4600F%40gmail.com.