diff --git a/graphene/pyutils/version.py b/graphene/pyutils/version.py index a0b0d2ba..ed2d16b1 100644 --- a/graphene/pyutils/version.py +++ b/graphene/pyutils/version.py @@ -46,12 +46,11 @@ def get_complete_version(version=None): from graphene import VERSION as version else: raise_assertion_if_not( - condition=len(version) is 5, - message="Wrong tuple provided" + condition=len(version) is 5, message="Wrong tuple provided" ) raise_assertion_if_not( condition=version[3] in ("alpha", "beta", "rc", "final"), - message="Version not correct." + message="Version not correct.", ) return version diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index 968242ed..3a96a447 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -55,7 +55,7 @@ class Connection(ObjectType): _meta = ConnectionOptions(cls) raise_assertion_if_not( condition=node, - message="You have to provide a node in {}.Meta".format(cls.__name__) + message="You have to provide a node in {}.Meta".format(cls.__name__), ) raise_assertion_if_not( condition=issubclass( @@ -63,7 +63,7 @@ class Connection(ObjectType): ), message=('Received incompatible node "{}" for Connection {}.').format( node, cls.__name__ - ) + ), ) base_name = re.sub("Connection$", "", name or cls.__name__) or node._meta.name @@ -143,7 +143,7 @@ class IterableConnectionField(Field): condition=issubclass(connection_type, Connection), message='{} type have to be a subclass of Connection. Received "{}".'.format( self.__class__.__name__, connection_type - ) + ), ) return type @@ -159,7 +159,7 @@ class IterableConnectionField(Field): Received "{}" """.format( connection_type, resolved - ) + ), ) connection = connection_from_list( diff --git a/graphene/relay/mutation.py b/graphene/relay/mutation.py index 23e0f655..792230c7 100644 --- a/graphene/relay/mutation.py +++ b/graphene/relay/mutation.py @@ -17,14 +17,10 @@ class ClientIDMutation(Mutation): input_class = getattr(cls, "Input", None) base_name = re.sub("Payload$", "", name or cls.__name__) - raise_assertion_if_not( - condition=not output, - message="Can't specify any output" - ) + raise_assertion_if_not(condition=not output, message="Can't specify any output") raise_assertion_if_not( - condition=not arguments, - message="Can't specify any arguments" + condition=not arguments, message="Can't specify any arguments" ) bases = (InputObjectType,) @@ -50,10 +46,8 @@ class ClientIDMutation(Mutation): if cls.mutate and cls.mutate.__func__ == ClientIDMutation.mutate.__func__: raise_assertion_if_not( condition=mutate_and_get_payload, - message="{name}.mutate_and_get_payload method is required" \ - " in a ClientIDMutation.".format( - name=name or cls.__name__ - ) + message="{name}.mutate_and_get_payload method is required" + " in a ClientIDMutation.".format(name=name or cls.__name__), ) if not name: diff --git a/graphene/relay/node.py b/graphene/relay/node.py index 50c1fccb..d9c4c0f6 100644 --- a/graphene/relay/node.py +++ b/graphene/relay/node.py @@ -7,7 +7,6 @@ from graphql_relay import from_global_id, to_global_id from ..types import ID, Field, Interface, ObjectType from ..types.interface import InterfaceOptions from ..types.utils import get_type -from ..utils.comparison_helper import raise_assertion_if_not def is_node(objecttype): diff --git a/graphene/types/argument.py b/graphene/types/argument.py index e34133bb..11a37767 100644 --- a/graphene/types/argument.py +++ b/graphene/types/argument.py @@ -76,9 +76,7 @@ def to_arguments(args, extra_args=None): arg_name = default_name or arg.name raise_assertion_if_not( condition=arg_name not in arguments, - message='More than one Argument have same name "{}".'.format( - arg_name - ) + message='More than one Argument have same name "{}".'.format(arg_name), ) arguments[arg_name] = arg diff --git a/graphene/types/base.py b/graphene/types/base.py index a2d74509..852737bf 100644 --- a/graphene/types/base.py +++ b/graphene/types/base.py @@ -33,8 +33,7 @@ class BaseType(SubclassWithMeta): @classmethod def __init_subclass_with_meta__(cls, name=None, description=None, _meta=None): raise_assertion_if_not( - condition="_meta" not in cls.__dict__, - message="Can't assign directly meta" + condition="_meta" not in cls.__dict__, message="Can't assign directly meta" ) if not _meta: return diff --git a/graphene/types/datetime.py b/graphene/types/datetime.py index f7f60519..61d42b75 100644 --- a/graphene/types/datetime.py +++ b/graphene/types/datetime.py @@ -22,7 +22,7 @@ class Date(Scalar): date = date.date() raise_assertion_if_not( condition=isinstance(date, datetime.date), - message='Received not compatible date "{}"'.format(repr(date)) + message='Received not compatible date "{}"'.format(repr(date)), ) return date.isoformat() @@ -50,7 +50,7 @@ class DateTime(Scalar): def serialize(dt): raise_assertion_if_not( condition=isinstance(dt, (datetime.datetime, datetime.date)), - message='Received not compatible datetime "{}"'.format(repr(dt)) + message='Received not compatible datetime "{}"'.format(repr(dt)), ) return dt.isoformat() @@ -78,8 +78,8 @@ class Time(Scalar): def serialize(time): raise_assertion_if_not( condition=isinstance(time, datetime.time), - message='Received not compatible time "{}"'.format(repr(time)) - ) + message='Received not compatible time "{}"'.format(repr(time)), + ) return time.isoformat() @classmethod diff --git a/graphene/types/field.py b/graphene/types/field.py index 3582a242..e0e009a2 100644 --- a/graphene/types/field.py +++ b/graphene/types/field.py @@ -39,19 +39,19 @@ class Field(MountedType): condition=not args or isinstance(args, Mapping), message='Arguments in a field have to be a mapping, received "{}".'.format( args - ) + ), ) raise_assertion_if_not( - condition=not(source and resolver), - message="A Field cannot have a source and a resolver in at the same time." + condition=not (source and resolver), + message="A Field cannot have a source and a resolver in at the same time.", ) raise_assertion_if_not( condition=not callable(default_value), message='The default value can not be a function but received "{}".'.format( base_type(default_value) - ) + ), ) if required: diff --git a/graphene/types/mountedtype.py b/graphene/types/mountedtype.py index e5eaa35c..bef31add 100644 --- a/graphene/types/mountedtype.py +++ b/graphene/types/mountedtype.py @@ -11,7 +11,7 @@ class MountedType(OrderedType): """ raise_assertion_if_not( condition=isinstance(unmounted, UnmountedType), - message="{} can't mount {}".format(cls.__name__, repr(unmounted)) + message="{} can't mount {}".format(cls.__name__, repr(unmounted)), ) return cls( diff --git a/graphene/types/mutation.py b/graphene/types/mutation.py index f71d3d08..76486e9f 100644 --- a/graphene/types/mutation.py +++ b/graphene/types/mutation.py @@ -65,8 +65,8 @@ class Mutation(ObjectType): mutate = getattr(cls, "mutate", None) raise_assertion_if_not( condition=mutate, - message="All mutations must define a mutate method in it" - ) + message="All mutations must define a mutate method in it", + ) resolver = get_unbound_function(mutate) if _meta.fields: diff --git a/graphene/types/objecttype.py b/graphene/types/objecttype.py index 140dd076..08e765cc 100644 --- a/graphene/types/objecttype.py +++ b/graphene/types/objecttype.py @@ -44,7 +44,7 @@ class ObjectType(BaseType): condition=issubclass(interface, Interface), message='All interfaces of {} must be a subclass of Interface. Received "{}".'.format( cls.__name__, interface - ) + ), ) fields.update(interface._meta.fields) @@ -53,11 +53,10 @@ class ObjectType(BaseType): raise_assertion_if_not( condition=not (possible_types and cls.is_type_of), - message=("{name}.Meta.possible_types will cause type collision with {name}.is_type_of. " \ - "Please use one or other.".format( - name=cls.__name__ - ) - ) + message=( + "{name}.Meta.possible_types will cause type collision with {name}.is_type_of. " + "Please use one or other.".format(name=cls.__name__) + ), ) if _meta.fields: diff --git a/graphene/types/schema.py b/graphene/types/schema.py index 39fee633..d9b86884 100644 --- a/graphene/types/schema.py +++ b/graphene/types/schema.py @@ -23,7 +23,7 @@ def assert_valid_root_type(_type): is_graphql_objecttype = isinstance(_type, GraphQLObjectType) raise_assertion_if_not( condition=is_graphene_objecttype or is_graphql_objecttype, - message="Type {} is not a valid ObjectType.".format(_type) + message="Type {} is not a valid ObjectType.".format(_type), ) @@ -59,7 +59,7 @@ class Schema(GraphQLSchema): condition=all(isinstance(d, GraphQLDirective) for d in directives), message="Schema directives must be List[GraphQLDirective] if provided but got: {}.".format( directives - ) + ), ) self._directives = directives self.build_typemap() diff --git a/graphene/types/structures.py b/graphene/types/structures.py index f383e6cc..0647c5eb 100644 --- a/graphene/types/structures.py +++ b/graphene/types/structures.py @@ -72,7 +72,7 @@ class NonNull(Structure): condition=not isinstance(self._of_type, NonNull), message="Can only create NonNull of a Nullable GraphQLType but got: {}.".format( self._of_type - ) + ), ) def __str__(self): diff --git a/graphene/types/typemap.py b/graphene/types/typemap.py index 25735613..93ea8ed9 100644 --- a/graphene/types/typemap.py +++ b/graphene/types/typemap.py @@ -63,13 +63,13 @@ def resolve_type(resolve_type_func, map, type_name, root, info): graphql_type = map.get(_type._meta.name) raise_assertion_if_not( condition=graphql_type, - message="Can't find type {} in schema".format(_type._meta.name) + message="Can't find type {} in schema".format(_type._meta.name), ) raise_assertion_if_not( condition=graphql_type.graphene_type is _type, message="The type {} does not match with the associated graphene type {}.".format( _type, graphql_type.graphene_type - ) + ), ) return graphql_type @@ -105,7 +105,7 @@ class TypeMap(GraphQLTypeMap): condition=_type.graphene_type is type, message="Found different types with the same name in the schema: {}, {}.".format( _type.graphene_type, type - ) + ), ) return map @@ -187,7 +187,7 @@ class TypeMap(GraphQLTypeMap): condition=_type.graphene_type is type, message="Found different types with the same name in the schema: {}, {}.".format( _type.graphene_type, type - ) + ), ) return _type @@ -226,7 +226,7 @@ class TypeMap(GraphQLTypeMap): condition=_type.graphene_type is type, message="Found different types with the same name in the schema: {}, {}.".format( _type.graphene_type, type - ) + ), ) return _type diff --git a/graphene/types/union.py b/graphene/types/union.py index 5b3bfd96..a4f8d486 100644 --- a/graphene/types/union.py +++ b/graphene/types/union.py @@ -26,7 +26,7 @@ class Union(UnmountedType, BaseType): def __init_subclass_with_meta__(cls, types=None, **options): raise_assertion_if_not( condition=isinstance(types, (list, tuple)) and len(types) > 0, - message="Must provide types for Union {name}.".format(name=cls.__name__) + message="Must provide types for Union {name}.".format(name=cls.__name__), ) _meta = UnionOptions(cls) _meta.types = types diff --git a/graphene/types/uuid.py b/graphene/types/uuid.py index d1f42683..4b40aa40 100644 --- a/graphene/types/uuid.py +++ b/graphene/types/uuid.py @@ -17,7 +17,7 @@ class UUID(Scalar): uuid = _UUID(uuid) raise_assertion_if_not( condition=isinstance(uuid, _UUID), - message="Expected UUID instance, received {}".format(uuid) + message="Expected UUID instance, received {}".format(uuid), ) return str(uuid) diff --git a/graphene/utils/annotate.py b/graphene/utils/annotate.py index 9b8cb15c..d620356c 100644 --- a/graphene/utils/annotate.py +++ b/graphene/utils/annotate.py @@ -24,10 +24,10 @@ def annotate(_func=None, _trigger_warning=True, **annotations): # We make sure the annotations are valid for key, value in annotations.items(): raise_assertion_if_not( - condition= key in func_signature.parameters, + condition=key in func_signature.parameters, message='The key {key} is not a function parameter in the function "{func_name}".'.format( key=key, func_name=func_name(_func) - ) + ), ) func_annotations = getattr(_func, "__annotations__", None) diff --git a/graphene/utils/subclass_with_meta.py b/graphene/utils/subclass_with_meta.py index 5b4ff134..739e2147 100644 --- a/graphene/utils/subclass_with_meta.py +++ b/graphene/utils/subclass_with_meta.py @@ -7,7 +7,6 @@ from .props import props from .comparison_helper import raise_assertion_if_not - class SubclassWithMeta_Meta(InitSubclassMeta): _meta = None @@ -46,10 +45,10 @@ class SubclassWithMeta(six.with_metaclass(SubclassWithMeta_Meta)): if abstract: raise_assertion_if_not( condition=not options, - message="Abstract types can only contain the abstract attribute. " \ - "Received: abstract, {option_keys}".format( - option_keys=", ".join(options.keys()) - ) + message="Abstract types can only contain the abstract attribute. " + "Received: abstract, {option_keys}".format( + option_keys=", ".join(options.keys()) + ), ) else: super_class = super(cls, cls)