from typing import Any, Container, Iterable, MutableMapping, NoReturn, Optional, TypeVar

from django.db.models import Model, QuerySet

from rest_framework.fields import Field
from rest_framework.serializers import BaseSerializer

_T = TypeVar("_T", bound=Model)

def qs_exists(queryset: QuerySet[Any]) -> bool: ...
def qs_filter(queryset: QuerySet[_T], **kwargs: Any) -> QuerySet[_T]: ...

class UniqueValidator:
    message: str = ...
    requires_context: bool = ...
    queryset: QuerySet[Any]
    lookup: str
    def __init__(self, queryset: QuerySet[Any], message: Optional[str] = ..., lookup: str = ...) -> None: ...
    def filter_queryset(self, value: Any, queryset: QuerySet[_T], field_name: str) -> QuerySet[_T]: ...
    def exclude_current_instance(self, queryset: QuerySet[_T], instance: _T) -> QuerySet[_T]: ...
    def __call__(self, value: Any, serializer_field: Field[Any, Any, Any, Any]) -> NoReturn: ...

class UniqueTogetherValidator:
    message: str = ...
    missing_message: str = ...
    requires_context: bool = ...
    queryset: QuerySet[Any]
    fields: Iterable[str]
    def __init__(self, queryset: QuerySet[Any], fields: Iterable[str], message: Optional[str] = ...) -> None: ...
    def enforce_required_fields(self, attrs: Container[str], serializer: BaseSerializer) -> NoReturn: ...
    def filter_queryset(
        self, attrs: MutableMapping[str, Any], queryset: QuerySet[_T], serializer: BaseSerializer
    ) -> QuerySet[_T]: ...
    def exclude_current_instance(
        self, attrs: MutableMapping[str, Any], queryset: QuerySet[_T], instance: _T
    ) -> QuerySet[_T]: ...
    def __call__(self, attrs: MutableMapping[str, Any], serializer: BaseSerializer) -> NoReturn: ...

class ProhibitSurrogateCharactersValidator:
    message: str = ...
    code: str = ...
    def __call__(self, value: Any) -> NoReturn: ...

class BaseUniqueForValidator:
    message: str = ...
    missing_message: str = ...
    requires_context: bool = ...
    queryset: QuerySet[Any]
    field: str
    date_field: str
    def __init__(self, queryset: QuerySet[Any], field: str, date_field: str, message: Optional[str] = ...) -> None: ...
    def enforce_required_fields(self, attrs: Container[str]) -> NoReturn: ...
    def filter_queryset(
        self, attrs: MutableMapping[str, Any], queryset: QuerySet[_T], field_name: str, date_field_name: str
    ) -> QuerySet[_T]: ...
    def exclude_current_instance(
        self, attrs: MutableMapping[str, Any], queryset: QuerySet[_T], instance: Model
    ) -> QuerySet[_T]: ...
    def __call__(self, attrs: MutableMapping[str, Any], serializer: BaseSerializer) -> NoReturn: ...

class UniqueForDateValidator(BaseUniqueForValidator): ...
class UniqueForMonthValidator(BaseUniqueForValidator): ...
class UniqueForYearValidator(BaseUniqueForValidator): ...
