diff --git a/docs/conf.py b/docs/conf.py index 26becbc2..0166d4c2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,18 +64,18 @@ source_suffix = ".rst" master_doc = "index" # General information about the project. -project = u"Graphene" -copyright = u"Graphene 2016" -author = u"Syrus Akbary" +project = "Graphene" +copyright = "Graphene 2016" +author = "Syrus Akbary" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u"1.0" +version = "1.0" # The full version, including alpha/beta/rc tags. -release = u"1.0" +release = "1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -278,7 +278,7 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, "Graphene.tex", u"Graphene Documentation", u"Syrus Akbary", "manual") + (master_doc, "Graphene.tex", "Graphene Documentation", "Syrus Akbary", "manual") ] # The name of an image file (relative to this directory) to place at the top of @@ -318,7 +318,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "graphene", u"Graphene Documentation", [author], 1)] +man_pages = [(master_doc, "graphene", "Graphene Documentation", [author], 1)] # If true, show URL addresses after external links. # @@ -334,7 +334,7 @@ texinfo_documents = [ ( master_doc, "Graphene", - u"Graphene Documentation", + "Graphene Documentation", author, "Graphene", "One line description of project.", diff --git a/examples/simple_example.py b/examples/simple_example.py index 9bff3070..b13d69c4 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -8,7 +8,6 @@ class Patron(graphene.ObjectType): class Query(graphene.ObjectType): - patron = graphene.Field(Patron) def resolve_patron(self, info): diff --git a/examples/starwars/tests/snapshots/snap_test_query.py b/examples/starwars/tests/snapshots/snap_test_query.py index b4f05bdb..ff6d2d82 100644 --- a/examples/starwars/tests/snapshots/snap_test_query.py +++ b/examples/starwars/tests/snapshots/snap_test_query.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals from snapshottest import Snapshot diff --git a/examples/starwars_relay/tests/snapshots/snap_test_connections.py b/examples/starwars_relay/tests/snapshots/snap_test_connections.py index 57a7b7ea..f3181e45 100644 --- a/examples/starwars_relay/tests/snapshots/snap_test_connections.py +++ b/examples/starwars_relay/tests/snapshots/snap_test_connections.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals from snapshottest import Snapshot diff --git a/examples/starwars_relay/tests/snapshots/snap_test_mutation.py b/examples/starwars_relay/tests/snapshots/snap_test_mutation.py index 4608bdaf..db438891 100644 --- a/examples/starwars_relay/tests/snapshots/snap_test_mutation.py +++ b/examples/starwars_relay/tests/snapshots/snap_test_mutation.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals from snapshottest import Snapshot diff --git a/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py b/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py index 2d13cba3..6e252933 100644 --- a/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py +++ b/examples/starwars_relay/tests/snapshots/snap_test_objectidentification.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals from snapshottest import Snapshot diff --git a/graphene/pyutils/compat.py b/graphene/pyutils/compat.py index 2581446b..c730676d 100644 --- a/graphene/pyutils/compat.py +++ b/graphene/pyutils/compat.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from graphql.pyutils.compat import Enum try: diff --git a/graphene/pyutils/init_subclass.py b/graphene/pyutils/init_subclass.py index 81198c9c..58d55779 100644 --- a/graphene/pyutils/init_subclass.py +++ b/graphene/pyutils/init_subclass.py @@ -10,14 +10,13 @@ if not is_init_subclass_available: if __init_subclass__: __init_subclass__ = classmethod(__init_subclass__) ns["__init_subclass__"] = __init_subclass__ - return super(InitSubclassMeta, cls).__new__(cls, name, bases, ns, **kwargs) + return super().__new__(cls, name, bases, ns, **kwargs) def __init__(cls, name, bases, ns, **kwargs): - super(InitSubclassMeta, cls).__init__(name, bases, ns) + super().__init__(name, bases, ns) super_class = super(cls, cls) if hasattr(super_class, "__init_subclass__"): super_class.__init_subclass__.__func__(cls, **kwargs) - else: InitSubclassMeta = type # type: ignore diff --git a/graphene/pyutils/signature.py b/graphene/pyutils/signature.py index 7757d9d0..43c62265 100644 --- a/graphene/pyutils/signature.py +++ b/graphene/pyutils/signature.py @@ -3,7 +3,6 @@ Back port of Python 3.3's function signature tools from the inspect module, modified to be compatible with Python 2.7 and 3.2+. """ -from __future__ import absolute_import, division, print_function import functools import itertools @@ -177,11 +176,11 @@ def signature(obj): raise ValueError("callable {!r} is not supported by signature".format(obj)) -class _void(object): +class _void: """A private marker - used in Parameter & Signature""" -class _empty(object): +class _empty: pass @@ -205,7 +204,7 @@ _KEYWORD_ONLY = _ParameterKind(3, name="KEYWORD_ONLY") _VAR_KEYWORD = _ParameterKind(4, name="VAR_KEYWORD") -class Parameter(object): +class Parameter: """Represents a parameter in a function signature. Has the following public attributes: * name : str @@ -236,7 +235,6 @@ class Parameter(object): def __init__( self, name, kind, default=_empty, annotation=_empty, _partial_kwarg=False ): - if kind not in ( _POSITIONAL_ONLY, _POSITIONAL_OR_KEYWORD, @@ -361,7 +359,7 @@ class Parameter(object): return not self.__eq__(other) -class BoundArguments(object): +class BoundArguments: """Result of `Signature.bind` call. Holds the mapping of arguments to the function's parameters. Has the following public attributes: @@ -456,7 +454,7 @@ class BoundArguments(object): return not self.__eq__(other) -class Signature(object): +class Signature: """A Signature object represents the overall signature of a function. It stores a Parameter object for each parameter accepted by the function, as well as information specific to the function itself. @@ -517,7 +515,7 @@ class Signature(object): raise ValueError(msg) params[name] = param else: - params = OrderedDict(((param.name, param) for param in parameters)) + params = OrderedDict((param.name, param) for param in parameters) self._parameters = params self._return_annotation = return_annotation diff --git a/graphene/pyutils/version.py b/graphene/pyutils/version.py index f2005442..f3a11ae9 100644 --- a/graphene/pyutils/version.py +++ b/graphene/pyutils/version.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import datetime import os import subprocess diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index c05160b5..fb92562b 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -4,7 +4,7 @@ from collections import OrderedDict try: from collections.abc import Iterable except ImportError: - from collections import Iterable + from collections.abc import Iterable from functools import partial @@ -72,7 +72,7 @@ class Connection(ObjectType): edge_class = getattr(cls, "Edge", None) _node = node - class EdgeBase(object): + class EdgeBase: node = Field(_node, description="The item at the end of the edge") cursor = String(required=True, description="A cursor for use in pagination") @@ -112,9 +112,7 @@ class Connection(ObjectType): ), ] ) - return super(Connection, cls).__init_subclass_with_meta__( - _meta=_meta, **options - ) + return super().__init_subclass_with_meta__(_meta=_meta, **options) class IterableConnectionField(Field): @@ -123,11 +121,11 @@ class IterableConnectionField(Field): kwargs.setdefault("after", String()) kwargs.setdefault("first", Int()) kwargs.setdefault("last", Int()) - super(IterableConnectionField, self).__init__(type, *args, **kwargs) + super().__init__(type, *args, **kwargs) @property def type(self): - type = super(IterableConnectionField, self).type + type = super().type connection_type = type if isinstance(type, NonNull): connection_type = type.of_type @@ -173,7 +171,7 @@ class IterableConnectionField(Field): return maybe_thenable(resolved, on_resolve) def get_resolver(self, parent_resolver): - resolver = super(IterableConnectionField, self).get_resolver(parent_resolver) + resolver = super().get_resolver(parent_resolver) return partial(self.connection_resolver, resolver, self.type) diff --git a/graphene/relay/mutation.py b/graphene/relay/mutation.py index ee758e78..eee14656 100644 --- a/graphene/relay/mutation.py +++ b/graphene/relay/mutation.py @@ -49,7 +49,7 @@ class ClientIDMutation(Mutation): if not name: name = "{}Payload".format(base_name) - super(ClientIDMutation, cls).__init_subclass_with_meta__( + super().__init_subclass_with_meta__( output=None, arguments=arguments, name=name, **options ) cls._meta.fields["client_mutation_id"] = Field(String, name="clientMutationId") diff --git a/graphene/relay/node.py b/graphene/relay/node.py index 4b324a93..a86b0ae7 100644 --- a/graphene/relay/node.py +++ b/graphene/relay/node.py @@ -28,7 +28,7 @@ def is_node(objecttype): class GlobalID(Field): def __init__(self, node=None, parent_type=None, required=True, *args, **kwargs): - super(GlobalID, self).__init__(ID, required=required, *args, **kwargs) + super().__init__(ID, required=required, *args, **kwargs) self.node = node or Node self.parent_type_name = parent_type._meta.name if parent_type else None @@ -53,7 +53,7 @@ class NodeField(Field): self.node_type = node self.field_type = type - super(NodeField, self).__init__( + super().__init__( # If we don's specify a type, the field type will be the node # interface type or node, @@ -75,7 +75,7 @@ class AbstractNode(Interface): _meta.fields = OrderedDict( id=GlobalID(cls, description="The ID of the object.") ) - super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) class Node(AbstractNode): diff --git a/graphene/relay/tests/test_connection.py b/graphene/relay/tests/test_connection.py index 6686f964..35bfde1f 100644 --- a/graphene/relay/tests/test_connection.py +++ b/graphene/relay/tests/test_connection.py @@ -39,7 +39,7 @@ def test_connection(): def test_connection_inherit_abstracttype(): - class BaseConnection(object): + class BaseConnection: extra = String() class MyObjectConnection(BaseConnection, Connection): @@ -54,7 +54,7 @@ def test_connection_inherit_abstracttype(): def test_connection_name(): custom_name = "MyObjectCustomNameConnection" - class BaseConnection(object): + class BaseConnection: extra = String() class MyObjectConnection(BaseConnection, Connection): @@ -86,7 +86,7 @@ def test_edge(): def test_edge_with_bases(): - class BaseEdge(object): + class BaseEdge: extra = String() class MyObjectConnection(Connection): diff --git a/graphene/relay/tests/test_global_id.py b/graphene/relay/tests/test_global_id.py index 6d328f23..2fe81300 100644 --- a/graphene/relay/tests/test_global_id.py +++ b/graphene/relay/tests/test_global_id.py @@ -17,7 +17,7 @@ class User(ObjectType): name = String() -class Info(object): +class Info: def __init__(self, parent_type): self.parent_type = GrapheneObjectType( graphene_type=parent_type, diff --git a/graphene/relay/tests/test_mutation.py b/graphene/relay/tests/test_mutation.py index b58a3ddf..c9540860 100644 --- a/graphene/relay/tests/test_mutation.py +++ b/graphene/relay/tests/test_mutation.py @@ -15,7 +15,7 @@ from ...types.scalars import String from ..mutation import ClientIDMutation -class SharedFields(object): +class SharedFields: shared = String() @@ -37,7 +37,7 @@ class SaySomething(ClientIDMutation): return SaySomething(phrase=str(what)) -class FixedSaySomething(object): +class FixedSaySomething: __slots__ = ("phrase",) def __init__(self, phrase): diff --git a/graphene/relay/tests/test_node.py b/graphene/relay/tests/test_node.py index a0f40608..c58adfdf 100644 --- a/graphene/relay/tests/test_node.py +++ b/graphene/relay/tests/test_node.py @@ -6,8 +6,7 @@ from ...types import ObjectType, Schema, String from ..node import Node, is_node -class SharedNodeFields(object): - +class SharedNodeFields: shared = String() something_else = String() diff --git a/graphene/test/__init__.py b/graphene/test/__init__.py index 7d554fb6..96e7d94d 100644 --- a/graphene/test/__init__.py +++ b/graphene/test/__init__.py @@ -24,7 +24,7 @@ def format_execution_result(execution_result, format_error): return response -class Client(object): +class Client: def __init__(self, schema, format_error=None, **execute_options): assert isinstance(schema, Schema) self.schema = schema diff --git a/graphene/tests/issues/test_425.py b/graphene/tests/issues/test_425.py index 50c18758..66cb570a 100644 --- a/graphene/tests/issues/test_425.py +++ b/graphene/tests/issues/test_425.py @@ -16,9 +16,7 @@ class SpecialObjectType(ObjectType): def __init_subclass_with_meta__(cls, other_attr="default", **options): _meta = SpecialOptions(cls) _meta.other_attr = other_attr - super(SpecialObjectType, cls).__init_subclass_with_meta__( - _meta=_meta, **options - ) + super().__init_subclass_with_meta__(_meta=_meta, **options) def test_special_objecttype_could_be_subclassed(): @@ -55,9 +53,7 @@ class SpecialInputObjectType(InputObjectType): def __init_subclass_with_meta__(cls, other_attr="default", **options): _meta = SpecialInputObjectTypeOptions(cls) _meta.other_attr = other_attr - super(SpecialInputObjectType, cls).__init_subclass_with_meta__( - _meta=_meta, **options - ) + super().__init_subclass_with_meta__(_meta=_meta, **options) def test_special_inputobjecttype_could_be_subclassed(): @@ -92,7 +88,7 @@ class SpecialEnum(Enum): def __init_subclass_with_meta__(cls, other_attr="default", **options): _meta = SpecialEnumOptions(cls) _meta.other_attr = other_attr - super(SpecialEnum, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) def test_special_enum_could_be_subclassed(): diff --git a/graphene/tests/issues/test_720.py b/graphene/tests/issues/test_720.py index ea961b25..fa1be25f 100644 --- a/graphene/tests/issues/test_720.py +++ b/graphene/tests/issues/test_720.py @@ -14,9 +14,7 @@ class MyInputClass(graphene.InputObjectType): if _meta is None: _meta = graphene.types.inputobjecttype.InputObjectTypeOptions(cls) _meta.fields = fields - super(MyInputClass, cls).__init_subclass_with_meta__( - container=container, _meta=_meta, **options - ) + super().__init_subclass_with_meta__(container=container, _meta=_meta, **options) class MyInput(MyInputClass): diff --git a/graphene/types/abstracttype.py b/graphene/types/abstracttype.py index 4eeb7f9c..16fe08c9 100644 --- a/graphene/types/abstracttype.py +++ b/graphene/types/abstracttype.py @@ -8,4 +8,4 @@ class AbstractType(SubclassWithMeta): "Abstract type is deprecated, please use normal object inheritance instead.\n" "See more: https://github.com/graphql-python/graphene/blob/master/UPGRADE-v2.0.md#deprecations" ) - super(AbstractType, cls).__init_subclass__(*args, **kwargs) + super().__init_subclass__(*args, **kwargs) diff --git a/graphene/types/argument.py b/graphene/types/argument.py index cb72322c..495e6239 100644 --- a/graphene/types/argument.py +++ b/graphene/types/argument.py @@ -48,7 +48,7 @@ class Argument(MountedType): required=False, _creation_counter=None, ): - super(Argument, self).__init__(_creation_counter=_creation_counter) + super().__init__(_creation_counter=_creation_counter) if required: type = NonNull(type) diff --git a/graphene/types/base.py b/graphene/types/base.py index 3bbebbe3..f6cf682d 100644 --- a/graphene/types/base.py +++ b/graphene/types/base.py @@ -4,7 +4,7 @@ from ..utils.trim_docstring import trim_docstring from typing import Type -class BaseOptions(object): +class BaseOptions: name = None # type: str description = None # type: str @@ -18,7 +18,7 @@ class BaseOptions(object): def __setattr__(self, name, value): if not self._frozen: - super(BaseOptions, self).__setattr__(name, value) + super().__setattr__(name, value) else: raise Exception("Can't modify frozen Options {}".format(self)) @@ -42,4 +42,4 @@ class BaseType(SubclassWithMeta): _meta.description = description or trim_docstring(cls.__doc__) _meta.freeze() cls._meta = _meta - super(BaseType, cls).__init_subclass_with_meta__() + super().__init_subclass_with_meta__() diff --git a/graphene/types/context.py b/graphene/types/context.py index 70b1a5b2..fa405179 100644 --- a/graphene/types/context.py +++ b/graphene/types/context.py @@ -1,4 +1,4 @@ -class Context(object): +class Context: """ Context can be used to make a convenient container for attributes to provide for execution for resolvers of a GraphQL operation like a query. diff --git a/graphene/types/datetime.py b/graphene/types/datetime.py index ca96547f..df0b4352 100644 --- a/graphene/types/datetime.py +++ b/graphene/types/datetime.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import datetime from aniso8601 import parse_date, parse_datetime, parse_time diff --git a/graphene/types/decimal.py b/graphene/types/decimal.py index 2f99134d..92b9fa21 100644 --- a/graphene/types/decimal.py +++ b/graphene/types/decimal.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from decimal import Decimal as _Decimal from graphql.language import ast diff --git a/graphene/types/definitions.py b/graphene/types/definitions.py index a914008c..b097de93 100644 --- a/graphene/types/definitions.py +++ b/graphene/types/definitions.py @@ -8,7 +8,7 @@ from graphql import ( ) -class GrapheneGraphQLType(object): +class GrapheneGraphQLType: """ A class for extending the base GraphQLType with the related graphene_type @@ -16,7 +16,7 @@ class GrapheneGraphQLType(object): def __init__(self, *args, **kwargs): self.graphene_type = kwargs.pop("graphene_type") - super(GrapheneGraphQLType, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class GrapheneInterfaceType(GrapheneGraphQLType, GraphQLInterfaceType): diff --git a/graphene/types/dynamic.py b/graphene/types/dynamic.py index 588c53bb..97f34067 100644 --- a/graphene/types/dynamic.py +++ b/graphene/types/dynamic.py @@ -11,7 +11,7 @@ class Dynamic(MountedType): """ def __init__(self, type, with_schema=False, _creation_counter=None): - super(Dynamic, self).__init__(_creation_counter=_creation_counter) + super().__init__(_creation_counter=_creation_counter) assert inspect.isfunction(type) or isinstance(type, partial) self.type = type self.with_schema = with_schema diff --git a/graphene/types/enum.py b/graphene/types/enum.py index 38dada0f..ad1ba5d5 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -50,7 +50,7 @@ class EnumMeta(SubclassWithMeta_Meta): description=description, deprecation_reason=deprecation_reason, ) - return super(EnumMeta, cls).__call__(*args, **kwargs) + return super().__call__(*args, **kwargs) # return cls._meta.enum(*args, **kwargs) def from_enum(cls, enum, description=None, deprecation_reason=None): # noqa: N805 @@ -98,7 +98,7 @@ class Enum(UnmountedType, BaseType, metaclass=EnumMeta): for key, value in _meta.enum.__members__.items(): setattr(cls, key, value) - super(Enum, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) @classmethod def get_type(cls): diff --git a/graphene/types/field.py b/graphene/types/field.py index 39db65e9..82dd6169 100644 --- a/graphene/types/field.py +++ b/graphene/types/field.py @@ -4,7 +4,7 @@ from collections import OrderedDict try: from collections.abc import Mapping except ImportError: - from collections import Mapping + from collections.abc import Mapping from functools import partial @@ -80,7 +80,7 @@ class Field(MountedType): default_value=None, **extra_args ): - super(Field, self).__init__(_creation_counter=_creation_counter) + super().__init__(_creation_counter=_creation_counter) assert not args or isinstance(args, Mapping), ( 'Arguments in a field have to be a mapping, received "{}".' ).format(args) diff --git a/graphene/types/generic.py b/graphene/types/generic.py index e5470dd9..e41dbb9c 100644 --- a/graphene/types/generic.py +++ b/graphene/types/generic.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from graphql.language.ast import ( BooleanValue, FloatValue, diff --git a/graphene/types/inputfield.py b/graphene/types/inputfield.py index ed9b96ab..5de03484 100644 --- a/graphene/types/inputfield.py +++ b/graphene/types/inputfield.py @@ -55,7 +55,7 @@ class InputField(MountedType): _creation_counter=None, **extra_args ): - super(InputField, self).__init__(_creation_counter=_creation_counter) + super().__init__(_creation_counter=_creation_counter) self.name = name if required: type = NonNull(type) diff --git a/graphene/types/inputobjecttype.py b/graphene/types/inputobjecttype.py index d1368931..e49d75f6 100644 --- a/graphene/types/inputobjecttype.py +++ b/graphene/types/inputobjecttype.py @@ -81,7 +81,7 @@ class InputObjectType(UnmountedType, BaseType): if container is None: container = type(cls.__name__, (InputObjectTypeContainer, cls), {}) _meta.container = container - super(InputObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) @classmethod def get_type(cls): diff --git a/graphene/types/interface.py b/graphene/types/interface.py index 59184a1f..9db7bca3 100644 --- a/graphene/types/interface.py +++ b/graphene/types/interface.py @@ -60,7 +60,7 @@ class Interface(BaseType): else: _meta.fields = fields - super(Interface, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) @classmethod def resolve_type(cls, instance, info): diff --git a/graphene/types/json.py b/graphene/types/json.py index 6b87ae6e..972391bd 100644 --- a/graphene/types/json.py +++ b/graphene/types/json.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import json from graphql.language import ast diff --git a/graphene/types/mutation.py b/graphene/types/mutation.py index 31c32284..bd297cc1 100644 --- a/graphene/types/mutation.py +++ b/graphene/types/mutation.py @@ -129,7 +129,7 @@ class Mutation(ObjectType): _meta.resolver = resolver _meta.arguments = arguments - super(Mutation, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) @classmethod def Field( diff --git a/graphene/types/objecttype.py b/graphene/types/objecttype.py index 88c9f5bc..b01bf4c1 100644 --- a/graphene/types/objecttype.py +++ b/graphene/types/objecttype.py @@ -126,7 +126,7 @@ class ObjectType(BaseType): _meta.possible_types = possible_types _meta.default_resolver = default_resolver - super(ObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) is_type_of = None diff --git a/graphene/types/scalars.py b/graphene/types/scalars.py index 769c406f..d3c0272b 100644 --- a/graphene/types/scalars.py +++ b/graphene/types/scalars.py @@ -22,7 +22,7 @@ class Scalar(UnmountedType, BaseType): @classmethod def __init_subclass_with_meta__(cls, **options): _meta = ScalarOptions(cls) - super(Scalar, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) serialize = None parse_value = None @@ -111,7 +111,7 @@ class String(Scalar): @staticmethod def coerce_string(value): if isinstance(value, bool): - return u"true" if value else u"false" + return "true" if value else "false" return str(value) serialize = coerce_string diff --git a/graphene/types/schema.py b/graphene/types/schema.py index 738ed746..4d2d8038 100644 --- a/graphene/types/schema.py +++ b/graphene/types/schema.py @@ -93,7 +93,7 @@ class Schema(GraphQLSchema): Example: using schema.Query for accessing the "Query" type in the Schema """ - _type = super(Schema, self).get_type(type_name) + _type = super().get_type(type_name) if _type is None: raise AttributeError('Type "{}" not found in the Schema'.format(type_name)) if isinstance(_type, GrapheneGraphQLType): diff --git a/graphene/types/structures.py b/graphene/types/structures.py index 3341e022..470651f4 100644 --- a/graphene/types/structures.py +++ b/graphene/types/structures.py @@ -9,7 +9,7 @@ class Structure(UnmountedType): """ def __init__(self, of_type, *args, **kwargs): - super(Structure, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if not isinstance(of_type, Structure) and isinstance(of_type, UnmountedType): cls_name = type(self).__name__ of_type_name = type(of_type).__name__ @@ -84,7 +84,7 @@ class NonNull(Structure): """ def __init__(self, *args, **kwargs): - super(NonNull, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) assert not isinstance(self._of_type, NonNull), ( "Can only create NonNull of a Nullable GraphQLType but got: {}." ).format(self._of_type) diff --git a/graphene/types/tests/test_base.py b/graphene/types/tests/test_base.py index 2f70903c..8456bd52 100644 --- a/graphene/types/tests/test_base.py +++ b/graphene/types/tests/test_base.py @@ -9,7 +9,7 @@ class CustomType(BaseType): @classmethod def __init_subclass_with_meta__(cls, **options): _meta = CustomOptions(cls) - super(CustomType, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) def test_basetype(): diff --git a/graphene/types/tests/test_definition.py b/graphene/types/tests/test_definition.py index 549847d5..1e3ea8bc 100644 --- a/graphene/types/tests/test_definition.py +++ b/graphene/types/tests/test_definition.py @@ -281,7 +281,7 @@ def test_stringifies_simple_types(): def test_does_not_mutate_passed_field_definitions(): - class CommonFields(object): + class CommonFields: field1 = String() field2 = String(id=String()) @@ -293,7 +293,7 @@ def test_does_not_mutate_passed_field_definitions(): assert TestObject1._meta.fields == TestObject2._meta.fields - class CommonFields(object): + class CommonFields: field1 = String() field2 = String() diff --git a/graphene/types/tests/test_enum.py b/graphene/types/tests/test_enum.py index b29764f2..e0937992 100644 --- a/graphene/types/tests/test_enum.py +++ b/graphene/types/tests/test_enum.py @@ -113,7 +113,6 @@ def test_enum_from_builtin_enum_accepts_lambda_description(): def test_enum_from_python3_enum_uses_enum_doc(): - from enum import Enum as PyEnum class Color(PyEnum): diff --git a/graphene/types/tests/test_field.py b/graphene/types/tests/test_field.py index 13c755fc..60bf3684 100644 --- a/graphene/types/tests/test_field.py +++ b/graphene/types/tests/test_field.py @@ -9,7 +9,7 @@ from ..structures import NonNull from .utils import MyLazyType -class MyInstance(object): +class MyInstance: value = "value" value_func = staticmethod(lambda: "value_func") diff --git a/graphene/types/tests/test_inputobjecttype.py b/graphene/types/tests/test_inputobjecttype.py index dc557b94..0ae6673c 100644 --- a/graphene/types/tests/test_inputobjecttype.py +++ b/graphene/types/tests/test_inputobjecttype.py @@ -8,7 +8,7 @@ from ..schema import Schema from ..unmountedtype import UnmountedType -class MyType(object): +class MyType: pass @@ -78,7 +78,7 @@ def test_generate_inputobjecttype_as_argument(): def test_generate_inputobjecttype_inherit_abstracttype(): - class MyAbstractType(object): + class MyAbstractType: field1 = MyScalar(MyType) class MyInputObjectType(InputObjectType, MyAbstractType): @@ -92,7 +92,7 @@ def test_generate_inputobjecttype_inherit_abstracttype(): def test_generate_inputobjecttype_inherit_abstracttype_reversed(): - class MyAbstractType(object): + class MyAbstractType: field1 = MyScalar(MyType) class MyInputObjectType(MyAbstractType, InputObjectType): diff --git a/graphene/types/tests/test_interface.py b/graphene/types/tests/test_interface.py index b524296b..df85472f 100644 --- a/graphene/types/tests/test_interface.py +++ b/graphene/types/tests/test_interface.py @@ -3,7 +3,7 @@ from ..interface import Interface from ..unmountedtype import UnmountedType -class MyType(object): +class MyType: pass @@ -57,7 +57,7 @@ def test_generate_interface_unmountedtype(): def test_generate_interface_inherit_abstracttype(): - class MyAbstractType(object): + class MyAbstractType: field1 = MyScalar() class MyInterface(Interface, MyAbstractType): @@ -80,7 +80,7 @@ def test_generate_interface_inherit_interface(): def test_generate_interface_inherit_abstracttype_reversed(): - class MyAbstractType(object): + class MyAbstractType: field1 = MyScalar() class MyInterface(MyAbstractType, Interface): diff --git a/graphene/types/tests/test_mountedtype.py b/graphene/types/tests/test_mountedtype.py index b964233e..2e8e9437 100644 --- a/graphene/types/tests/test_mountedtype.py +++ b/graphene/types/tests/test_mountedtype.py @@ -5,7 +5,7 @@ from ..scalars import String class CustomField(Field): def __init__(self, *args, **kwargs): self.metadata = kwargs.pop("metadata", None) - super(CustomField, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def test_mounted_type(): diff --git a/graphene/types/tests/test_objecttype.py b/graphene/types/tests/test_objecttype.py index 2acb578f..97ae4dad 100644 --- a/graphene/types/tests/test_objecttype.py +++ b/graphene/types/tests/test_objecttype.py @@ -106,7 +106,7 @@ def test_ordered_fields_in_objecttype(): def test_generate_objecttype_inherit_abstracttype(): - class MyAbstractType(object): + class MyAbstractType: field1 = MyScalar() class MyObjectType(ObjectType, MyAbstractType): @@ -120,7 +120,7 @@ def test_generate_objecttype_inherit_abstracttype(): def test_generate_objecttype_inherit_abstracttype_reversed(): - class MyAbstractType(object): + class MyAbstractType: field1 = MyScalar() class MyObjectType(MyAbstractType, ObjectType): diff --git a/graphene/types/tests/test_query.py b/graphene/types/tests/test_query.py index 0885e22b..69b0fa8f 100644 --- a/graphene/types/tests/test_query.py +++ b/graphene/types/tests/test_query.py @@ -28,7 +28,7 @@ def test_query(): def test_query_source(): - class Root(object): + class Root: _hello = "World" def hello(self): @@ -45,10 +45,10 @@ def test_query_source(): def test_query_union(): - class one_object(object): + class one_object: pass - class two_object(object): + class two_object: pass class One(ObjectType): @@ -83,10 +83,10 @@ def test_query_union(): def test_query_interface(): - class one_object(object): + class one_object: pass - class two_object(object): + class two_object: pass class MyInterface(Interface): diff --git a/graphene/types/tests/test_resolver.py b/graphene/types/tests/test_resolver.py index a03cf187..dcadb6d8 100644 --- a/graphene/types/tests/test_resolver.py +++ b/graphene/types/tests/test_resolver.py @@ -13,7 +13,7 @@ info = None demo_dict = {"attr": "value"} -class demo_obj(object): +class demo_obj: attr = "value" diff --git a/graphene/types/tests/test_scalars_serialization.py b/graphene/types/tests/test_scalars_serialization.py index a95e8bd4..a91efe2c 100644 --- a/graphene/types/tests/test_scalars_serialization.py +++ b/graphene/types/tests/test_scalars_serialization.py @@ -38,7 +38,7 @@ def test_serializes_output_string(): assert String.serialize(-1.1) == "-1.1" assert String.serialize(True) == "true" assert String.serialize(False) == "false" - assert String.serialize(u"\U0001F601") == u"\U0001F601" + assert String.serialize("\U0001F601") == "\U0001F601" def test_serializes_output_boolean(): diff --git a/graphene/types/typemap.py b/graphene/types/typemap.py index 9edb8518..d66a3f5e 100644 --- a/graphene/types/typemap.py +++ b/graphene/types/typemap.py @@ -77,7 +77,7 @@ class TypeMap(GraphQLTypeMap): def __init__(self, types, auto_camelcase=True, schema=None): self.auto_camelcase = auto_camelcase self.schema = schema - super(TypeMap, self).__init__(types) + super().__init__(types) def reducer(self, map, type): if not type: diff --git a/graphene/types/union.py b/graphene/types/union.py index 194ba1da..f38d457b 100644 --- a/graphene/types/union.py +++ b/graphene/types/union.py @@ -57,7 +57,7 @@ class Union(UnmountedType, BaseType): _meta = UnionOptions(cls) _meta.types = types - super(Union, cls).__init_subclass_with_meta__(_meta=_meta, **options) + super().__init_subclass_with_meta__(_meta=_meta, **options) @classmethod def get_type(cls): diff --git a/graphene/types/unmountedtype.py b/graphene/types/unmountedtype.py index 081c4ba0..574d3986 100644 --- a/graphene/types/unmountedtype.py +++ b/graphene/types/unmountedtype.py @@ -40,7 +40,7 @@ class UnmountedType(OrderedType): """ def __init__(self, *args, **kwargs): - super(UnmountedType, self).__init__() + super().__init__() self.args = args self.kwargs = kwargs diff --git a/graphene/types/uuid.py b/graphene/types/uuid.py index d6d35eed..e0148b0a 100644 --- a/graphene/types/uuid.py +++ b/graphene/types/uuid.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from uuid import UUID as _UUID from graphql.language import ast diff --git a/graphene/utils/crunch.py b/graphene/utils/crunch.py index a84a0d31..e6d1542a 100644 --- a/graphene/utils/crunch.py +++ b/graphene/utils/crunch.py @@ -3,7 +3,7 @@ import json try: from collections.abc import Mapping except ImportError: - from collections import Mapping + from collections.abc import Mapping def to_key(value): diff --git a/graphene/utils/deduplicator.py b/graphene/utils/deduplicator.py index 57980772..ad0f10e1 100644 --- a/graphene/utils/deduplicator.py +++ b/graphene/utils/deduplicator.py @@ -3,7 +3,7 @@ from collections import OrderedDict try: from collections.abc import Mapping except ImportError: - from collections import Mapping + from collections.abc import Mapping def deflate(node, index=None, path=None): diff --git a/graphene/utils/deprecated.py b/graphene/utils/deprecated.py index 2f98d829..32d30209 100644 --- a/graphene/utils/deprecated.py +++ b/graphene/utils/deprecated.py @@ -2,7 +2,7 @@ import functools import inspect import warnings -string_types = (type(b""), type(u"")) +string_types = (bytes, str) def warn_deprecation(text): @@ -17,7 +17,6 @@ def deprecated(reason): """ if isinstance(reason, string_types): - # The @deprecated is used with a 'reason'. # # .. code-block:: python @@ -27,7 +26,6 @@ def deprecated(reason): # pass def decorator(func1): - if inspect.isclass(func1): fmt1 = "Call to deprecated class {name} ({reason})." else: @@ -43,7 +41,6 @@ def deprecated(reason): return decorator elif inspect.isclass(reason) or inspect.isfunction(reason): - # The @deprecated is used without any 'reason'. # # .. code-block:: python diff --git a/graphene/utils/orderedtype.py b/graphene/utils/orderedtype.py index a58f4d08..294ad54e 100644 --- a/graphene/utils/orderedtype.py +++ b/graphene/utils/orderedtype.py @@ -2,7 +2,7 @@ from functools import total_ordering @total_ordering -class OrderedType(object): +class OrderedType: creation_counter = 1 def __init__(self, _creation_counter=None): @@ -36,4 +36,4 @@ class OrderedType(object): return NotImplemented def __hash__(self): - return hash((self.creation_counter)) + return hash(self.creation_counter) diff --git a/graphene/utils/props.py b/graphene/utils/props.py index 5ef3ba0a..26c697ec 100644 --- a/graphene/utils/props.py +++ b/graphene/utils/props.py @@ -2,7 +2,7 @@ class _OldClass: pass -class _NewClass(object): +class _NewClass: pass diff --git a/graphene/utils/tests/test_str_converters.py b/graphene/utils/tests/test_str_converters.py index 786149d9..761ce4ff 100644 --- a/graphene/utils/tests/test_str_converters.py +++ b/graphene/utils/tests/test_str_converters.py @@ -1,4 +1,3 @@ -# coding: utf-8 from ..str_converters import to_camel_case, to_const, to_snake_case diff --git a/graphene/utils/tests/test_trim_docstring.py b/graphene/utils/tests/test_trim_docstring.py index 704d3997..232836d1 100644 --- a/graphene/utils/tests/test_trim_docstring.py +++ b/graphene/utils/tests/test_trim_docstring.py @@ -2,7 +2,7 @@ from ..trim_docstring import trim_docstring def test_trim_docstring(): - class WellDocumentedObject(object): + class WellDocumentedObject: """ This object is very well-documented. It has multiple lines in its description. @@ -16,7 +16,7 @@ def test_trim_docstring(): "description.\n\nMultiple paragraphs too" ) - class UndocumentedObject(object): + class UndocumentedObject: pass assert trim_docstring(UndocumentedObject.__doc__) is None diff --git a/graphene/utils/thenables.py b/graphene/utils/thenables.py index a3089595..8c77ce82 100644 --- a/graphene/utils/thenables.py +++ b/graphene/utils/thenables.py @@ -9,7 +9,7 @@ try: from promise import Promise, is_thenable # type: ignore except ImportError: - class Promise(object): # type: ignore + class Promise: # type: ignore pass def is_thenable(obj): # type: ignore diff --git a/tests_asyncio/test_relay_mutation.py b/tests_asyncio/test_relay_mutation.py index 42ea5fc7..73348bfd 100644 --- a/tests_asyncio/test_relay_mutation.py +++ b/tests_asyncio/test_relay_mutation.py @@ -6,7 +6,7 @@ from graphene.types.scalars import String from graphene.relay.mutation import ClientIDMutation -class SharedFields(object): +class SharedFields: shared = String()