mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-27 08:19:45 +03:00
changes by linter
This commit is contained in:
parent
f38fc5136f
commit
a212c8a422
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user