diff --git a/graphene_sqlalchemy/converter.py b/graphene_sqlalchemy/converter.py index 17e54b0f..2543fc84 100644 --- a/graphene_sqlalchemy/converter.py +++ b/graphene_sqlalchemy/converter.py @@ -10,16 +10,10 @@ from .fields import createConnectionField try: - from sqlalchemy_utils import ChoiceType, JSONType, ScalarListType, TSVectorType + from sqlalchemy_utils import ( + ChoiceType, JSONType, ScalarListType, TSVectorType) except ImportError: - class ChoiceType(object): - pass - - class ScalarListType(object): - pass - - class JSONType(object): - pass + ChoiceType = JSONType = ScalarListType = TSVectorType = object def get_column_doc(column): @@ -38,10 +32,9 @@ def dynamic_type(): _type = registry.get_type_for_model(model) if not _type: return None - if (direction == interfaces.MANYTOONE or not relationship.uselist): + if direction == interfaces.MANYTOONE or not relationship.uselist: return Field(_type) - elif (direction == interfaces.ONETOMANY or - direction == interfaces.MANYTOMANY): + elif direction in (interfaces.ONETOMANY, interfaces.MANYTOMANY): if _type._meta.connection: return createConnectionField(_type) return Field(List(_type)) diff --git a/graphene_sqlalchemy/types.py b/graphene_sqlalchemy/types.py index 44bf9c27..04d1a8a6 100644 --- a/graphene_sqlalchemy/types.py +++ b/graphene_sqlalchemy/types.py @@ -28,7 +28,7 @@ def construct_fields(model, registry, only_fields, exclude_fields): is_excluded = name in exclude_fields # or is_already_created if is_not_in_only or is_excluded: # We skip this field if we specify only_fields and is not - # in there. Or when we excldue this field in exclude_fields + # in there. Or when we exclude this field in exclude_fields continue converted_column = convert_sqlalchemy_column(column, registry) fields[name] = converted_column @@ -39,7 +39,7 @@ def construct_fields(model, registry, only_fields, exclude_fields): is_excluded = name in exclude_fields # or is_already_created if is_not_in_only or is_excluded: # We skip this field if we specify only_fields and is not - # in there. Or when we excldue this field in exclude_fields + # in there. Or when we exclude this field in exclude_fields continue converted_composite = convert_sqlalchemy_composite(composite, registry) fields[name] = converted_composite @@ -55,7 +55,7 @@ def construct_fields(model, registry, only_fields, exclude_fields): if is_not_in_only or is_excluded: # We skip this field if we specify only_fields and is not - # in there. Or when we excldue this field in exclude_fields + # in there. Or when we exclude this field in exclude_fields continue converted_hybrid_property = convert_sqlalchemy_hybrid_method( @@ -70,7 +70,7 @@ def construct_fields(model, registry, only_fields, exclude_fields): is_excluded = relationship.key in exclude_fields # or is_already_created if is_not_in_only or is_excluded: # We skip this field if we specify only_fields and is not - # in there. Or when we excldue this field in exclude_fields + # in there. Or when we exclude this field in exclude_fields continue converted_relationship = convert_sqlalchemy_relationship(relationship, registry) name = relationship.key