cros lint: Do not error out if no files provided.

The "cros lint" command is used as a repo upload hook, and in some cases
there are no files provided for a commit (if the commit only deletes
files).  This change makes "cros lint" accept a lack of arguments
without complaint, only issuing a warning for any human looking at the
output.

BUG=chromium:266549
TEST=`cros lint` does not fail, but issues warning
TEST=`cros lint scripts/cbuildbot.py` still runs lint
TEST=Creating a CL that deletes a file after this one and seeing if repo
will upload it.

Change-Id: Ib5aa5d5b75c881fa664e680a802d61de64245053
Reviewed-on: https://chromium-review.googlesource.com/182937
Tested-by: Matt Tennant <mtennant@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
diff --git a/cros/commands/cros_lint.py b/cros/commands/cros_lint.py
index 116d3e9..b1c4271 100644
--- a/cros/commands/cros_lint.py
+++ b/cros/commands/cros_lint.py
@@ -76,11 +76,18 @@
   @classmethod
   def AddParser(cls, parser):
     super(LintCommand, cls).AddParser(parser)
-    parser.add_argument('files', help='Files to lint', nargs='+')
+    parser.add_argument('files', help='Files to lint', nargs='*')
 
   def Run(self):
+    files = self.options.files
+    if not files:
+      # Running with no arguments is allowed to make the repo upload hook
+      # simple, but print a warning so that if someone runs this manually
+      # they are aware that nothing was linted.
+      cros_build_lib.Warning('No files provided to lint.  Doing nothing.')
+
     errors = False
-    for pylintrc, paths in sorted(_GetPylintGroups(self.options.files).items()):
+    for pylintrc, paths in sorted(_GetPylintGroups(files).items()):
       paths = sorted(list(set([os.path.realpath(x) for x in paths])))
       cmd = ['pylint', '--rcfile=%s' % pylintrc] + paths
       extra_env = {'PYTHONPATH': ':'.join(_GetPythonPath(paths))}
@@ -89,5 +96,6 @@
                                       print_cmd=self.options.debug)
       if res.returncode != 0:
         errors = True
+
     if errors:
       sys.exit(1)