ManyToManyField methods should also have docstrings

item isManyToManyField.

class Listing:
    # ...
    items = models.ManyToManyField(Item, related_name="listings", blank=True)

When I hover over its methods set, add, remove and clear in VS Code, their docstrings do not show. Only signatures.

What I get when I hover over set:

listing.items.set: Listing instance

Model: listings.Listing

Module: realestate.listings.models

File: listings/models.py

(method) def set(
    objs: QuerySet[Unknown, Unknown] | Iterable[Unknown],
    *,
    clear: bool = ...,
    through_defaults: Mapping[str, Any] = ...
) -> None

What I get when I hover over clear:

listing.items.clear: Listing instance

Model: listings.Listing

Module: realestate.listings.models

File: listings/models.py

(method) def clear() -> None

I thought it was the fault in Pylance, but maybe these methods don’t actually have docstrings. I propose giving them docstrings, so that I don’t have to go to Django website every time.

ManyToManyField is only used to declare the field in models. When you access this field in code you get an object of ManyRelatedManager. You are right that this class doesn’t provide docstrings for the methods add, remove etc. The catch is that this class is defined dynamically inside a function which (I think) makes it non-trivial for an IDE to pick up the docstrings even if they were there.