django-stubs
django-stubs copied to clipboard
Error typechecking ManyToManyField manager `request.user.groups.all()`
Bug report
What's wrong
If I use request.user.groups.all()
in a view (request being an instance of django.http.HttpRequest
), this runs fine but mypy complains with
error: Item "ManyToManyField[Sequence[Group], RelatedManager[Group]]" of "Union[ManyToManyField[Sequence[Group], RelatedManager[Group]], EmptyManager]" has no attribute "all"
How is that should be
Typechecking should pass without errors.
System information
- OS: Ubuntu 20.04
-
python
version: 3.9.10 -
django
version: 4.0.2 -
mypy
version: 0.910 -
django-stubs
version: 1.9.0 -
django-stubs-ext
version: 0.3.1