typeshed stubs for mypy

193 views
Skip to first unread message

Pradip Caulagi

unread,
Apr 20, 2016, 7:28:25 PM4/20/16
to django-d...@googlegroups.com
Hello,

Is there any plans to add type annotations to Django itself? Or to
provide typeshed stubs so that we can run mypy on django projects?

Thanks,
Pradip

Tim Graham

unread,
Apr 20, 2016, 8:20:44 PM4/20/16
to Django developers (Contributions to Django itself)
My understanding is that adding type annotations must wait until we drop support for Python 2 which will happen after we cut the stable/1.11.x branch in January 2017.

Florian Apolloner

unread,
Apr 21, 2016, 5:27:00 AM4/21/16
to Django developers (Contributions to Django itself)
stub files would do it too, but all in all it seems much work for not much gain.

Anssi Kääriäinen

unread,
Apr 21, 2016, 6:26:44 AM4/21/16
to django-d...@googlegroups.com
I think we can use type annotations in comments, and I do think this
could be useful in some cases as a hint to autocomplete systems in
IDEs.

What I'm afraid is that if we add annotations somewhere, we'll have
really hard time determining when to stop when requests for more type
hints arrive. So, unless we have easy to follow rules for when to
reject type hints, I'm with Florian - too much work for little gain.
(Or in other words, it is really easy to follow a rule where we reject
type hints always).

I've tested mypy a little, and while it might be really useful for
larger Django projetcts, it isn't there yet.

- Anssi
> --
> 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 post to this group, send email to django-d...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/a4dc54e9-52a4-46ce-86a7-1b8eccfac10a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Pradip Caulagi

unread,
Apr 21, 2016, 6:34:38 AM4/21/16
to django-d...@googlegroups.com
On 21/04/16 11:26, Florian Apolloner wrote:
> stub files would do it too, but all in all it seems much work for not
> much gain.

I created some stub files here -
https://github.com/caulagi/django-mypy/tree/master/stubs/django. It is
not complete, but it is working for my toy example.

I used stubgen to create the files but there are some places where
stubgen gets it wrong. Should I post the examples here? Maybe in some
places we can tidy the Django code a bit to help stubgen?
Reply all
Reply to author
Forward
0 new messages