code: def _check_pattern_list(patterns, key, default=None):
      
      if not patterns:
          return default
  
      if isinstance(patterns, basestring):
          return [patterns]
  
      if isinstance(patterns, list):
          if all(isinstance(p, basestring) for p in patterns):
              return patterns
  
      raise ValueError("Invalid file patterns in key '{}': must be a string or "
                       'list of strings'.format(key))
docs: Validates file search patterns from user configuration.
  
      Acceptable input is a string (which will be converted to a singleton list),
      a list of strings, or anything falsy (such as None or an empty dictionary).
      Empty or unset input will be converted to a default.
  
      Args:
          patterns: input from user configuration (YAML).
          key (str): name of the configuration key the input came from,
              used for error display purposes.
  
      Keyword Args:
          default: value to return in case the input is empty or unset.
  
      Returns:
          list[str]: validated list of patterns
  
      Raises:
          ValueError: if the input is unacceptable.