From e2ca1ed5e0bb9b3a4f0b65b2b26b74824edc4f65 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Thu, 13 Jun 2019 17:33:49 +0100 Subject: [PATCH] Run black --- graphene_django/converter.py | 4 +++- graphene_django/tests/test_converter.py | 3 +-- graphene_django/tests/test_types.py | 24 +++++++++++++++--------- graphene_django/types.py | 16 +++++++--------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/graphene_django/converter.py b/graphene_django/converter.py index 11a427e..4d0b45f 100644 --- a/graphene_django/converter.py +++ b/graphene_django/converter.py @@ -52,7 +52,9 @@ def get_choices(choices): yield name, value, description -def convert_django_field_with_choices(field, registry=None, convert_choices_to_enum=True): +def convert_django_field_with_choices( + field, registry=None, convert_choices_to_enum=True +): if registry is not None: converted = registry.get_converted_field(field) if converted: diff --git a/graphene_django/tests/test_converter.py b/graphene_django/tests/test_converter.py index 07ac082..5542c90 100644 --- a/graphene_django/tests/test_converter.py +++ b/graphene_django/tests/test_converter.py @@ -208,8 +208,7 @@ def test_field_with_choices_convert_enum_false(): app_label = "test" graphene_type = convert_django_field_with_choices( - field, - convert_choices_to_enum=False + field, convert_choices_to_enum=False ) assert isinstance(graphene_type, graphene.String) diff --git a/graphene_django/tests/test_types.py b/graphene_django/tests/test_types.py index 5beedb9..f7c26a9 100644 --- a/graphene_django/tests/test_types.py +++ b/graphene_django/tests/test_types.py @@ -230,13 +230,15 @@ def test_django_objecttype_exclude_fields(): assert "email" not in fields -class TestDjangoObjectType(): +class TestDjangoObjectType: @pytest.fixture def PetModel(self): class PetModel(models.Model): - kind = models.CharField(choices=(('cat', 'Cat'), ('dog', 'Dog'))) - cuteness = models.IntegerField(choices=( - (1, 'Kind of cute'), (2, 'Pretty cute'), (3, 'OMG SO CUTE!!!'))) + kind = models.CharField(choices=(("cat", "Cat"), ("dog", "Dog"))) + cuteness = models.IntegerField( + choices=((1, "Kind of cute"), (2, "Pretty cute"), (3, "OMG SO CUTE!!!")) + ) + return PetModel def test_django_objecttype_convert_choices_enum_false(self, PetModel): @@ -250,7 +252,8 @@ class TestDjangoObjectType(): schema = Schema(query=Query) - assert str(schema) == dedent("""\ + assert str(schema) == dedent( + """\ schema { query: Query } @@ -264,20 +267,22 @@ class TestDjangoObjectType(): type Query { pet: Pet } - """) + """ + ) def test_django_objecttype_convert_choices_enum_list(self, PetModel): class Pet(DjangoObjectType): class Meta: model = PetModel - convert_choices_to_enum = ['kind'] + convert_choices_to_enum = ["kind"] class Query(ObjectType): pet = Field(Pet) schema = Schema(query=Query) - assert str(schema) == dedent("""\ + assert str(schema) == dedent( + """\ schema { query: Query } @@ -296,4 +301,5 @@ class TestDjangoObjectType(): type Query { pet: Pet } - """) + """ + ) diff --git a/graphene_django/types.py b/graphene_django/types.py index 9c38bd3..005300d 100644 --- a/graphene_django/types.py +++ b/graphene_django/types.py @@ -18,8 +18,9 @@ if six.PY3: from typing import Type -def construct_fields(model, registry, only_fields, exclude_fields, - convert_choices_to_enum): +def construct_fields( + model, registry, only_fields, exclude_fields, convert_choices_to_enum +): _model_fields = get_model_fields(model) fields = OrderedDict() @@ -44,7 +45,8 @@ def construct_fields(model, registry, only_fields, exclude_fields, _convert_choices_to_enum = False converted = convert_django_field_with_choices( - field, registry, convert_choices_to_enum=_convert_choices_to_enum) + field, registry, convert_choices_to_enum=_convert_choices_to_enum + ) fields[name] = converted return fields @@ -103,13 +105,9 @@ class DjangoObjectType(ObjectType): django_fields = yank_fields_from_attrs( construct_fields( - model, - registry, - only_fields, - exclude_fields, - convert_choices_to_enum + model, registry, only_fields, exclude_fields, convert_choices_to_enum ), - _as=Field + _as=Field, ) if use_connection is None and interfaces: