-
-
Notifications
You must be signed in to change notification settings - Fork 496
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
What's wrong
class SubscriptionPromotion(BasePromotion):
objects = SubscriptionPromotionQuerySet.as_manager()
error: Cannot override class variable (previously declared on base class "BasePromotion") with instance variable [misc]
error: Incompatible types in assignment (expression has type "Manager[BasePromotion]", base class "BasePromotion" defined the type as "ManagerFromPromotionQuerySet[BasePromotion]") [assignment]
How is that should be
The second error was there before but the first one is newly introduced in 4.2.4. As suggested in #1712 (comment), this code should be explicitly annotated. However, the problem is that if I annotate it like this:
objects: ClassVar[models.Manager[BasePromotion]
Then all custom attributes defined in the SubscriptionPromotionQuerySet won't be available in SubscriptionPromotion.objects
.
In other words, before django-stubs-ext used to construct on the fly the return type of QuerySet.as_manager
as a mix of Manager and custom methods but now I can't use it because I have to add explicit annotations, and there is no explicit annotation for this dynamically constructed type.
System information
- OS: linux
python
version:3.8
django
version: 4.2.4mypy
version: 1.5.1django-stubs
version: 4.2.4django-stubs-ext
version: 4.2.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working