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
pythonversion: 3.9.10djangoversion: 4.0.2mypyversion: 0.910django-stubsversion: 1.9.0django-stubs-extversion: 0.3.1