-
-
Couldn't load subscription status.
- Fork 131
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
What's wrong
The RelatedField.get_queryset method is missing a None typing.
The implementation:
def get_queryset(self):
queryset = self.queryset
if isinstance(queryset, (QuerySet, Manager)):
# Ensure queryset is re-evaluated whenever used.
# Note that actually a `Manager` class may also be used as the
# queryset argument. This occurs on ModelSerializer fields,
# as it allows us to generate a more expressive 'repr' output
# for the field.
# Eg: 'MyRelationship(queryset=ExampleModel.objects.all())'
queryset = queryset.all()
return querysetThe type of self.queryset is queryset: QuerySet[_MT] | Manager[_MT] | None. This means that if self.queryset is None, self.get_queryset will return None.
How is that should be
# relations.pyi
class RelatedField(...):
# ...
def get_queryset(self) -> QuerySet[_MT] | None: ...System information
- OS:
pythonversion: 3.13.5djangoversion: 5.2.3mypyversion: 1.16.0django-stubsversion: 3.16.0
intgr
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working