@@ -269,10 +269,14 @@ def _create_field_via_origin(origin, tp, options: Options) -> BaseField:
269269 options .base_args ["value" ] = value
270270 return options .construct_field ()
271271
272- elif issubclass (origin , list ):
272+ # If type already defined skip lookup
273+ if options .is_field_type_valid :
274+ return options .construct_field ()
275+
276+ if issubclass (origin , list ):
273277 return _create_field_from_list_type (get_args (tp ), options )
274278
275- elif issubclass (origin , dict ):
279+ if issubclass (origin , dict ):
276280 return _create_field_from_dict_type (get_args (tp ), options )
277281
278282 msg = f"Unable to resolve field for sub-scripted type { tp !r} "
@@ -281,16 +285,18 @@ def _create_field_via_origin(origin, tp, options: Options) -> BaseField:
281285
282286def _create_field_for_type (tp , options : Options ) -> Field :
283287 # If type already defined skip lookup
284- if not options .is_field_type_valid :
285- # Is a basic type
286- if isinstance (tp , type ):
287- _set_options_field_type (options , tp )
288- elif tp is Any :
289- # For Python 3.10
290- options .field_type = AnyField
291- else :
292- msg = f"Annotation is not a type instance { tp !r} "
293- raise ResourceDefError (msg )
288+ if options .is_field_type_valid :
289+ return options .construct_field ()
290+
291+ # Is a basic type
292+ if isinstance (tp , type ):
293+ _set_options_field_type (options , tp )
294+ elif tp is Any :
295+ # For Python 3.10
296+ options .field_type = AnyField
297+ else :
298+ msg = f"Annotation is not a type instance { tp !r} "
299+ raise ResourceDefError (msg )
294300
295301 return options .construct_field ()
296302
0 commit comments