mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-16 08:47:49 +08:00
add support for managers as generics
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Type, Union, TypeVar, Any, Generic, List, Optional, Dict, Callable, Tuple, Sequence
|
||||
from typing import Type, Union, TypeVar, Any, Generic, List, Optional, Dict, Callable, Tuple, Sequence, TYPE_CHECKING
|
||||
from uuid import UUID
|
||||
|
||||
from django.db import models
|
||||
@@ -6,6 +6,9 @@ from django.db.models import Field, Model, QuerySet
|
||||
from django.db.models.fields.mixins import FieldCacheMixin
|
||||
from django.db.models.query_utils import PathInfo, Q
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.models.manager import RelatedManager
|
||||
|
||||
_T = TypeVar("_T", bound=models.Model)
|
||||
|
||||
class RelatedField(FieldCacheMixin, Field):
|
||||
@@ -64,7 +67,7 @@ class ManyToManyField(RelatedField, Generic[_T]):
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def __set__(self, instance, value: Sequence[_T]) -> None: ...
|
||||
def __get__(self, instance, owner) -> QuerySet[_T]: ...
|
||||
def __get__(self, instance, owner) -> RelatedManager[_T]: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
def deconstruct(self) -> Tuple[Optional[str], str, List[Any], Dict[str, str]]: ...
|
||||
def get_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
||||
|
||||
Reference in New Issue
Block a user