code: def lint(files: List[str], reformat: bool) -> List[str]:
      assert files, "no files provided"
  
      invalids = []
      errors = []
  
      for file in files:
          with open(file) as f:
              try:
                  schema = json.loads(f.read())
              except json.decoder.JSONDecodeError as e:
                  invalids.append(f"{file} not valid: {e}")
                  continue
  
          doc = os.path.relpath(file, os.path.dirname(__file__))
  
          try:
              errors += iter_schema(
                  schema,
                  f"<{doc}>",
                  in_checks=doc.startswith("check-"),
                  filepath=doc,
              )
          except Exception as e:
              raise ValueError(f"failure processing {file}") from e
  
      # Exit now if there are invalid errors.
      if invalids:
          return invalids
  
      errors += fmt(files, reformat)
  
      if errors:
          pathwidth = max(len(path) for path, error in errors)
          msgs = [
              "%-*s  %s" % (pathwidth, path, error)
              for path, error in errors
          ]
          return sorted(msgs)
  
      return []
  
imports: import argparse
  import json
  import os
  import re
  import sys
  from typing import Callable, List, Optional, Tuple, TypeVar, Union
label_desc: Use image node_id 19 for calling a global function with example usage: lint(files, reformat) and returns: list, invalids, sorted