fix Optional typing hint for SerializerMethodField (#428)
This commit is contained in:
committed by
Cristi Vîjdea
parent
8578b93eba
commit
1352c2a23b
@@ -610,6 +610,8 @@ class SerializerMethodFieldInspector(FieldInspector):
|
||||
# look for Python 3.5+ style type hinting of the return value
|
||||
hint_class = inspect_signature(method).return_annotation
|
||||
|
||||
if not inspect.isclass(hint_class) and hasattr(hint_class, '__args__'):
|
||||
hint_class = hint_class.__args__[0]
|
||||
if inspect.isclass(hint_class) and not issubclass(hint_class, inspect._empty):
|
||||
type_info = get_basic_type_info_from_hint(hint_class)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user