From d2db5f5584c74bbcdccd05b9099d5318a44adea3 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 10 Dec 2017 00:53:13 -0500 Subject: [PATCH] Remove Django1.7 shims --- graphene_django/form_converter.py | 8 +-- .../management/commands/graphql_schema.py | 71 ++++++------------- 2 files changed, 21 insertions(+), 58 deletions(-) diff --git a/graphene_django/form_converter.py b/graphene_django/form_converter.py index 46a38b3..195c8c4 100644 --- a/graphene_django/form_converter.py +++ b/graphene_django/form_converter.py @@ -8,12 +8,6 @@ from .utils import import_single_dispatch singledispatch = import_single_dispatch() -try: - UUIDField = forms.UUIDField -except AttributeError: - class UUIDField(object): - pass - @singledispatch def convert_form_field(field): @@ -36,7 +30,7 @@ def convert_form_field_to_string(field): return String(description=field.help_text, required=field.required) -@convert_form_field.register(UUIDField) +@convert_form_field.register(forms.UUIDField) def convert_form_field_to_uuid(field): return UUID(description=field.help_text, required=field.required) diff --git a/graphene_django/management/commands/graphql_schema.py b/graphene_django/management/commands/graphql_schema.py index 7e2dbac..3a1690a 100644 --- a/graphene_django/management/commands/graphql_schema.py +++ b/graphene_django/management/commands/graphql_schema.py @@ -1,64 +1,33 @@ import importlib import json -from distutils.version import StrictVersion -from optparse import make_option -from django import get_version as get_django_version from django.core.management.base import BaseCommand, CommandError from graphene_django.settings import graphene_settings -LT_DJANGO_1_8 = StrictVersion(get_django_version()) < StrictVersion('1.8') +class CommandArguments(BaseCommand): -if LT_DJANGO_1_8: - class CommandArguments(BaseCommand): - option_list = BaseCommand.option_list + ( - make_option( - '--schema', - type=str, - dest='schema', - default='', - help='Django app containing schema to dump, e.g. myproject.core.schema.schema', - ), - make_option( - '--out', - type=str, - dest='out', - default='', - help='Output file (default: schema.json)' - ), - make_option( - '--indent', - type=int, - dest='indent', - default=None, - help='Output file indent (default: None)' - ), - ) -else: - class CommandArguments(BaseCommand): + def add_arguments(self, parser): + parser.add_argument( + '--schema', + type=str, + dest='schema', + default=graphene_settings.SCHEMA, + help='Django app containing schema to dump, e.g. myproject.core.schema.schema') - def add_arguments(self, parser): - parser.add_argument( - '--schema', - type=str, - dest='schema', - default=graphene_settings.SCHEMA, - help='Django app containing schema to dump, e.g. myproject.core.schema.schema') + parser.add_argument( + '--out', + type=str, + dest='out', + default=graphene_settings.SCHEMA_OUTPUT, + help='Output file (default: schema.json)') - parser.add_argument( - '--out', - type=str, - dest='out', - default=graphene_settings.SCHEMA_OUTPUT, - help='Output file (default: schema.json)') - - parser.add_argument( - '--indent', - type=int, - dest='indent', - default=graphene_settings.SCHEMA_INDENT, - help='Output file indent (default: None)') + parser.add_argument( + '--indent', + type=int, + dest='indent', + default=graphene_settings.SCHEMA_INDENT, + help='Output file indent (default: None)') class Command(CommandArguments):