Fix error when using typing classes (#195)

Closes #195.
openapi3
Julian Bez 2018-09-03 12:10:58 +02:00 committed by Cristi Vîjdea
parent 6e39a58b2d
commit 02b8848912
1 changed files with 4 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import operator
import uuid import uuid
from collections import OrderedDict from collections import OrderedDict
from decimal import Decimal from decimal import Decimal
from inspect import isclass
from django.core import validators from django.core import validators
from django.db import models from django.db import models
@ -511,7 +512,9 @@ class SerializerMethodFieldInspector(FieldInspector):
# look for Python 3.5+ style type hinting of the return value # look for Python 3.5+ style type hinting of the return value
hint_class = inspect.signature(method).return_annotation hint_class = inspect.signature(method).return_annotation
if not issubclass(hint_class, inspect._empty): if not isclass(hint_class) and hasattr(hint_class, '__args__'):
hint_class = hint_class.__args__[0]
if isclass(hint_class) and not issubclass(hint_class, inspect._empty):
type_info = get_basic_type_info_from_hint(hint_class) type_info = get_basic_type_info_from_hint(hint_class)
if type_info is not None: if type_info is not None: