Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace OrderedDict with dict #414

Merged
merged 1 commit into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions rest_framework-stubs/fields.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime
import uuid
from collections import OrderedDict
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping, Sequence
from decimal import Decimal
from enum import Enum
Expand Down Expand Up @@ -46,10 +45,10 @@ class Option(Protocol):
def is_simple_callable(obj: Callable) -> bool: ...
def get_attribute(instance: Any, attrs: list[str] | None) -> Any: ...
def set_value(dictionary: MutableMapping[str, Any], keys: Sequence[str], value: Any) -> None: ...
def to_choices_dict(choices: Iterable[Any]) -> OrderedDict: ...
def flatten_choices_dict(choices: dict[Any, Any]) -> OrderedDict: ...
def to_choices_dict(choices: Iterable[Any]) -> dict: ...
def flatten_choices_dict(choices: dict[Any, Any]) -> dict: ...
def iter_options(
grouped_choices: OrderedDict, cutoff: int | None = ..., cutoff_text: StrOrPromise | None = ...
grouped_choices: dict, cutoff: int | None = ..., cutoff_text: StrOrPromise | None = ...
) -> Generator[Option, None, None]: ...
def get_error_detail(exc_info: Any) -> Any: ...

Expand Down Expand Up @@ -454,9 +453,9 @@ class ChoiceField(Field[str, str | int | tuple[str | int, str | int | tuple], st
html_cutoff: int | None
html_cutoff_text: StrOrPromise | None
allow_blank: bool
grouped_choices: OrderedDict
grouped_choices: dict
choice_strings_to_values: dict[str, Any]
_choices: OrderedDict
_choices: dict
def __init__(
self,
choices: Iterable[Any],
Expand Down
13 changes: 6 additions & 7 deletions rest_framework-stubs/relations.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections import OrderedDict
from collections.abc import Callable, Iterable, Mapping, Sequence
from typing import Any, Generic, TypeVar

Expand Down Expand Up @@ -62,11 +61,11 @@ class RelatedField(Generic[_MT, _DT, _PT], Field[_MT, _DT, _PT, Any]):
def many_init(cls, *args: Any, **kwargs: Any) -> ManyRelatedField: ...
def get_queryset(self) -> QuerySet[_MT]: ...
def use_pk_only_optimization(self) -> bool: ...
def get_choices(self, cutoff: int | None = ...) -> OrderedDict: ...
def get_choices(self, cutoff: int | None = ...) -> dict: ...
@property
def choices(self) -> OrderedDict: ...
def choices(self) -> dict: ...
@property
def grouped_choices(self) -> OrderedDict: ...
def grouped_choices(self) -> dict: ...
def iter_options(self) -> Iterable[Option]: ...
def get_attribute(self, instance: _MT) -> _PT | None: ... # type: ignore[override]
def display_value(self, instance: _MT) -> str: ...
Expand Down Expand Up @@ -182,9 +181,9 @@ class ManyRelatedField(Field[Sequence[Any], Sequence[Any], list[Any], Any]):
child_relation: RelatedField = ...,
): ...
def get_value(self, dictionary: Mapping[Any, Any]) -> list[Any]: ... # type: ignore[override]
def get_choices(self, cutoff: int | None = ...) -> OrderedDict: ...
def get_choices(self, cutoff: int | None = ...) -> dict: ...
@property
def choices(self) -> OrderedDict: ...
def choices(self) -> dict: ...
@property
def grouped_choices(self) -> OrderedDict: ...
def grouped_choices(self) -> dict: ...
def iter_options(self) -> Iterable[Option]: ...
4 changes: 2 additions & 2 deletions rest_framework-stubs/schemas/coreapi.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import Counter, OrderedDict
from collections import Counter
from collections.abc import Iterable, Sequence
from typing import Any

Expand All @@ -17,7 +17,7 @@ def distribute_links(obj: Any) -> None: ...

INSERT_INTO_COLLISION_FMT: str

class LinkNode(OrderedDict):
class LinkNode(dict):
links: list[Any]
methods_counter: Counter
def __init__(self) -> None: ...
Expand Down
5 changes: 2 additions & 3 deletions rest_framework-stubs/utils/serializer_helpers.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections import OrderedDict
from collections.abc import Iterator, MutableMapping
from typing import Any

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

class ReturnDict(OrderedDict):
class ReturnDict(dict):
serializer: BaseSerializer
def __init__(self, serializer: BaseSerializer = ..., *args, **kwargs): ...
def copy(self) -> ReturnDict: ...
Expand Down Expand Up @@ -39,7 +38,7 @@ class NestedBoundField(BoundField):

class BindingDict(MutableMapping[str, Field]):
serializer: BaseSerializer
fields: OrderedDict[str, Field]
fields: dict[str, Field]
def __init__(self, serializer: BaseSerializer): ...
def __setitem__(self, key: str, field: Field) -> None: ...
def __getitem__(self, key: str) -> Field: ...
Expand Down
3 changes: 1 addition & 2 deletions rest_framework-stubs/viewsets.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections import OrderedDict
from collections.abc import Callable
from typing import Any

Expand Down Expand Up @@ -36,7 +35,7 @@ class ViewSetMixin:
def reverse_action(self, url_name: str, *args: Any, **kwargs: Any) -> str: ...
@classmethod
def get_extra_actions(cls) -> list[_ViewFunc]: ...
def get_extra_action_url_map(self) -> OrderedDict[str, str]: ...
def get_extra_action_url_map(self) -> dict[str, str]: ...

class ViewSet(ViewSetMixin, views.APIView): ...
class GenericViewSet(ViewSetMixin, generics.GenericAPIView[_MT_co]): ...
Expand Down