Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
django-stubs-ext: Export
RelatedManager
, ManyRelatedManager
stub-…
…only classes (typeddjango#1834) RelatedManager, ManyRelatedManager classes are sometimes useful for type hinting. But these classes don't exist as is at Django runtime, rather they are defined inside function bodies. * When `TYPE_CHECKING`, we re-export django-stubs fake classes. * At runtime, we define these as `Protocol[_T]`. This has the advantage that Python prevents them being used with isinstance(). Usage before: ```python if TYPE_CHECKING: from django.db.models.manager import RelatedManager # before PR typeddjango#1814 def get_manager() -> "RelatedManager[MyModel]": ... ``` Usage after: ```python from django_stubs_ext.db.models.manager import RelatedManager def get_manager() -> RelatedManager[MyModel]: ... ```
- Loading branch information