From 105535b36226aef9e52b844f02a285268c4d1b50 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 10 Mar 2021 14:18:24 +0100 Subject: [PATCH] Fix for python 2.7 --- graphene_django/converter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphene_django/converter.py b/graphene_django/converter.py index 63cc35d..b744e51 100644 --- a/graphene_django/converter.py +++ b/graphene_django/converter.py @@ -69,7 +69,11 @@ def convert_choices_to_named_enum_with_descriptions(name, choices): def description(self): return named_choices_descriptions[self.name] - return Enum(name, list(named_choices), type=EnumWithDescriptionsType) + if named_choices == []: + # Python 2.7 doesn't handle enums with lists with zero entries, but works okay with empty sets + named_choices = set() + + return Enum(name, named_choices, type=EnumWithDescriptionsType) def generate_enum_name(django_model_meta, field):