diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index 87054e91..c27b3f49 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -1,5 +1,5 @@ import re -from collections import Iterable, OrderedDict +from collections import Iterable from functools import partial from graphql_relay import connection_from_list @@ -86,26 +86,18 @@ class Connection(ObjectType): options["name"] = name _meta.node = node - _meta.fields = OrderedDict( - [ - ( - "page_info", - Field( - PageInfo, - name="pageInfo", - required=True, - description="Pagination data for this connection.", - ), - ), - ( - "edges", - Field( - NonNull(List(edge)), - description="Contains the nodes in this connection.", - ), - ), - ] - ) + _meta.fields = { + "page_info": Field( + PageInfo, + name="pageInfo", + required=True, + description="Pagination data for this connection.", + ), + "edges": Field( + NonNull(List(edge)), + description="Contains the nodes in this connection.", + ), + } return super(Connection, cls).__init_subclass_with_meta__( _meta=_meta, **options ) diff --git a/graphene/relay/mutation.py b/graphene/relay/mutation.py index ee758e78..bb27855f 100644 --- a/graphene/relay/mutation.py +++ b/graphene/relay/mutation.py @@ -1,5 +1,4 @@ import re -from collections import OrderedDict from ..types import Field, InputObjectType, String from ..types.mutation import Mutation @@ -30,12 +29,12 @@ class ClientIDMutation(Mutation): cls.Input = type( "{}Input".format(base_name), bases, - OrderedDict( + dict( input_fields, client_mutation_id=String(name="clientMutationId") ), ) - arguments = OrderedDict( + arguments = dict( input=cls.Input(required=True) # 'client_mutation_id': String(name='clientMutationId') ) diff --git a/graphene/relay/node.py b/graphene/relay/node.py index f80db13e..79c34ffc 100644 --- a/graphene/relay/node.py +++ b/graphene/relay/node.py @@ -1,4 +1,3 @@ -from collections import OrderedDict from functools import partial from inspect import isclass @@ -72,9 +71,9 @@ class AbstractNode(Interface): @classmethod def __init_subclass_with_meta__(cls, **options): _meta = InterfaceOptions(cls) - _meta.fields = OrderedDict( - id=GlobalID(cls, description="The ID of the object") - ) + _meta.fields = { + 'id': GlobalID(cls, description="The ID of the object") + } super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options) diff --git a/graphene/types/argument.py b/graphene/types/argument.py index bf304608..b59ecc44 100644 --- a/graphene/types/argument.py +++ b/graphene/types/argument.py @@ -1,4 +1,3 @@ -from collections import OrderedDict from itertools import chain from .dynamic import Dynamic @@ -50,7 +49,7 @@ def to_arguments(args, extra_args=None): else: extra_args = [] iter_arguments = chain(args.items(), extra_args) - arguments = OrderedDict() + arguments = {} for default_name, arg in iter_arguments: if isinstance(arg, Dynamic): arg = arg.get_type() diff --git a/graphene/types/enum.py b/graphene/types/enum.py index 79f2f636..fd286eef 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -1,4 +1,3 @@ -from collections import OrderedDict from enum import Enum as PyEnum from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta @@ -23,13 +22,13 @@ class EnumOptions(BaseOptions): class EnumMeta(SubclassWithMeta_Meta): def __new__(cls, name, bases, classdict, **options): - enum_members = OrderedDict(classdict, __eq__=eq_enum) + enum_members = dict(classdict, __eq__=eq_enum) # We remove the Meta attribute from the class to not collide # with the enum values. enum_members.pop("Meta", None) enum = PyEnum(cls.__name__, enum_members) return SubclassWithMeta_Meta.__new__( - cls, name, bases, OrderedDict(classdict, __enum__=enum), **options + cls, name, bases, dict(classdict, __enum__=enum), **options ) def get(cls, value): @@ -39,7 +38,7 @@ class EnumMeta(SubclassWithMeta_Meta): return cls._meta.enum[value] def __prepare__(name, bases, **kwargs): # noqa: N805 - return OrderedDict() + return {} def __call__(cls, *args, **kwargs): # noqa: N805 if cls is Enum: diff --git a/graphene/types/inputobjecttype.py b/graphene/types/inputobjecttype.py index 8116a827..d75f639a 100644 --- a/graphene/types/inputobjecttype.py +++ b/graphene/types/inputobjecttype.py @@ -1,5 +1,3 @@ -from collections import OrderedDict - from .base import BaseOptions, BaseType from .inputfield import InputField from .unmountedtype import UnmountedType @@ -44,7 +42,7 @@ class InputObjectType(UnmountedType, BaseType): if not _meta: _meta = InputObjectTypeOptions(cls) - fields = OrderedDict() + fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=InputField)) diff --git a/graphene/types/interface.py b/graphene/types/interface.py index f2c9749c..8173f4c2 100644 --- a/graphene/types/interface.py +++ b/graphene/types/interface.py @@ -1,5 +1,3 @@ -from collections import OrderedDict - from .base import BaseOptions, BaseType from .field import Field from .utils import yank_fields_from_attrs @@ -29,7 +27,7 @@ class Interface(BaseType): if not _meta: _meta = InterfaceOptions(cls) - fields = OrderedDict() + fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) diff --git a/graphene/types/mutation.py b/graphene/types/mutation.py index dd09e461..fb139d78 100644 --- a/graphene/types/mutation.py +++ b/graphene/types/mutation.py @@ -1,5 +1,3 @@ -from collections import OrderedDict - from ..utils.deprecated import warn_deprecation from ..utils.get_unbound_function import get_unbound_function from ..utils.props import props @@ -36,7 +34,7 @@ class Mutation(ObjectType): fields = {} if not output: # If output is defined, we don't need to get the fields - fields = OrderedDict() + fields = {} for base in reversed(cls.__mro__): fields.update(yank_fields_from_attrs(base.__dict__, _as=Field)) output = cls diff --git a/graphene/types/objecttype.py b/graphene/types/objecttype.py index be4addb2..d622c598 100644 --- a/graphene/types/objecttype.py +++ b/graphene/types/objecttype.py @@ -1,5 +1,3 @@ -from collections import OrderedDict - from .base import BaseOptions, BaseType from .field import Field from .interface import Interface @@ -36,7 +34,7 @@ class ObjectType(BaseType): if not _meta: _meta = ObjectTypeOptions(cls) - fields = OrderedDict() + fields = {} for interface in interfaces: assert issubclass(interface, Interface), ( diff --git a/graphene/types/utils.py b/graphene/types/utils.py index a7e23572..3b195d69 100644 --- a/graphene/types/utils.py +++ b/graphene/types/utils.py @@ -1,5 +1,4 @@ import inspect -from collections import OrderedDict from functools import partial from ..utils.module_loading import import_string @@ -33,7 +32,7 @@ def yank_fields_from_attrs(attrs, _as=None, sort=True): if sort: fields_with_names = sorted(fields_with_names, key=lambda f: f[1]) - return OrderedDict(fields_with_names) + return dict(fields_with_names) def get_type(_type): diff --git a/graphene/utils/deduplicator.py b/graphene/utils/deduplicator.py index 13c1cb16..32f6dcbe 100644 --- a/graphene/utils/deduplicator.py +++ b/graphene/utils/deduplicator.py @@ -1,4 +1,4 @@ -from collections import Mapping, OrderedDict +from collections import Mapping def deflate(node, index=None, path=None): @@ -16,10 +16,9 @@ def deflate(node, index=None, path=None): else: index[cache_key] = True - field_names = node.keys() - result = OrderedDict() + result = {} - for field_name in field_names: + for field_name in node: value = node[field_name] new_path = path + [field_name] diff --git a/graphene/utils/tests/test_crunch.py b/graphene/utils/tests/test_crunch.py index 9646a257..bbcf37dd 100644 --- a/graphene/utils/tests/test_crunch.py +++ b/graphene/utils/tests/test_crunch.py @@ -1,5 +1,4 @@ import pytest -from collections import OrderedDict from ..crunch import crunch @@ -28,28 +27,26 @@ from ..crunch import crunch ["single-item object", {"a": None}, [None, {"a": 0}]], [ "multi-item all distinct object", - OrderedDict([("a", None), ("b", 0), ("c", True), ("d", "string")]), + {"a": None, "b": 0, "c": True, "d": "string"}, [None, 0, True, "string", {"a": 0, "b": 1, "c": 2, "d": 3}], ], [ "multi-item repeated object", - OrderedDict([("a", True), ("b", True), ("c", True), ("d", True)]), + {"a": True, "b": True, "c": True, "d": True}, [True, {"a": 0, "b": 0, "c": 0, "d": 0}], ], [ "complex array", - [OrderedDict([("a", True), ("b", [1, 2, 3])]), [1, 2, 3]], + [{"a": True, "b": [1, 2, 3]}, [1, 2, 3]], [True, 1, 2, 3, [1, 2, 3], {"a": 0, "b": 4}, [5, 4]], ], [ "complex object", - OrderedDict( - [ - ("a", True), - ("b", [1, 2, 3]), - ("c", OrderedDict([("a", True), ("b", [1, 2, 3])])), - ] - ), + { + "a": True, + "b": [1, 2, 3], + "c": {"a": True, "b": [1, 2, 3]}, + }, [True, 1, 2, 3, [1, 2, 3], {"a": 0, "b": 4}, {"a": 0, "b": 4, "c": 5}], ], ],