1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
from typing import TYPE_CHECKING
# Re-export stubs-only classes RelatedManger and ManyRelatedManager.
# These are fake, Django defines these inside function body.
if TYPE_CHECKING:
# noinspection PyUnresolvedReferences
from django.db.models.fields.related_descriptors import ManyRelatedManager as ManyRelatedManager
# noinspection PyUnresolvedReferences
from django.db.models.fields.related_descriptors import RelatedManager as RelatedManager
else:
from typing import Protocol, TypeVar
_T = TypeVar("_T")
_Through = TypeVar("_Through")
# Define as `Protocol` to prevent them being used with `isinstance()`.
# These actually inherit from `BaseManager`.
class RelatedManager(Protocol[_T]):
pass
class ManyRelatedManager(Protocol[_T, _Through]):
pass
|