You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 #1814
def get_manager() -> "RelatedManager[MyModel]": ...
```
Usage after:
```python
from django_stubs_ext.db.models.manager import RelatedManager
def get_manager() -> RelatedManager[MyModel]: ...
```
0 commit comments