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

from django.db.models import Model, QuerySet
from rest_framework.fields import Field
from rest_framework.serializers import BaseSerializer

def qs_exists(queryset: QuerySet) -> bool: ...

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

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

class UniqueValidator(object):
    message: str = ...

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

class UniqueTogetherValidator(object):
    message: str = ...
    missing_message: str = ...

    queryset: QuerySet
    fields: Iterable[str]
    serializer_field: Optional[Field]
    instance: Optional[Model]
    def __init__(self, queryset: QuerySet, fields: Iterable[str], message: Optional[str] = ...): ...
    def set_context(self, serializer: BaseSerializer) -> None: ...
    def enforce_required_fields(self, attrs: Container[str]) -> None: ...
    def filter_queryset(self, attrs: MutableMapping[str, Any], queryset: QuerySet[_T]) -> QuerySet[_T]: ...
    def exclude_current_instance(self, attrs: MutableMapping[str, Any], queryset: QuerySet[_T]) -> QuerySet[_T]: ...
    def __call__(self, attrs: MutableMapping[str, Any]) -> None: ...

class BaseUniqueForValidator(object):
    message: str = ...
    missing_message: str = ...

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

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