Re: PEP 484 type hinting in Django
Hi, I'm the original creator of https://github.com/typeddjango/django-stubs. I guess it's my duty to start writing a DEP, so here is some preliminary thoughts/questions to gather early feedback: Main discussion points: 1. There's two ways to make Django compatible with type hinting and PEP484: - Separate repo with `.pyi` files and mypy plugin (how it's done currently with django-stubs). Pros: - no backwards-incompatible changes. Only required change from Django is adding the `__class_getitem__` method to `QuerySet` https://docs.python.org/3/reference/datamodel.html#object.__class_getitem__ to support generic parameters in 3.7+ - could be released separately - no type hints code clutter Cons: - (as of now) there's no way to use type hints to typecheck Django codebase itself. I think the official answer to that is to use retype tool https://github.com/ambv/retype (https://github.com/python/mypy/issues/5028#issuecomment-495942769), but so far I didn't have any positive experience with that - Inline type hints in the codebase. Pros/Cons are exact reverse. 2. Whether to use Django own machinery to extract info for the models/fields, or not. Current implementation of django-stubs utilises `Apps` registry of Django itself to extract some data for models/fields. So, basically it executes codes first, then performs static analysis of it. Pros: - lots of models/fields introspection could be extracted from the `_meta` API => lower maintenance burden, more accurate types. In the pre-1.0.0 versions of the django-stubs it was all done statically, and it was very painful to implement. Cons: - mypy daemon mode (dmypy) is broken. It could be fixed, but it requires some changes to mypy itself, and as `django.setup()` could not run incrementally, it's not clear whether dmypy would provide any real benefits over plain incremental mode. - there could be some side effects in `django.setup()` invocation - cannot typecheck invalid code - slower to execute Carlton, is it possible to move discussion to Github somehow? On Wednesday, December 12, 2018 at 7:06:16 PM UTC+3, Carlton Gibson wrote: > > Hi all. > > > Where are we with this Type Hinting work? > > > I just closed https://code.djangoproject.com/ticket/30019 as needsinfo > pointing back to this thread. > > > As far as I can see: > > * There's keenness for this. > * There's a number of people who are prepared to put in the effort. > * But we just need a strategy. > > It looks then like a coordination problem. Do we just need to get said > people in a (virtual) room...? > > Maybe one of you — anyone — opening a DEP to begin the conversation would > be enough.. > (That's just an idea.) > > Looking here: > https://github.com/django/deps/blob/master/final/0001-dep-process.rst#dep-submission-workflow > I'd guess "Forming the Team" is relevant. > > Happy to help if I can. > (I recall Frank mentioned it no too long ago...) > > 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/c659f5aa-0ce5-4e65-a983-e98f3f6dfb3d%40googlegroups.com.
Re: Fellow Reports - August 2019
Week ending August 25, 2019. *Triaged:* https://code.djangoproject.com/ticket/30715 - ArrayField lookups crash on ArrayAgg() over AutoFields. (accepted) https://code.djangoproject.com/ticket/29043 - test --keepdb says "Using existing test database" even if it's run for the first time. (wontfix) https://code.djangoproject.com/ticket/30716 - ArrayContains does not call get_db_prep_value method for base field. (duplicate) https://code.djangoproject.com/ticket/30721 - Implicit related objects filtration because of the set Manager. (invalid) https://code.djangoproject.com/ticket/30724 - Please create a hyperlink to easy pickings in README.rst file. (wontfix) https://code.djangoproject.com/ticket/30718 - blocktrans is crashing when using percent signs when no variables were supplied. (wontfix) https://code.djangoproject.com/ticket/30717 - Session model has a useless LIKE index. (wontfix) https://code.djangoproject.com/ticket/30720 - Allow specifying multiple domains for makemessages command. (wontfix) https://code.djangoproject.com/ticket/30726 - 'week' queryset returns no objects (needsinfo) *Reviewed/committed:* https://github.com/django/django/pull/11680 - Fixed #29260 -- Skipped an UPDATE when adding a model instance with primary key that has a default. https://github.com/django/django/pull/10680 - Fixed #29979, Refs #17337 -- Extracted AutoField field logic into a mixin and refactored AutoFields. https://github.com/django/django/pull/11594 - Fixed #21039 -- Added AddIndexConcurrently/RemoveIndexConcurrently operations for PostgreSQL. https://github.com/django/django/pull/11679 - Fixed #30712 -- Allowed BLOB/TEXT defaults on MySQL 8.0.13+. https://github.com/django/django/pull/11412 - Fixed #30507 -- Updated admin's jQuery to 3.4.1. https://github.com/django/django/pull/11681 - Fixed #29955 -- Added support for distance expression to the dwithin lookup. *Authored:* https://github.com/django/django/pull/11685 - Fixed broken links and redirects to OGR library in docs. https://github.com/django/django/pull/11699 - Fixed #30715 -- Fixed crash of ArrayField lookups on ArrayAgg annotations over AutoField. https://github.com/django/django/pull/11704 - Refs #30591 -- Fixed introspection of check and unique column constraints on MariaDB. Best regards, Mariusz -- 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/511b9679-384a-4dfc-a610-d300d7bfbe57%40googlegroups.com.
Re: PEP 484 type hinting in Django
On Monday, 26 August 2019 14:05:19 UTC+2, Maxim Kurnikov wrote: > > Carlton, is it possible to move discussion to Github somehow? > Drafting a DEP begins by making a PR against the drafts folder in the DEPs repo. I guess that could be a WIP PR, if felt beneficial/necessary. -- 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/05bff11a-4057-4c45-97a9-447462da9cbc%40googlegroups.com.