from collections import OrderedDict
from typing import Any, Dict, Iterable, List, MutableMapping, Tuple, Union

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

class ReturnDict(OrderedDict[Any, Any]):
    serializer: BaseSerializer
    def __init__(self, serializer: BaseSerializer = ..., *args: Any, **kwargs: Any): ...
    def copy(self) -> ReturnDict: ...
    def __reduce__(self) -> Tuple[Dict[Any, Any], Tuple[Dict[Any, Any]]]: ...

class ReturnList(List[Any]):
    serializer: BaseSerializer
    def __init__(self, serializer: BaseSerializer = ..., *args: Any, **kwargs: Any): ...
    def __reduce__(self) -> Tuple[Dict[Any, Any], Tuple[Dict[Any, Any]]]: ...

class BoundField:
    """
    A field object that also includes `.value` and `.error` properties.
    Returned when iterating over a serializer instance,
    providing an API similar to Django forms and form fields.
    """

    value: Any
    fields: Dict[str, Field[Any, Any, Any, Any]]
    errors: List[ErrorDetail]
    def __init__(self, field: Field[Any, Any, Any, Any], value: Any, errors: List[ErrorDetail], prefix: str = ...): ...
    def __getattr__(self, attr_name: str) -> Any: ...
    def as_form_field(self) -> BoundField: ...

class JSONBoundField(BoundField): ...

class NestedBoundField(BoundField):
    def __iter__(self) -> Iterable[str]: ...
    def __getitem__(self, key: str) -> Union[BoundField, NestedBoundField]: ...

class BindingDict(MutableMapping[str, Field[Any, Any, Any, Any]]):
    serializer: BaseSerializer
    fields: OrderedDict[str, Field[Any, Any, Any, Any]]
    def __init__(self, serializer: BaseSerializer): ...
    def __setitem__(self, key: str, field: Field[Any, Any, Any, Any]) -> None: ...
    def __getitem__(self, key: str) -> Field[Any, Any, Any, Any]: ...
    def __delitem__(self, key: str) -> None: ...
    def __iter__(self) -> Iterable[Field[Any, Any, Any, Any]]: ...  # type: ignore[override]
    def __len__(self) -> int: ...
