diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 153980eb..5f72385c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,11 +14,11 @@ repos: - --autofix - id: flake8 - repo: https://github.com/asottile/pyupgrade - rev: v1.2.0 + rev: v1.4.0 hooks: - id: pyupgrade - repo: https://github.com/ambv/black - rev: stable + rev: 18.6b4 hooks: - id: black language_version: python3.6 diff --git a/examples/complex_example.py b/examples/complex_example.py index 18ad89b9..3c2d77ba 100644 --- a/examples/complex_example.py +++ b/examples/complex_example.py @@ -22,7 +22,6 @@ class Query(graphene.ObjectType): class CreateAddress(graphene.Mutation): - class Arguments: geo = GeoInput(required=True) diff --git a/examples/starwars/schema.py b/examples/starwars/schema.py index b4182949..a0595734 100644 --- a/examples/starwars/schema.py +++ b/examples/starwars/schema.py @@ -21,7 +21,6 @@ class Character(graphene.Interface): class Human(graphene.ObjectType): - class Meta: interfaces = (Character,) @@ -29,7 +28,6 @@ class Human(graphene.ObjectType): class Droid(graphene.ObjectType): - class Meta: interfaces = (Character,) diff --git a/examples/starwars_relay/schema.py b/examples/starwars_relay/schema.py index f3ebb09d..3a1cd980 100644 --- a/examples/starwars_relay/schema.py +++ b/examples/starwars_relay/schema.py @@ -18,7 +18,6 @@ class Ship(graphene.ObjectType): class ShipConnection(relay.Connection): - class Meta: node = Ship @@ -44,7 +43,6 @@ class Faction(graphene.ObjectType): class IntroduceShip(relay.ClientIDMutation): - class Input: ship_name = graphene.String(required=True) faction_id = graphene.String(required=True) diff --git a/graphene/pyutils/enum.py b/graphene/pyutils/enum.py index 6ce91b23..84421e04 100644 --- a/graphene/pyutils/enum.py +++ b/graphene/pyutils/enum.py @@ -208,7 +208,7 @@ class EnumMeta(type): invalid_names = set(members) & {"mro"} if invalid_names: raise ValueError( - "Invalid enum member name(s): %s" % (", ".join(invalid_names),) + "Invalid enum member name(s): {}".format(", ".join(invalid_names)) ) # save attributes from super classes so we know if we can take @@ -682,7 +682,7 @@ def __new__(cls, value): for member in cls._member_map_.values(): if member.value == value: return member - raise ValueError("%s is not a valid %s" % (value, cls.__name__)) + raise ValueError("{} is not a valid {}".format(value, cls.__name__)) temp_enum_dict["__new__"] = __new__ @@ -690,7 +690,7 @@ del __new__ def __repr__(self): - return "<%s.%s: %r>" % (self.__class__.__name__, self._name_, self._value_) + return "<{}.{}: {!r}>".format(self.__class__.__name__, self._name_, self._value_) temp_enum_dict["__repr__"] = __repr__ @@ -698,7 +698,7 @@ del __repr__ def __str__(self): - return "%s.%s" % (self.__class__.__name__, self._name_) + return "{}.{}".format(self.__class__.__name__, self._name_) temp_enum_dict["__str__"] = __str__ @@ -907,9 +907,9 @@ def unique(enumeration): duplicates.append((name, member.name)) if duplicates: duplicate_names = ", ".join( - ["%s -> %s" % (alias, name) for (alias, name) in duplicates] + ["{} -> {}".format(alias, name) for (alias, name) in duplicates] ) raise ValueError( - "duplicate names found in %r: %s" % (enumeration, duplicate_names) + "duplicate names found in {!r}: {}".format(enumeration, duplicate_names) ) return enumeration diff --git a/graphene/pyutils/signature.py b/graphene/pyutils/signature.py index 43633f56..c66c2563 100644 --- a/graphene/pyutils/signature.py +++ b/graphene/pyutils/signature.py @@ -186,7 +186,6 @@ class _empty(object): class _ParameterKind(int): - def __new__(self, *args, **kwargs): obj = int.__new__(self, *args) obj._name = kwargs["name"] diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index 421ab502..f23849f2 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -40,7 +40,6 @@ class ConnectionOptions(ObjectTypeOptions): class Connection(ObjectType): - class Meta: abstract = True @@ -88,7 +87,6 @@ class Connection(ObjectType): class IterableConnectionField(Field): - def __init__(self, type, *args, **kwargs): kwargs.setdefault("before", String()) kwargs.setdefault("after", String()) diff --git a/graphene/relay/mutation.py b/graphene/relay/mutation.py index cce49d11..1b8b855e 100644 --- a/graphene/relay/mutation.py +++ b/graphene/relay/mutation.py @@ -8,7 +8,6 @@ from ..types.mutation import Mutation class ClientIDMutation(Mutation): - class Meta: abstract = True @@ -58,7 +57,6 @@ class ClientIDMutation(Mutation): @classmethod def mutate(cls, root, info, input): - def on_resolve(payload): try: payload.client_mutation_id = input.get("client_mutation_id") diff --git a/graphene/relay/node.py b/graphene/relay/node.py index ab8778bf..d9c4c0f6 100644 --- a/graphene/relay/node.py +++ b/graphene/relay/node.py @@ -27,7 +27,6 @@ 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) self.node = node or Node @@ -49,7 +48,6 @@ class GlobalID(Field): class NodeField(Field): - def __init__(self, node, type=False, deprecation_reason=None, name=None, **kwargs): assert issubclass(node, Node), "NodeField can only operate in Nodes" self.node_type = node @@ -68,7 +66,6 @@ class NodeField(Field): class AbstractNode(Interface): - class Meta: abstract = True diff --git a/graphene/relay/tests/test_connection.py b/graphene/relay/tests/test_connection.py index f3dad969..061d6ec9 100644 --- a/graphene/relay/tests/test_connection.py +++ b/graphene/relay/tests/test_connection.py @@ -6,7 +6,6 @@ from ..node import Node class MyObject(ObjectType): - class Meta: interfaces = [Node] @@ -14,7 +13,6 @@ class MyObject(ObjectType): def test_connection(): - class MyObjectConnection(Connection): extra = String() @@ -41,12 +39,10 @@ def test_connection(): def test_connection_inherit_abstracttype(): - class BaseConnection(object): extra = String() class MyObjectConnection(BaseConnection, Connection): - class Meta: node = MyObject @@ -62,7 +58,6 @@ def test_connection_name(): extra = String() class MyObjectConnection(BaseConnection, Connection): - class Meta: node = MyObject name = custom_name @@ -71,9 +66,7 @@ def test_connection_name(): def test_edge(): - class MyObjectConnection(Connection): - class Meta: node = MyObject @@ -93,12 +86,10 @@ def test_edge(): def test_edge_with_bases(): - class BaseEdge(object): extra = String() class MyObjectConnection(Connection): - class Meta: node = MyObject @@ -129,9 +120,7 @@ def test_pageinfo(): def test_connectionfield(): - class MyObjectConnection(Connection): - class Meta: node = MyObject @@ -155,9 +144,7 @@ def test_connectionfield_node_deprecated(): def test_connectionfield_custom_args(): - class MyObjectConnection(Connection): - class Meta: node = MyObject @@ -174,9 +161,7 @@ def test_connectionfield_custom_args(): def test_connectionfield_required(): - class MyObjectConnection(Connection): - class Meta: node = MyObject diff --git a/graphene/relay/tests/test_connection_query.py b/graphene/relay/tests/test_connection_query.py index 12baa2d3..be6ee8c7 100644 --- a/graphene/relay/tests/test_connection_query.py +++ b/graphene/relay/tests/test_connection_query.py @@ -11,7 +11,6 @@ letter_chars = ["A", "B", "C", "D", "E"] class Letter(ObjectType): - class Meta: interfaces = (Node,) @@ -19,7 +18,6 @@ class Letter(ObjectType): class LetterConnection(Connection): - class Meta: node = Letter diff --git a/graphene/relay/tests/test_global_id.py b/graphene/relay/tests/test_global_id.py index 74fd6458..6d328f23 100644 --- a/graphene/relay/tests/test_global_id.py +++ b/graphene/relay/tests/test_global_id.py @@ -6,13 +6,11 @@ from ..node import GlobalID, Node class CustomNode(Node): - class Meta: name = "Node" class User(ObjectType): - class Meta: interfaces = [CustomNode] @@ -20,7 +18,6 @@ class User(ObjectType): class Info(object): - 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 ba51f4a2..b58a3ddf 100644 --- a/graphene/relay/tests/test_mutation.py +++ b/graphene/relay/tests/test_mutation.py @@ -27,7 +27,6 @@ class MyNode(ObjectType): class SaySomething(ClientIDMutation): - class Input: what = String() @@ -46,7 +45,6 @@ class FixedSaySomething(object): class SaySomethingFixed(ClientIDMutation): - class Input: what = String() @@ -58,7 +56,6 @@ class SaySomethingFixed(ClientIDMutation): class SaySomethingPromise(ClientIDMutation): - class Input: what = String() @@ -76,7 +73,6 @@ class MyEdge(ObjectType): class OtherMutation(ClientIDMutation): - class Input(SharedFields): additional_field = String() diff --git a/graphene/relay/tests/test_node.py b/graphene/relay/tests/test_node.py index 26fd73be..fbce1d54 100644 --- a/graphene/relay/tests/test_node.py +++ b/graphene/relay/tests/test_node.py @@ -16,7 +16,6 @@ class SharedNodeFields(object): class MyNode(ObjectType): - class Meta: interfaces = (Node,) diff --git a/graphene/relay/tests/test_node_custom.py b/graphene/relay/tests/test_node_custom.py index 59ecd23f..07e50a1b 100644 --- a/graphene/relay/tests/test_node_custom.py +++ b/graphene/relay/tests/test_node_custom.py @@ -6,7 +6,6 @@ from ..node import Node class CustomNode(Node): - class Meta: name = "Node" @@ -28,7 +27,6 @@ class BasePhoto(Interface): class User(ObjectType): - class Meta: interfaces = [CustomNode] @@ -36,7 +34,6 @@ class User(ObjectType): class Photo(ObjectType): - class Meta: interfaces = [CustomNode, BasePhoto] diff --git a/graphene/test/__init__.py b/graphene/test/__init__.py index ce10ac09..dab3b51b 100644 --- a/graphene/test/__init__.py +++ b/graphene/test/__init__.py @@ -27,7 +27,6 @@ def format_execution_result(execution_result, format_error): class Client(object): - def __init__(self, schema, format_error=None, **execute_options): assert isinstance(schema, Schema) self.schema = schema diff --git a/graphene/tests/issues/test_313.py b/graphene/tests/issues/test_313.py index ab607325..34dfef1a 100644 --- a/graphene/tests/issues/test_313.py +++ b/graphene/tests/issues/test_313.py @@ -16,13 +16,11 @@ class Error(graphene.ObjectType): class CreatePostResult(graphene.Union): - class Meta: types = [Success, Error] class CreatePost(graphene.Mutation): - class Input: text = graphene.String(required=True) diff --git a/graphene/tests/issues/test_356.py b/graphene/tests/issues/test_356.py index e7f4882b..4571aad8 100644 --- a/graphene/tests/issues/test_356.py +++ b/graphene/tests/issues/test_356.py @@ -15,13 +15,11 @@ class SomeTypeTwo(graphene.ObjectType): class MyUnion(graphene.Union): - class Meta: types = (SomeTypeOne, SomeTypeTwo) def test_issue(): - class Query(graphene.ObjectType): things = relay.ConnectionField(MyUnion) diff --git a/graphene/tests/issues/test_425.py b/graphene/tests/issues/test_425.py index 4f367380..50c18758 100644 --- a/graphene/tests/issues/test_425.py +++ b/graphene/tests/issues/test_425.py @@ -12,7 +12,6 @@ class SpecialOptions(ObjectTypeOptions): class SpecialObjectType(ObjectType): - @classmethod def __init_subclass_with_meta__(cls, other_attr="default", **options): _meta = SpecialOptions(cls) @@ -23,9 +22,7 @@ class SpecialObjectType(ObjectType): def test_special_objecttype_could_be_subclassed(): - class MyType(SpecialObjectType): - class Meta: other_attr = "yeah!" @@ -33,7 +30,6 @@ def test_special_objecttype_could_be_subclassed(): def test_special_objecttype_could_be_subclassed_default(): - class MyType(SpecialObjectType): pass @@ -41,7 +37,6 @@ def test_special_objecttype_could_be_subclassed_default(): def test_special_objecttype_inherit_meta_options(): - class MyType(SpecialObjectType): pass @@ -56,7 +51,6 @@ class SpecialInputObjectTypeOptions(ObjectTypeOptions): class SpecialInputObjectType(InputObjectType): - @classmethod def __init_subclass_with_meta__(cls, other_attr="default", **options): _meta = SpecialInputObjectTypeOptions(cls) @@ -67,9 +61,7 @@ class SpecialInputObjectType(InputObjectType): def test_special_inputobjecttype_could_be_subclassed(): - class MyInputObjectType(SpecialInputObjectType): - class Meta: other_attr = "yeah!" @@ -77,7 +69,6 @@ def test_special_inputobjecttype_could_be_subclassed(): def test_special_inputobjecttype_could_be_subclassed_default(): - class MyInputObjectType(SpecialInputObjectType): pass @@ -85,7 +76,6 @@ def test_special_inputobjecttype_could_be_subclassed_default(): def test_special_inputobjecttype_inherit_meta_options(): - class MyInputObjectType(SpecialInputObjectType): pass @@ -98,7 +88,6 @@ class SpecialEnumOptions(EnumOptions): class SpecialEnum(Enum): - @classmethod def __init_subclass_with_meta__(cls, other_attr="default", **options): _meta = SpecialEnumOptions(cls) @@ -107,9 +96,7 @@ class SpecialEnum(Enum): def test_special_enum_could_be_subclassed(): - class MyEnum(SpecialEnum): - class Meta: other_attr = "yeah!" @@ -117,7 +104,6 @@ def test_special_enum_could_be_subclassed(): def test_special_enum_could_be_subclassed_default(): - class MyEnum(SpecialEnum): pass @@ -125,7 +111,6 @@ def test_special_enum_could_be_subclassed_default(): def test_special_enum_inherit_meta_options(): - class MyEnum(SpecialEnum): pass diff --git a/graphene/tests/issues/test_720.py b/graphene/tests/issues/test_720.py index 8ac611ee..ea961b25 100644 --- a/graphene/tests/issues/test_720.py +++ b/graphene/tests/issues/test_720.py @@ -7,7 +7,6 @@ import graphene class MyInputClass(graphene.InputObjectType): - @classmethod def __init_subclass_with_meta__( cls, container=None, _meta=None, fields=None, **options @@ -21,7 +20,6 @@ class MyInputClass(graphene.InputObjectType): class MyInput(MyInputClass): - class Meta: fields = dict(x=graphene.Field(graphene.Int)) diff --git a/graphene/types/abstracttype.py b/graphene/types/abstracttype.py index 9d84d819..4eeb7f9c 100644 --- a/graphene/types/abstracttype.py +++ b/graphene/types/abstracttype.py @@ -3,7 +3,6 @@ from ..utils.subclass_with_meta import SubclassWithMeta class AbstractType(SubclassWithMeta): - def __init_subclass__(cls, *args, **kwargs): warn_deprecation( "Abstract type is deprecated, please use normal object inheritance instead.\n" diff --git a/graphene/types/argument.py b/graphene/types/argument.py index 20ea84b7..9c75bcee 100644 --- a/graphene/types/argument.py +++ b/graphene/types/argument.py @@ -8,7 +8,6 @@ from .utils import get_type class Argument(MountedType): - def __init__( self, type, diff --git a/graphene/types/base.py b/graphene/types/base.py index 3c37b8dd..aa97ed22 100644 --- a/graphene/types/base.py +++ b/graphene/types/base.py @@ -25,7 +25,6 @@ class BaseOptions(object): class BaseType(SubclassWithMeta): - @classmethod def create_type(cls, class_name, **options): return type(class_name, (cls,), {"Meta": options}) diff --git a/graphene/types/context.py b/graphene/types/context.py index dba51958..bac2073c 100644 --- a/graphene/types/context.py +++ b/graphene/types/context.py @@ -1,5 +1,4 @@ class Context(object): - def __init__(self, **params): for key, value in params.items(): setattr(self, key, value) diff --git a/graphene/types/enum.py b/graphene/types/enum.py index 96a322ad..6e6bab8f 100644 --- a/graphene/types/enum.py +++ b/graphene/types/enum.py @@ -24,7 +24,6 @@ class EnumOptions(BaseOptions): class EnumMeta(SubclassWithMeta_Meta): - def __new__(cls, name, bases, classdict, **options): enum_members = OrderedDict(classdict, __eq__=eq_enum) # We remove the Meta attribute from the class to not collide @@ -63,7 +62,6 @@ class EnumMeta(SubclassWithMeta_Meta): class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)): - @classmethod def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options): if not _meta: diff --git a/graphene/types/field.py b/graphene/types/field.py index 5db5530e..a1428632 100644 --- a/graphene/types/field.py +++ b/graphene/types/field.py @@ -19,7 +19,6 @@ def source_resolver(source, root, info, **args): class Field(MountedType): - def __init__( self, type, diff --git a/graphene/types/inputfield.py b/graphene/types/inputfield.py index df6285b5..cdfea114 100644 --- a/graphene/types/inputfield.py +++ b/graphene/types/inputfield.py @@ -4,7 +4,6 @@ from .utils import get_type class InputField(MountedType): - def __init__( self, type, diff --git a/graphene/types/inputobjecttype.py b/graphene/types/inputobjecttype.py index dc6e0048..8116a827 100644 --- a/graphene/types/inputobjecttype.py +++ b/graphene/types/inputobjecttype.py @@ -17,7 +17,6 @@ class InputObjectTypeOptions(BaseOptions): class InputObjectTypeContainer(dict, BaseType): - class Meta: abstract = True diff --git a/graphene/types/mountedtype.py b/graphene/types/mountedtype.py index 47c828b9..6d0c8cf8 100644 --- a/graphene/types/mountedtype.py +++ b/graphene/types/mountedtype.py @@ -3,7 +3,6 @@ from .unmountedtype import UnmountedType class MountedType(OrderedType): - @classmethod def mounted(cls, unmounted): # noqa: N802 """ diff --git a/graphene/types/tests/test_abstracttype.py b/graphene/types/tests/test_abstracttype.py index 6fee3b11..41470383 100644 --- a/graphene/types/tests/test_abstracttype.py +++ b/graphene/types/tests/test_abstracttype.py @@ -10,7 +10,6 @@ class MyType(ObjectType): class MyScalar(UnmountedType): - def get_type(self): return MyType @@ -25,7 +24,6 @@ def test_abstract_objecttype_warn_deprecation(mocker): def test_generate_objecttype_inherit_abstracttype(): - class MyAbstractType(AbstractType): field1 = MyScalar() diff --git a/graphene/types/tests/test_base.py b/graphene/types/tests/test_base.py index d42d54fb..2f70903c 100644 --- a/graphene/types/tests/test_base.py +++ b/graphene/types/tests/test_base.py @@ -6,7 +6,6 @@ class CustomOptions(BaseOptions): class CustomType(BaseType): - @classmethod def __init_subclass_with_meta__(cls, **options): _meta = CustomOptions(cls) @@ -14,7 +13,6 @@ class CustomType(BaseType): def test_basetype(): - class MyBaseType(CustomType): pass @@ -24,7 +22,6 @@ def test_basetype(): def test_basetype_nones(): - class MyBaseType(CustomType): """Documentation""" @@ -38,7 +35,6 @@ def test_basetype_nones(): def test_basetype_custom(): - class MyBaseType(CustomType): """Documentation""" diff --git a/graphene/types/tests/test_definition.py b/graphene/types/tests/test_definition.py index 2cff3002..347de9c9 100644 --- a/graphene/types/tests/test_definition.py +++ b/graphene/types/tests/test_definition.py @@ -56,7 +56,6 @@ class MyInterface(Interface): class MyUnion(Union): - class Meta: types = (Article,) @@ -116,7 +115,6 @@ def test_defines_a_subscription_schema(): def test_includes_nested_input_objects_in_the_map(): - class NestedInputObject(InputObjectType): value = String() @@ -135,12 +133,10 @@ def test_includes_nested_input_objects_in_the_map(): def test_includes_interfaces_thunk_subtypes_in_the_type_map(): - class SomeInterface(Interface): f = Int() class SomeSubtype(ObjectType): - class Meta: interfaces = (SomeInterface,) @@ -153,7 +149,6 @@ def test_includes_interfaces_thunk_subtypes_in_the_type_map(): def test_includes_types_in_union(): - class SomeType(ObjectType): a = String() @@ -161,7 +156,6 @@ def test_includes_types_in_union(): b = String() class MyUnion(Union): - class Meta: types = (SomeType, OtherType) @@ -175,7 +169,6 @@ def test_includes_types_in_union(): def test_maps_enum(): - class SomeType(ObjectType): a = String() @@ -183,7 +176,6 @@ def test_maps_enum(): b = String() class MyUnion(Union): - class Meta: types = (SomeType, OtherType) @@ -197,12 +189,10 @@ def test_maps_enum(): def test_includes_interfaces_subtypes_in_the_type_map(): - class SomeInterface(Interface): f = Int() class SomeSubtype(ObjectType): - class Meta: interfaces = (SomeInterface,) @@ -293,7 +283,6 @@ def test_stringifies_simple_types(): def test_does_not_mutate_passed_field_definitions(): - class CommonFields(object): field1 = String() field2 = String(id=String()) diff --git a/graphene/types/tests/test_dynamic.py b/graphene/types/tests/test_dynamic.py index f2c4c627..3b5f7a3b 100644 --- a/graphene/types/tests/test_dynamic.py +++ b/graphene/types/tests/test_dynamic.py @@ -30,7 +30,6 @@ def test_list_non_null(): def test_partial(): - def __type(_type): return _type diff --git a/graphene/types/tests/test_enum.py b/graphene/types/tests/test_enum.py index 081ccc62..6086f54c 100644 --- a/graphene/types/tests/test_enum.py +++ b/graphene/types/tests/test_enum.py @@ -8,9 +8,9 @@ from ..schema import ObjectType, Schema def test_enum_construction(): - class RGB(Enum): """Description""" + RED = 1 GREEN = 2 BLUE = 3 @@ -32,9 +32,7 @@ def test_enum_construction(): def test_enum_construction_meta(): - class RGB(Enum): - class Meta: name = "RGBEnum" description = "Description" @@ -65,7 +63,6 @@ def test_enum_from_builtin_enum(): def test_enum_from_builtin_enum_accepts_lambda_description(): - def custom_description(value): if not value: return "StarWars Episodes" @@ -125,6 +122,7 @@ def test_enum_from_python3_enum_uses_enum_doc(): class Color(PyEnum): """This is the description""" + RED = 1 GREEN = 2 BLUE = 3 @@ -139,7 +137,6 @@ def test_enum_from_python3_enum_uses_enum_doc(): def test_enum_value_from_class(): - class RGB(Enum): RED = 1 GREEN = 2 @@ -151,7 +148,6 @@ def test_enum_value_from_class(): def test_enum_value_as_unmounted_field(): - class RGB(Enum): RED = 1 GREEN = 2 @@ -164,7 +160,6 @@ def test_enum_value_as_unmounted_field(): def test_enum_value_as_unmounted_inputfield(): - class RGB(Enum): RED = 1 GREEN = 2 @@ -177,7 +172,6 @@ def test_enum_value_as_unmounted_inputfield(): def test_enum_value_as_unmounted_argument(): - class RGB(Enum): RED = 1 GREEN = 2 @@ -190,7 +184,6 @@ def test_enum_value_as_unmounted_argument(): def test_enum_can_be_compared(): - class RGB(Enum): RED = 1 GREEN = 2 @@ -202,7 +195,6 @@ def test_enum_can_be_compared(): def test_enum_can_be_initialzied(): - class RGB(Enum): RED = 1 GREEN = 2 @@ -214,7 +206,6 @@ def test_enum_can_be_initialzied(): def test_enum_can_retrieve_members(): - class RGB(Enum): RED = 1 GREEN = 2 @@ -226,7 +217,6 @@ def test_enum_can_retrieve_members(): def test_enum_to_enum_comparison_should_differ(): - class RGB1(Enum): RED = 1 GREEN = 2 @@ -243,9 +233,7 @@ def test_enum_to_enum_comparison_should_differ(): def test_enum_skip_meta_from_members(): - class RGB1(Enum): - class Meta: name = "RGB" diff --git a/graphene/types/tests/test_inputobjecttype.py b/graphene/types/tests/test_inputobjecttype.py index 0100cf42..d565ff40 100644 --- a/graphene/types/tests/test_inputobjecttype.py +++ b/graphene/types/tests/test_inputobjecttype.py @@ -14,13 +14,11 @@ class MyType(object): class MyScalar(UnmountedType): - def get_type(self): return MyType def test_generate_inputobjecttype(): - class MyInputObjectType(InputObjectType): """Documentation""" @@ -30,9 +28,7 @@ def test_generate_inputobjecttype(): def test_generate_inputobjecttype_with_meta(): - class MyInputObjectType(InputObjectType): - class Meta: name = "MyOtherInputObjectType" description = "Documentation" @@ -42,7 +38,6 @@ def test_generate_inputobjecttype_with_meta(): def test_generate_inputobjecttype_with_fields(): - class MyInputObjectType(InputObjectType): field = Field(MyType) @@ -50,7 +45,6 @@ def test_generate_inputobjecttype_with_fields(): def test_ordered_fields_in_inputobjecttype(): - class MyInputObjectType(InputObjectType): b = InputField(MyType) a = InputField(MyType) @@ -61,7 +55,6 @@ def test_ordered_fields_in_inputobjecttype(): def test_generate_inputobjecttype_unmountedtype(): - class MyInputObjectType(InputObjectType): field = MyScalar(MyType) @@ -70,7 +63,6 @@ def test_generate_inputobjecttype_unmountedtype(): def test_generate_inputobjecttype_as_argument(): - class MyInputObjectType(InputObjectType): field = MyScalar() @@ -87,7 +79,6 @@ def test_generate_inputobjecttype_as_argument(): def test_generate_inputobjecttype_inherit_abstracttype(): - class MyAbstractType(object): field1 = MyScalar(MyType) @@ -102,7 +93,6 @@ def test_generate_inputobjecttype_inherit_abstracttype(): def test_generate_inputobjecttype_inherit_abstracttype_reversed(): - class MyAbstractType(object): field1 = MyScalar(MyType) @@ -117,7 +107,6 @@ def test_generate_inputobjecttype_inherit_abstracttype_reversed(): def test_inputobjecttype_of_input(): - class Child(InputObjectType): first_name = String() last_name = String() diff --git a/graphene/types/tests/test_interface.py b/graphene/types/tests/test_interface.py index 4657b437..b524296b 100644 --- a/graphene/types/tests/test_interface.py +++ b/graphene/types/tests/test_interface.py @@ -8,13 +8,11 @@ class MyType(object): class MyScalar(UnmountedType): - def get_type(self): return MyType def test_generate_interface(): - class MyInterface(Interface): """Documentation""" @@ -24,9 +22,7 @@ def test_generate_interface(): def test_generate_interface_with_meta(): - class MyInterface(Interface): - class Meta: name = "MyOtherInterface" description = "Documentation" @@ -36,7 +32,6 @@ def test_generate_interface_with_meta(): def test_generate_interface_with_fields(): - class MyInterface(Interface): field = Field(MyType) @@ -44,7 +39,6 @@ def test_generate_interface_with_fields(): def test_ordered_fields_in_interface(): - class MyInterface(Interface): b = Field(MyType) a = Field(MyType) @@ -55,7 +49,6 @@ def test_ordered_fields_in_interface(): def test_generate_interface_unmountedtype(): - class MyInterface(Interface): field = MyScalar() @@ -64,7 +57,6 @@ def test_generate_interface_unmountedtype(): def test_generate_interface_inherit_abstracttype(): - class MyAbstractType(object): field1 = MyScalar() @@ -76,7 +68,6 @@ def test_generate_interface_inherit_abstracttype(): def test_generate_interface_inherit_interface(): - class MyBaseInterface(Interface): field1 = MyScalar() @@ -89,7 +80,6 @@ def test_generate_interface_inherit_interface(): def test_generate_interface_inherit_abstracttype_reversed(): - class MyAbstractType(object): field1 = MyScalar() diff --git a/graphene/types/tests/test_mountedtype.py b/graphene/types/tests/test_mountedtype.py index c510aee4..787bee56 100644 --- a/graphene/types/tests/test_mountedtype.py +++ b/graphene/types/tests/test_mountedtype.py @@ -4,7 +4,6 @@ from ..scalars import String class CustomField(Field): - def __init__(self, *args, **kwargs): self.metadata = kwargs.pop("metadata", None) super(CustomField, self).__init__(*args, **kwargs) diff --git a/graphene/types/tests/test_mutation.py b/graphene/types/tests/test_mutation.py index 6268192a..3ecefe2f 100644 --- a/graphene/types/tests/test_mutation.py +++ b/graphene/types/tests/test_mutation.py @@ -10,7 +10,6 @@ from ..structures import NonNull def test_generate_mutation_no_args(): - class MyMutation(Mutation): """Documentation""" @@ -25,9 +24,7 @@ def test_generate_mutation_no_args(): def test_generate_mutation_with_meta(): - class MyMutation(Mutation): - class Meta: name = "MyOtherMutation" description = "Documentation" @@ -51,12 +48,10 @@ def test_mutation_raises_exception_if_no_mutate(): def test_mutation_custom_output_type(): - class User(ObjectType): name = String() class CreateUser(Mutation): - class Arguments: name = String() @@ -74,9 +69,7 @@ def test_mutation_custom_output_type(): def test_mutation_execution(): - class CreateUser(Mutation): - class Arguments: name = String() dynamic = Dynamic(lambda: String()) @@ -109,7 +102,6 @@ def test_mutation_execution(): def test_mutation_no_fields_output(): - class CreateUser(Mutation): name = String() @@ -136,9 +128,7 @@ def test_mutation_no_fields_output(): def test_mutation_allow_to_have_custom_args(): - class CreateUser(Mutation): - class Arguments: name = String() diff --git a/graphene/types/tests/test_objecttype.py b/graphene/types/tests/test_objecttype.py index 4c6fabd4..2acb578f 100644 --- a/graphene/types/tests/test_objecttype.py +++ b/graphene/types/tests/test_objecttype.py @@ -23,7 +23,6 @@ class MyInterface(Interface): class ContainerWithInterface(ObjectType): - class Meta: interfaces = (MyInterface,) @@ -32,13 +31,11 @@ class ContainerWithInterface(ObjectType): class MyScalar(UnmountedType): - def get_type(self): return MyType def test_generate_objecttype(): - class MyObjectType(ObjectType): """Documentation""" @@ -53,9 +50,7 @@ def test_generate_objecttype(): def test_generate_objecttype_with_meta(): - class MyObjectType(ObjectType): - class Meta: name = "MyOtherObjectType" description = "Documentation" @@ -67,7 +62,6 @@ def test_generate_objecttype_with_meta(): def test_generate_lazy_objecttype(): - class MyObjectType(ObjectType): example = Field(lambda: InnerObjectType, required=True) @@ -81,7 +75,6 @@ def test_generate_lazy_objecttype(): def test_generate_objecttype_with_fields(): - class MyObjectType(ObjectType): field = Field(MyType) @@ -89,7 +82,6 @@ def test_generate_objecttype_with_fields(): def test_generate_objecttype_with_private_attributes(): - class MyObjectType(ObjectType): _private_state = None @@ -104,7 +96,6 @@ def test_generate_objecttype_with_private_attributes(): def test_ordered_fields_in_objecttype(): - class MyObjectType(ObjectType): b = Field(MyType) a = Field(MyType) @@ -115,7 +106,6 @@ def test_ordered_fields_in_objecttype(): def test_generate_objecttype_inherit_abstracttype(): - class MyAbstractType(object): field1 = MyScalar() @@ -130,7 +120,6 @@ def test_generate_objecttype_inherit_abstracttype(): def test_generate_objecttype_inherit_abstracttype_reversed(): - class MyAbstractType(object): field1 = MyScalar() @@ -145,7 +134,6 @@ def test_generate_objecttype_inherit_abstracttype_reversed(): def test_generate_objecttype_unmountedtype(): - class MyObjectType(ObjectType): field = MyScalar() @@ -205,14 +193,12 @@ def test_objecttype_as_container_invalid_kwargs(): def test_objecttype_container_benchmark(benchmark): - @benchmark def create_objecttype(): Container(field1="field1", field2="field2") def test_generate_objecttype_description(): - class MyObjectType(ObjectType): """ Documentation @@ -224,9 +210,7 @@ def test_generate_objecttype_description(): def test_objecttype_with_possible_types(): - class MyObjectType(ObjectType): - class Meta: possible_types = (dict,) @@ -237,7 +221,6 @@ def test_objecttype_with_possible_types_and_is_type_of_should_raise(): with pytest.raises(AssertionError) as excinfo: class MyObjectType(ObjectType): - class Meta: possible_types = (dict,) @@ -252,7 +235,6 @@ def test_objecttype_with_possible_types_and_is_type_of_should_raise(): def test_objecttype_no_fields_output(): - class User(ObjectType): name = String() @@ -276,9 +258,7 @@ def test_objecttype_no_fields_output(): def test_abstract_objecttype_can_str(): - class MyObjectType(ObjectType): - class Meta: abstract = True diff --git a/graphene/types/tests/test_query.py b/graphene/types/tests/test_query.py index 0535e4e7..9f693a52 100644 --- a/graphene/types/tests/test_query.py +++ b/graphene/types/tests/test_query.py @@ -17,7 +17,6 @@ from ..union import Union def test_query(): - class Query(ObjectType): hello = String(resolver=lambda *_: "World") @@ -29,7 +28,6 @@ def test_query(): def test_query_source(): - class Root(object): _hello = "World" @@ -47,7 +45,6 @@ def test_query_source(): def test_query_union(): - class one_object(object): pass @@ -69,7 +66,6 @@ def test_query_union(): return isinstance(root, two_object) class MyUnion(Union): - class Meta: types = (One, Two) @@ -87,7 +83,6 @@ def test_query_union(): def test_query_interface(): - class one_object(object): pass @@ -98,7 +93,6 @@ def test_query_interface(): base = String() class One(ObjectType): - class Meta: interfaces = (MyInterface,) @@ -109,7 +103,6 @@ def test_query_interface(): return isinstance(root, one_object) class Two(ObjectType): - class Meta: interfaces = (MyInterface,) @@ -135,7 +128,6 @@ def test_query_interface(): def test_query_dynamic(): - class Query(ObjectType): hello = Dynamic(lambda: String(resolver=lambda *_: "World")) hellos = Dynamic(lambda: List(String, resolver=lambda *_: ["Worlds"])) @@ -153,7 +145,6 @@ def test_query_dynamic(): def test_query_default_value(): - class MyType(ObjectType): field = String() @@ -168,7 +159,6 @@ def test_query_default_value(): def test_query_wrong_default_value(): - class MyType(ObjectType): field = String() @@ -191,7 +181,6 @@ def test_query_wrong_default_value(): def test_query_default_value_ignored_by_resolver(): - class MyType(ObjectType): field = String() @@ -210,7 +199,6 @@ def test_query_default_value_ignored_by_resolver(): def test_query_resolve_function(): - class Query(ObjectType): hello = String() @@ -225,7 +213,6 @@ def test_query_resolve_function(): def test_query_arguments(): - class Query(ObjectType): test = String(a_str=String(), a_int=Int()) @@ -251,7 +238,6 @@ def test_query_arguments(): def test_query_input_field(): - class Input(InputObjectType): a_field = String() recursive_field = InputField(lambda: Input) @@ -282,7 +268,6 @@ def test_query_input_field(): def test_query_middlewares(): - class Query(ObjectType): hello = String() other = String() @@ -307,9 +292,7 @@ def test_query_middlewares(): def test_objecttype_on_instances(): - class Ship: - def __init__(self, name): self.name = name @@ -369,7 +352,6 @@ def test_big_list_query_compiled_query_benchmark(benchmark): def test_big_list_of_containers_query_benchmark(benchmark): - class Container(ObjectType): x = Int() @@ -390,7 +372,6 @@ def test_big_list_of_containers_query_benchmark(benchmark): def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark): - class Container(ObjectType): x = Int() y = Int() @@ -420,7 +401,6 @@ def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark): def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark( benchmark ): - class Container(ObjectType): x = Int() y = Int() diff --git a/graphene/types/tests/test_scalar.py b/graphene/types/tests/test_scalar.py index fb20980d..1ec986cd 100644 --- a/graphene/types/tests/test_scalar.py +++ b/graphene/types/tests/test_scalar.py @@ -3,7 +3,6 @@ from ..scalars import Scalar def test_scalar(): - class JSONScalar(Scalar): """Documentation""" diff --git a/graphene/types/tests/test_typemap.py b/graphene/types/tests/test_typemap.py index 0f60986b..f713726f 100644 --- a/graphene/types/tests/test_typemap.py +++ b/graphene/types/tests/test_typemap.py @@ -24,9 +24,9 @@ from ..typemap import TypeMap, resolve_type def test_enum(): - class MyEnum(Enum): """Description""" + foo = 1 bar = 2 @@ -58,9 +58,9 @@ def test_enum(): def test_objecttype(): - class MyObjectType(ObjectType): """Description""" + foo = String( bar=String(description="Argument description", default_value="x"), description="Field description", @@ -94,9 +94,9 @@ def test_objecttype(): def test_dynamic_objecttype(): - class MyObjectType(ObjectType): """Description""" + bar = Dynamic(lambda: Field(String)) own = Field(lambda: MyObjectType) @@ -112,9 +112,9 @@ def test_dynamic_objecttype(): def test_interface(): - class MyInterface(Interface): """Description""" + foo = String( bar=String(description="Argument description", default_value="x"), description="Field description", @@ -151,7 +151,6 @@ def test_interface(): def test_inputobject(): - class OtherObjectType(InputObjectType): thingy = NonNull(Int) @@ -161,6 +160,7 @@ def test_inputobject(): class MyInputObjectType(InputObjectType): """Description""" + foo_bar = String(description="Field description") bar = String(name="gizmo") baz = NonNull(MyInnerObjectType) @@ -210,9 +210,9 @@ def test_inputobject(): def test_objecttype_camelcase(): - class MyObjectType(ObjectType): """Description""" + foo_bar = String(bar_foo=String()) typemap = TypeMap([MyObjectType]) @@ -232,9 +232,9 @@ def test_objecttype_camelcase(): def test_objecttype_camelcase_disabled(): - class MyObjectType(ObjectType): """Description""" + foo_bar = String(bar_foo=String()) typemap = TypeMap([MyObjectType], auto_camelcase=False) @@ -254,7 +254,6 @@ def test_objecttype_camelcase_disabled(): def test_objecttype_with_possible_types(): - class MyObjectType(ObjectType): """Description""" @@ -271,7 +270,6 @@ def test_objecttype_with_possible_types(): def test_resolve_type_with_missing_type(): - class MyObjectType(ObjectType): foo_bar = String() diff --git a/graphene/types/tests/test_union.py b/graphene/types/tests/test_union.py index 8d46b00b..256c7d95 100644 --- a/graphene/types/tests/test_union.py +++ b/graphene/types/tests/test_union.py @@ -15,7 +15,6 @@ class MyObjectType2(ObjectType): def test_generate_union(): - class MyUnion(Union): """Documentation""" @@ -28,9 +27,7 @@ def test_generate_union(): def test_generate_union_with_meta(): - class MyUnion(Union): - class Meta: name = "MyOtherUnion" description = "Documentation" @@ -50,9 +47,7 @@ def test_generate_union_with_no_types(): def test_union_can_be_mounted(): - class MyUnion(Union): - class Meta: types = (MyObjectType1, MyObjectType2) diff --git a/graphene/types/typemap.py b/graphene/types/typemap.py index cb44175a..dce04445 100644 --- a/graphene/types/typemap.py +++ b/graphene/types/typemap.py @@ -74,7 +74,6 @@ def is_type_of_from_possible_types(possible_types, root, info): class TypeMap(GraphQLTypeMap): - def __init__(self, types, auto_camelcase=True, schema=None): self.auto_camelcase = auto_camelcase self.schema = schema diff --git a/graphene/utils/resolve_only_args.py b/graphene/utils/resolve_only_args.py index 009d17ac..5efff2ed 100644 --- a/graphene/utils/resolve_only_args.py +++ b/graphene/utils/resolve_only_args.py @@ -5,7 +5,6 @@ from .deprecated import deprecated @deprecated("This function is deprecated") def resolve_only_args(func): - @wraps(func) def wrapped_func(root, info, **args): return func(root, **args) diff --git a/graphene/utils/subclass_with_meta.py b/graphene/utils/subclass_with_meta.py index 9905feb2..01fc5375 100644 --- a/graphene/utils/subclass_with_meta.py +++ b/graphene/utils/subclass_with_meta.py @@ -20,6 +20,7 @@ class SubclassWithMeta_Meta(InitSubclassMeta): class SubclassWithMeta(six.with_metaclass(SubclassWithMeta_Meta)): """This class improves __init_subclass__ to receive automatically the options from meta""" + # We will only have the metaclass in Python 2 def __init_subclass__(cls, **meta_options): """This method just terminates the super() chain""" diff --git a/graphene/utils/tests/test_deduplicator.py b/graphene/utils/tests/test_deduplicator.py index d65f6fd0..604ae438 100644 --- a/graphene/utils/tests/test_deduplicator.py +++ b/graphene/utils/tests/test_deduplicator.py @@ -106,9 +106,7 @@ TEST_DATA = { def test_example_end_to_end(): - class Movie(graphene.ObjectType): - class Meta: interfaces = (relay.Node,) default_resolver = dict_resolver @@ -117,7 +115,6 @@ def test_example_end_to_end(): synopsis = graphene.String(required=True) class Event(graphene.ObjectType): - class Meta: interfaces = (relay.Node,) default_resolver = dict_resolver diff --git a/graphene/utils/tests/test_trim_docstring.py b/graphene/utils/tests/test_trim_docstring.py index ab84d829..704d3997 100644 --- a/graphene/utils/tests/test_trim_docstring.py +++ b/graphene/utils/tests/test_trim_docstring.py @@ -2,7 +2,6 @@ from ..trim_docstring import trim_docstring def test_trim_docstring(): - class WellDocumentedObject(object): """ This object is very well-documented. It has multiple lines in its