code: def maybe_cast_list(value, types):
      
      if not isinstance(value, list):
          return value
  
      if type(types) not in (list, tuple):
          types = (types,)
  
      for list_type in types:
          if issubclass(list_type, list):
              try:
                  return list_type(value)
              except (TypeError, ValueError):
                  pass
      return value
docs: Try to coerce list values into more specific list subclasses in types.