mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-12 09:12:18 +03:00
Remove singledispatch dependency
singledispatch is inluded with Python >= 3.4, no need for external package.
This commit is contained in:
parent
14321dd5d9
commit
c678a379a2
|
@ -1,4 +1,6 @@
|
|||
from collections import OrderedDict
|
||||
from functools import singledispatch
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.module_loading import import_string
|
||||
|
@ -26,9 +28,6 @@ from graphql import assert_valid_name
|
|||
from .settings import graphene_settings
|
||||
from .compat import ArrayField, HStoreField, JSONField, RangeField
|
||||
from .fields import DjangoListField, DjangoConnectionField
|
||||
from .utils import import_single_dispatch
|
||||
|
||||
singledispatch = import_single_dispatch()
|
||||
|
||||
|
||||
def convert_choice_name(name):
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
from functools import singledispatch
|
||||
|
||||
from django import forms
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from graphene import ID, Boolean, Float, Int, List, String, UUID, Date, DateTime, Time
|
||||
|
||||
from .forms import GlobalIDFormField, GlobalIDMultipleChoiceField
|
||||
from ..utils import import_single_dispatch
|
||||
|
||||
|
||||
singledispatch = import_single_dispatch()
|
||||
|
||||
|
||||
@singledispatch
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from functools import singledispatch
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from rest_framework import serializers
|
||||
|
||||
|
@ -5,11 +7,8 @@ import graphene
|
|||
|
||||
from ..registry import get_global_registry
|
||||
from ..converter import convert_choices_to_named_enum_with_descriptions
|
||||
from ..utils import import_single_dispatch
|
||||
from .types import DictType
|
||||
|
||||
singledispatch = import_single_dispatch()
|
||||
|
||||
|
||||
@singledispatch
|
||||
def get_graphene_type_from_serializer_field(field):
|
||||
|
|
|
@ -4,7 +4,6 @@ from .utils import (
|
|||
camelize,
|
||||
get_model_fields,
|
||||
get_reverse_fields,
|
||||
import_single_dispatch,
|
||||
is_valid_django_model,
|
||||
maybe_queryset,
|
||||
)
|
||||
|
@ -16,6 +15,5 @@ __all__ = [
|
|||
"get_model_fields",
|
||||
"camelize",
|
||||
"is_valid_django_model",
|
||||
"import_single_dispatch",
|
||||
"GraphQLTestCase",
|
||||
]
|
||||
|
|
|
@ -76,26 +76,3 @@ def get_model_fields(model):
|
|||
|
||||
def is_valid_django_model(model):
|
||||
return inspect.isclass(model) and issubclass(model, models.Model)
|
||||
|
||||
|
||||
def import_single_dispatch():
|
||||
try:
|
||||
from functools import singledispatch
|
||||
except ImportError:
|
||||
singledispatch = None
|
||||
|
||||
if not singledispatch:
|
||||
try:
|
||||
from singledispatch import singledispatch
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if not singledispatch:
|
||||
raise Exception(
|
||||
"It seems your python version does not include "
|
||||
"functools.singledispatch. Please install the 'singledispatch' "
|
||||
"package. More information here: "
|
||||
"https://pypi.python.org/pypi/singledispatch"
|
||||
)
|
||||
|
||||
return singledispatch
|
||||
|
|
Loading…
Reference in New Issue
Block a user