GSoC proposal research - type hinting

99 views
Skip to first unread message

Kacper Szmigiel

unread,
Mar 27, 2020, 7:08:07 PM3/27/20
to Django developers (Contributions to Django itself)
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

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/).

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

Tom Forbes

unread,
Mar 27, 2020, 7:54:06 PM3/27/20
to django-d...@googlegroups.com
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:


--
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-develop...@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.

charettes

unread,
Mar 27, 2020, 8:09:36 PM3/27/20
to Django developers (Contributions to Django itself)
You might also be interested in this Django Enhancement Proposal to add type hints to Django


Cheers,
Simon

Kacper Szmigiel

unread,
Mar 28, 2020, 10:51:41 AM3/28/20
to Django developers (Contributions to Django itself)
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), 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) 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 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
To unsubscribe from this group and stop receiving emails from it, send an email to django-d...@googlegroups.com.

Carlton Gibson

unread,
Mar 28, 2020, 11:16:26 AM3/28/20
to django-d...@googlegroups.com
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)

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


To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@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.

Kacper Szmigiel

unread,
Mar 28, 2020, 12:19:41 PM3/28/20
to Django developers (Contributions to Django itself)
Hello,

I've sent emails to Mr Kurnikov and Mr Sobolev, Typed Django project maintainers. Looking forward to get an answer from them.

Kind regards,
Kacper
Kind Regards,

Carlton


Никита Соболев

unread,
Mar 30, 2020, 7:56:59 AM3/30/20
to Django developers (Contributions to Django itself)
Hi everyone,

I am one of the django-stubs core-devs (https://github.com/sobolevn).

I would love to mentor Kacper and help with anything django-stubs related.
You can count me in!

Best regards,
Nikita Sobolev

суббота, 28 марта 2020 г., 2:08:07 UTC+3 пользователь Kacper Szmigiel написал:

Carlton Gibson

unread,
Mar 30, 2020, 8:08:57 AM3/30/20
to django-d...@googlegroups.com
Hi Nikita. Thanks for the follow up. C.

--
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-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/b3c8ac9c-248f-41d7-9412-9276f476c775%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages