Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rest_framework-stubs/serializers.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Iterator, Mapping, MutableMapping, Sequence
from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeVar
from typing import Any, ClassVar, Generator, Generic, Literal, NoReturn, TypeVar

from django.db import models
from django.db.models import Manager, Model, QuerySet
Expand Down Expand Up @@ -253,6 +253,9 @@ class ModelSerializer(Serializer, BaseSerializer[_MT]):
self, kwargs: MutableMapping[str, Any], extra_kwargs: MutableMapping[str, Any]
) -> MutableMapping[str, Any]: ...
def get_extra_kwargs(self) -> dict[str, Any]: ...
def get_unique_together_constraints(
self, model: _MT
) -> Generator[tuple[set[tuple[str, ...]], Manager[_MT]], None, None]: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) -> Generator[tuple[set[tuple[str, ...]], Manager[_MT]], None, None]: ...
) -> Iterator[tuple[set[tuple[str, ...]], Manager[_MT]], None, None]: ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sobolevn Thank you very much for your feedback :) I have made the necessary revisions based on your input!

def get_uniqueness_extra_kwargs(
self, field_names: Iterable[str], declared_fields: Mapping[str, Field], extra_kwargs: dict[str, Any]
) -> tuple[dict[str, Any], dict[str, HiddenField]]: ...
Expand Down
4 changes: 3 additions & 1 deletion rest_framework-stubs/utils/field_mapping.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from _typeshed import Incomplete
from collections.abc import MutableMapping, Sequence
from typing import Any, Generic, TypeVar
from typing import Any, Generator, Generic, TypeVar

from django.db import models
from rest_framework.validators import UniqueValidator

NUMERIC_FIELD_TYPES: Sequence[type[models.Field]]

Expand All @@ -17,6 +18,7 @@ class ClassLookupDict(Generic[_K, _V]):

def needs_label(model_field: models.Field, field_name: str) -> bool: ...
def get_detail_view_name(model: models.Model) -> str: ...
def get_unique_validators(field_name: str, model_field: models.Field) -> Generator[UniqueValidator, None, None]: ...
def get_field_kwargs(field_name: str, model_field: models.Field) -> dict[str, Any]: ...
def get_relation_kwargs(field_name: str, relation_info: Incomplete) -> dict[str, Any]: ...
def get_nested_relation_kwargs(relation_info: Incomplete) -> dict[str, Any]: ...
Expand Down
2 changes: 0 additions & 2 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,3 @@ rest_framework.views.GenericView

# Added in 3.15:
rest_framework.filters.search_smart_split
rest_framework.serializers.ModelSerializer.get_unique_together_constraints
rest_framework.utils.field_mapping.get_unique_validators