parameters: ()
docstring: Run pylint on specified files.
docstring_summary: Run pylint on specified files.
docstring_tokens: Run pylint on specified files .
function: def main():
      """
      Run pylint on specified files.
      """
  
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "--check_grandfathered",
          action="store_true",
          help="Also check grandfathered files for lint errors.",
      )
      parser.add_argument("files", nargs="*", help="List of files to check using pylint.")
      args = parser.parse_args()
  
      # Check if we are doing all files, or user-provided list
      if args.files:
          # Check that all files exist, and build pathlib objects
          paths = []
          for file in args.files:
              f_path = pathlib.Path(file).resolve()
              if not f_path.is_file():
                  error(f_path, "does not exist")
              paths.append(f_path)
      else:
          # Expand all paths
          paths = expand_paths()
      print(TermColor.BLUE + "Linting", len(paths), "python file(s).", TermColor.END)
  
      # Lint files
      num_error_files = 0
      for path in paths:
          relpath_str = str(path.relative_to(repo_path))
  
          if (path in grandfathered_files) and not args.check_grandfathered:
              print(
                  TermColor.YELLOW + relpath_str,
                  "skipped (grandfathered)",
                  TermColor.END,
              )
              continue
  
          # Pylint checks to ignore
          ignore_list = []
  
          # Ignore function argument indenting, which is currently incompabile with black
          # https://github.com/psf/black/issues/48
          ignore_list.append("C0330")
  
          # Build pylint command
          cmd = ["pylint", path, "-s", "n"]
          if ignore_list:
              cmd.append("--disable=" + ",".join(ignore_list))
  
          # Run pylint and check output
          process = subprocess.run(cmd, check=False, stdout=subprocess.PIPE)
          if process.returncode:
              print(TermColor.RED + relpath_str, "has lint errors", TermColor.END)
              print(process.stdout.decode().strip())
              num_error_files += 1
          else:
              print(TermColor.GREEN + relpath_str, "passed", TermColor.END)
  
      if num_error_files:
          error(num_error_files, "file(s) failed lint test.", returncode=num_error_files)
      else:
          print(TermColor.GREEN + "Lint passed.", TermColor.END)
function_tokens: def main ( ) : parser = argparse . ArgumentParser ( ) parser . add_argument ( "--check_grandfathered" , action = "store_true" , help = "Also check grandfathered files for lint errors." , ) parser . add_argument ( "files" , nargs = "*" , help = "List of files to check using pylint." ) args = parser . parse_args ( ) # Check if we are doing all files, or user-provided list if args . files : # Check that all files exist, and build pathlib objects paths = [ ] for file in args . files : f_path = pathlib . Path ( file ) . resolve ( ) if not f_path . is_file ( ) : error ( f_path , "does not exist" ) paths . append ( f_path ) else : # Expand all paths paths = expand_paths ( ) print ( TermColor . BLUE + "Linting" , len ( paths ) , "python file(s)." , TermColor . END ) # Lint files num_error_files = 0 for path in paths : relpath_str = str ( path . relative_to ( repo_path ) ) if ( path in grandfathered_files ) and not args . check_grandfathered : print ( TermColor . YELLOW + relpath_str , "skipped (grandfathered)" , TermColor . END , ) continue # Pylint checks to ignore ignore_list = [ ] # Ignore function argument indenting, which is currently incompabile with black # https://github.com/psf/black/issues/48 ignore_list . append ( "C0330" ) # Build pylint command cmd = [ "pylint" , path , "-s" , "n" ] if ignore_list : cmd . append ( "--disable=" + "," . join ( ignore_list ) ) # Run pylint and check output process = subprocess . run ( cmd , check = False , stdout = subprocess . PIPE ) if process . returncode : print ( TermColor . RED + relpath_str , "has lint errors" , TermColor . END ) print ( process . stdout . decode ( ) . strip ( ) ) num_error_files += 1 else : print ( TermColor . GREEN + relpath_str , "passed" , TermColor . END ) if num_error_files : error ( num_error_files , "file(s) failed lint test." , returncode = num_error_files ) else : print ( TermColor . GREEN + "Lint passed." , TermColor . END )