-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Support inheriting manager classes created via .from_queryset
#1699
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,7 +310,7 @@ | |
- case: handles_type_collision_with_from_queryset | ||
main: | | ||
from myapp.models import MyModel, FromQuerySet | ||
reveal_type(FromQuerySet) # N: Revealed type is "def [_T <: django.db.models.base.Model] () -> myapp.models.ManagerFromModelQuerySet[_T`1]" | ||
reveal_type(FromQuerySet) # N: Revealed type is "def () -> myapp.models.ManagerFromModelQuerySet[_T`1]" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, yeah, gotta look in to that. But I'm not so sure there should be any arguments here. It might be, if we implicitly copy the manager argument to the new subclass created. It's all a bit blurry, since it needs to align with the model argument of the queryset etc. |
||
reveal_type(MyModel.from_queryset) # N: Revealed type is "myapp.models.ManagerFromModelQuerySet[myapp.models.MyModel]" | ||
reveal_type(MyModel.as_manager) # N: Revealed type is "myapp.models.ManagerFromModelQuerySet[myapp.models.MyModel]" | ||
installed_apps: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this is a chain reaction of a bug that was revealed. Might be better to push it as a separate PR though.
The below change is the reason, in
mypy_django_plugin/transformers/managers.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, think I figured it out. The change there takes a more correct path. There's nothing generic on the related managers, their model arguments are already populated on parent class(es). It becomes more obvious when using
.get
and seeing what model is returned. So I'll add that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened #1701