mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-18 01:45:59 +08:00
add support for _meta.get_field() typechecking
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import date
|
||||
from io import BufferedReader, StringIO, TextIOWrapper
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Dict, Iterable, List, Mapping, Optional, Type, Union
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.management.base import OutputWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields.related import ForeignKey, ManyToManyField
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class SerializerDoesNotExist(KeyError): ...
|
||||
class SerializationError(Exception): ...
|
||||
@@ -43,7 +43,7 @@ class Serializer:
|
||||
first: bool = ...
|
||||
def serialize(
|
||||
self,
|
||||
queryset: Union[Iterator[Any], List[Model], QuerySet],
|
||||
queryset: Iterable[Model],
|
||||
*,
|
||||
stream: Optional[Any] = ...,
|
||||
fields: Optional[Any] = ...,
|
||||
@@ -52,7 +52,7 @@ class Serializer:
|
||||
progress_output: Optional[Any] = ...,
|
||||
object_count: int = ...,
|
||||
**options: Any
|
||||
) -> Optional[Union[List[OrderedDict], bytes, str]]: ...
|
||||
) -> Any: ...
|
||||
def start_serialization(self) -> None: ...
|
||||
def end_serialization(self) -> None: ...
|
||||
def start_object(self, obj: Any) -> None: ...
|
||||
@@ -72,13 +72,16 @@ class Deserializer:
|
||||
class DeserializedObject:
|
||||
object: Any = ...
|
||||
m2m_data: Dict[str, List[int]] = ...
|
||||
def __init__(self, obj: Model, m2m_data: Optional[Dict[str, List[int]]] = ...) -> None: ...
|
||||
deferred_fields: Mapping[Field, Any]
|
||||
def __init__(
|
||||
self,
|
||||
obj: Model,
|
||||
m2m_data: Optional[Dict[str, List[int]]] = ...,
|
||||
deferred_fields: Optional[Mapping[Field, Any]] = ...,
|
||||
) -> None: ...
|
||||
def save(self, save_m2m: bool = ..., using: Optional[str] = ..., **kwargs: Any) -> None: ...
|
||||
def save_deferred_fields(self, using: Optional[str] = ...) -> None: ...
|
||||
|
||||
def build_instance(Model: Type[Model], data: Dict[str, Optional[Union[date, int, str, UUID]]], db: str) -> Model: ...
|
||||
def deserialize_m2m_values(
|
||||
field: ManyToManyField, field_value: Union[List[List[str]], List[int]], using: str
|
||||
) -> List[int]: ...
|
||||
def deserialize_fk_value(
|
||||
field: ForeignKey, field_value: Optional[Union[List[str], Tuple[str], int, str]], using: str
|
||||
) -> Optional[Union[int, str, UUID]]: ...
|
||||
def deserialize_m2m_values(field: ManyToManyField, field_value: Any, using: str) -> List[Any]: ...
|
||||
def deserialize_fk_value(field: ForeignKey, field_value: Any, using: str) -> Any: ...
|
||||
|
||||
Reference in New Issue
Block a user