code: def create_sources_field(self, sources, sources_rel_path, key_arg=None):
      
      if not sources:
        sources = FilesetWithSpec.empty(sources_rel_path)
      elif not isinstance(sources, FilesetWithSpec):
        key_arg_section = "'{}' to be ".format(key_arg) if key_arg else ""
        raise TargetDefinitionException(self, "Expected {}a glob, an address or a list, but was {}"
                                              .format(key_arg_section, type(sources)))
  
      return SourcesField(sources=sources)
docs: Factory method to create a SourcesField appropriate for the type of the sources object.
  
      Note that this method is called before the call to Target.__init__ so don't expect fields to
      be populated!
  
      :API: public
  
      :return: a payload field object representing the sources parameter
      :rtype: SourcesField