1
+ from enum import Enum
1
2
import flask
2
3
from flask import Blueprint , current_app , jsonify
3
4
@@ -74,11 +75,13 @@ def get_arg_type_hint(fdocs, arg_name):
74
75
Extract the type hint for a specific argument.
75
76
"""
76
77
arg_type = fdocs ["argspec" ].annotations [arg_name ]
77
- if hasattr (arg_type , "__args__" ):
78
- return (
79
- f"{ arg_type .__name__ } [{ ', ' .join ([a .__name__ for a in arg_type .__args__ ])} ]"
80
- )
81
- return arg_type .__name__
78
+ def recursively_resolve_type_hint (type_to_resolve ):
79
+ if hasattr (type_to_resolve , "__args__" ):
80
+ return (
81
+ f"{ type_to_resolve .__name__ } [{ ', ' .join ([recursively_resolve_type_hint (a ) for a in type_to_resolve .__args__ ])} ]"
82
+ )
83
+ return type_to_resolve .__name__
84
+ return recursively_resolve_type_hint (arg_type )
82
85
83
86
84
87
def get_arg_location (fdocs , idx ):
@@ -98,6 +101,18 @@ def get_arg_location_details(fdocs, idx):
98
101
if value is not None :
99
102
if callable (value ):
100
103
loc_details [param ] = f"{ value .__module__ } .{ value .__name__ } "
104
+ elif issubclass (type (value ), Enum ):
105
+ loc_details [param ] = f"{ type (value ).__name__ } .{ value .name } : "
106
+ if issubclass (type (value ), int ):
107
+ loc_details [param ] += f"{ value .value } "
108
+ elif issubclass (type (value ), str ):
109
+ loc_details [param ] += f"'{ value .value } '"
110
+ else :
111
+ loc_details [param ] = f"FPV: Unsupported Enum type"
112
+ elif type (value ).__name__ == 'time' :
113
+ loc_details [param ] = value .isoformat ()
114
+ elif param == 'sources' :
115
+ loc_details [param ] = [type (source ).__name__ for source in value ]
101
116
else :
102
117
loc_details [param ] = value
103
118
return loc_details
0 commit comments