ManyToManyField is typed as RelatedManager[<model>] | None
rather than just RelatedManager[<model>]
#1638
Labels
RelatedManager[<model>] | None
rather than just RelatedManager[<model>]
#1638
What's wrong
I have the following model:
addresses
here is typed asRelatedManager[<model>] | None
. meaning any queryset call on it will make mypy complain about the attribute not existing. For example:However, it never is
None
, and I'm not sure how it could be either. If there are no addresses for a customer thancustomer.addresses.exists()
would just return false rather thancustomer.addresses
beingNone
.How is that should be
It should be typed as just
RelatedManager[<model>]
.System information
python
version: 3.11django
version: 4.2mypy
version: 1.4.1django-stubs
version: 4.2.3django-stubs-ext
version: not installedThe text was updated successfully, but these errors were encountered: