Hi all. The question of using typing, or type hints, or type checking, in (or with) Django has come up several times. Whether we would add inline annotations, or use stub files, or what?
Most recently, this resulted in a draft DEP[0] to try and formalize the situation, followed by a PR[1] adding the `__class_getitem__()` to `QuerySet` and `Manager` that would ease the job of working on external stub files. [0]: https://github.com/django/deps/pull/65 [1]: https://github.com/django/django/pull/12405 There was extended discussion on both the draft DEP and the PR, which I recommend for anyone particularly interested in this topic. Given the lack of consensus on the issue, I asked the Technical Board to review the situation in full, and make a judgement on the way forward. Having been charged to do so, I here post the Technical Board's response: It is the view of the Django Technical Board that inline type annotations should not be added to Django at the current time. A brief idea of the considerations are these: * Typing in Python is still young and in flux. As such it is not sufficiently stable. * There are competing technologies, which may settle with time, but at this moment Django is not in a position to favor any one. * Writing correct type hints is hard. And reviewing them to ensure correctness isn't any easier. Even ostensibly simple examples often have hidden complexity. Thus the barrier to contribution and maintenance is raised. * Due to the very dynamic nature of much of Django, example type hints very often do not pass an acceptable standard for readability. This might be manageable with extensive aliasing but that effort itself involves further overhead. The Technical Board acknowledges the type checking is gaining ground in Python and that many users are keen to employ it. The django-stubs project is notable for the impressive work that it has done adding external stub files for Django. It is the view of the Technical Board that non-invasive changes in order to assist the work of external projects such as django-stubs are acceptable. In particular, this means that the pull request to add the `__class_getitem__()` method to QuerySet and Manager should be accepted. A small number of further changes of a similar nature may be accepted, but the Technical Board wishes to emphasise that where possible typing should be done in external stub files, and that the barrier for further inline changes will be high. We're looking forward to seeing how typing evolves in Python and re-evaluating Django's position as things change. On the basis of this, Mariusz and I (in our role as Mergers) shall review and merge the PR #12405 in time for Django 3.1. (We will also close the draft DEP, and any related tickets, over the coming period.) Personally, I wish to thank everybody who has participated in the discussion to bring us to this point. Kind Regards, Carlton -- 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/47283a09-7899-4449-8792-e31b5c779c4e%40googlegroups.com.