-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Fixed #31223 -- Added __class_getitem__() to Manager and QuerySet. #12405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@mkurnikov please review this PR from your side as well! 👍 |
Hi. Thanks for opening this. I'm going to ask the Technical Board to make a decision on this topic. |
I just want to point out that previous version of this patch adds |
@felixxm Would you like to see tests like
Is that an argument against this implementation? To me that's a very strange argument, and it sounds like "due to not knowing what will happen in the future, we should do nothing today". In the discussion on the DEP there seemed to be consensus that this is an insignificant change that will unlock very valuable features for users of static typing in Django. I think it would be very sad if Django entirely turns its back on static typing.
This is a valid concern, although @mkurnikov did mention "maybe also other classes" in his proposal in the DEP discussion. Maybe @sobolevn and/or @mkurnikov could shed some light on which classes critically needs subscriptability, would it be a good idea to add docstrings to the |
That's how I made a decision about which classes need to have So users can write I have omitted Searching for |
Generics on fields used for If there's an opposition to this change, one could always just give up on
It's plugin implementation detail of sorts, and could be reimplemented into hard-coding of lookups with their corresponding value types
We could also go with
It's cleaner to have it right in stubs, and allow to smoothly create new |
Oh, and there's a PR to CPython open right now, python/cpython#18239, which adds a number of |
Agreed. +1.
The API of
I understand the syntax. Doesn't feel critical for this first round. -0. |
@davidfstr Just to be clear: this PR only introduces |
Hi all. I write up something for the technical board next week now. Can I ask you to agree the minimal form of this PR (and adjust the actual changes if needed) so that it's canonical when I ask them to look? |
@sobolevn |
@mkurnikov sure thing! |
@sobolevn |
Tests are very hard to navigate, so I have ended up adding two simple cases to places where inheritance is checked. |
@sobolevn Can you check new tests locally before pushing? (gentle request) |
No, sorry. My current device does not allow that. I can run tests locally in more than a week. I use Github web editor right now. |
Just curious -- is there anything holding this up? |
I also eagerly wish for this fix! It will open the door to the world without no ugly ”# type: ignore” in my codebase. 😅 |
It's under consideration by the Technical Board. The earliest it would possibly be released is for Django 3.1, so there is no urgency. |
There is no "urgency" but the sooner Django project's position is stated, the sooner we can begin discussing additional type annotations that might reach Django 3.1. |
OK, thank you for your patience everybody. Statement from the Technical Board is here: We will be moving forward with this PR for Django 3.1. |
15cd634
to
c3c44df
Compare
django/django#12405 (comment) QuerySet and BaseManager already have __class_getitem__, starting from Django 3.1
django/django#12405 (comment) QuerySet and BaseManager already have __class_getitem__, starting from Django 3.1
Ticket: https://code.djangoproject.com/ticket/31223#ticket
Related:
django-stubs repo: https://github.com/typeddjango/django-stubs