This PR makes a series of improvements to methods and properties of BaseManager and Manager:
BaseManager.deconstruct(): Most of the values in the return tuple can be null (see implementation)
BaseManager.from_queryset(): queryset_class is now generic, and the return type is made more specific (see implementation). This allows code like this to receive type information:
class CustomQuerySet(models.QuerySet["User"]):
...
class CustomManager(models.Manager.from_queryset(CustomQuerySet)):
def get_queryset(self):
qs = super().get_queryset() # ← Type checker knows get_queryset exists in the parent
user = qs.get() # ← Inferred type is "User"
return qs
BaseManager._get_queryset_methods(): Return dictionary values are functions (see implementation).
Manager._queryset_class: This property is assigned dynamically by BaseManager.from_queryset() (see implementation)
This PR makes a series of improvements to methods and properties of
BaseManager
andManager
:BaseManager.deconstruct()
: Most of the values in the return tuple can be null (see implementation)BaseManager.from_queryset()
:queryset_class
is now generic, and the return type is made more specific (see implementation). This allows code like this to receive type information:BaseManager._get_queryset_methods()
: Return dictionary values are functions (see implementation).Manager._queryset_class
: This property is assigned dynamically byBaseManager.from_queryset()
(see implementation)