pre-upload: long lines: handle Python & Rust better

Since Python is run through pylint which has much better checking
logic, don't bother enforcing long lines at all.

While we're here, fix Rust's line length to 100 per rustfmt.

BUG=chromium:870016
TEST=`repo upload` no longer complains in chromite/

Change-Id: I920d181f52513152af6e62dececb513b4a9fdb01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/repohooks/+/2202752
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index f897ccc..7330aec 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -500,12 +500,16 @@
       # Go has no line length limit.
       # https://golang.org/doc/effective_go.html#formatting
       r'.*\.go$',
+      # Python does its own long line checks via pylint.
+      r'.*\.py$',
   ]
 
   DEFAULT_MAX_LENGTHS = [
       # Java's line length limit is 100 chars.
       # https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md
       (r'.*\.java$', 100),
+      # Rust's line length limit is 100 chars.
+      (r'.*\.rs$', 100),
   ]
 
   MAX_LEN = 80
diff --git a/pre-upload_unittest.py b/pre-upload_unittest.py
index 384af0e..71b4337 100755
--- a/pre-upload_unittest.py
+++ b/pre-upload_unittest.py
@@ -99,7 +99,8 @@
     self.diff_mock = self.PatchObject(pre_upload, '_get_file_diff')
 
   def testCheck(self):
-    self.PatchObject(pre_upload, '_get_affected_files', return_value=['x.py'])
+    path = 'x.cc'
+    self.PatchObject(pre_upload, '_get_affected_files', return_value=[path])
     self.diff_mock.return_value = [
         (1, u'x' * 80),                      # OK
         (2, '\x80' * 80),                    # OK
@@ -114,7 +115,7 @@
     self.assertTrue(failure)
     self.assertEqual('Found lines longer than the limit (first 5 shown):',
                      failure.msg)
-    self.assertEqual(['x.py, line %d, 81 chars, over 80 chars' %
+    self.assertEqual([path + ', line %d, 81 chars, over 80 chars' %
                       x for x in [3, 4, 8]],
                      failure.items)
 
@@ -163,7 +164,7 @@
   def testExcludeOptions(self):
     self.PatchObject(pre_upload,
                      '_get_affected_files',
-                     return_value=['foo.py'])
+                     return_value=['foo.cc'])
     self.diff_mock.return_value = [(1, u'x' * 81)]
     self.assertTrue(pre_upload._check_no_long_lines(
         ProjectNamed('PROJECT'), 'COMMIT'))