clean up lint warnings
Newer chromite adds more lint warnings.
BUG=None
TEST=`cros lint` is clean in here
Change-Id: I96416f2d4e51956a2991e8b91124b3300693ffdf
Reviewed-on: https://chromium-review.googlesource.com/1757360
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
diff --git a/pre-upload.py b/pre-upload.py
index 789e53a..5afe6f5 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -52,47 +52,47 @@
COMMON_INCLUDED_PATHS = [
# C++ and friends
- r".*\.c$", r".*\.cc$", r".*\.cpp$", r".*\.h$", r".*\.m$", r".*\.mm$",
- r".*\.inl$", r".*\.asm$", r".*\.hxx$", r".*\.hpp$", r".*\.s$", r".*\.S$",
+ r'.*\.c$', r'.*\.cc$', r'.*\.cpp$', r'.*\.h$', r'.*\.m$', r'.*\.mm$',
+ r'.*\.inl$', r'.*\.asm$', r'.*\.hxx$', r'.*\.hpp$', r'.*\.s$', r'.*\.S$',
# Scripts
- r".*\.js$", r".*\.py$", r".*\.sh$", r".*\.rb$", r".*\.pl$", r".*\.pm$",
+ r'.*\.js$', r'.*\.py$', r'.*\.sh$', r'.*\.rb$', r'.*\.pl$', r'.*\.pm$',
# No extension at all, note that ALL CAPS files are black listed in
# COMMON_EXCLUDED_LIST below.
- r"(^|.*[\\\/])[^.]+$",
+ r'(^|.*[\\\/])[^.]+$',
# Other
- r".*\.java$", r".*\.mk$", r".*\.am$",
- r".*\.policy$", r".*\.conf$", r".*\.go$",
- r"(^OWNERS|/OWNERS)",
+ r'.*\.java$', r'.*\.mk$', r'.*\.am$',
+ r'.*\.policy$', r'.*\.conf$', r'.*\.go$',
+ r'(^OWNERS|/OWNERS)',
]
COMMON_EXCLUDED_PATHS = [
# For ebuild trees, ignore any caches and manifest data.
- r".*/Manifest$",
- r".*/metadata/[^/]*cache[^/]*/[^/]+/[^/]+$",
+ r'.*/Manifest$',
+ r'.*/metadata/[^/]*cache[^/]*/[^/]+/[^/]+$',
# Ignore profiles data (like overlay-tegra2/profiles).
- r"(^|.*/)overlay-.*/profiles/.*",
- r"^profiles/.*$",
+ r'(^|.*/)overlay-.*/profiles/.*',
+ r'^profiles/.*$',
# Ignore config files in ebuild setup.
- r"(^|.*/)overlay-.*/chromeos-base/chromeos-bsp.*/files/.*",
- r"^chromeos-base/chromeos-bsp.*/files/.*",
+ r'(^|.*/)overlay-.*/chromeos-base/chromeos-bsp.*/files/.*',
+ r'^chromeos-base/chromeos-bsp.*/files/.*',
# Ignore minified js and jquery.
- r".*\.min\.js",
- r".*jquery.*\.js",
+ r'.*\.min\.js',
+ r'.*jquery.*\.js',
# Ignore license files as the content is often taken verbatim.
- r".*/licenses/.*",
+ r'.*/licenses/.*',
# Exclude generated protobuf bindings.
- r".*_pb2\.py$",
- r".*\.pb\.go$",
+ r'.*_pb2\.py$',
+ r'.*\.pb\.go$',
]
LICENSE_EXCLUDED_PATHS = [
- r"^(.*/)?OWNERS$",
+ r'^(.*/)?OWNERS$',
]
_CONFIG_FILE = 'PRESUBMIT.cfg'
@@ -461,7 +461,7 @@
LONG_LINE_OK_PATHS = [
# Go has no line length limit.
# https://golang.org/doc/effective_go.html#formatting
- r".*\.go$",
+ r'.*\.go$',
]
MAX_LEN = 80
@@ -517,11 +517,11 @@
# Don't add entire repos here. Update the PRESUBMIT.cfg in each repo instead.
# We only whitelist known specific filetypes here that show up in all repos.
TAB_OK_PATHS = [
- r".*\.ebuild$",
- r".*\.eclass$",
- r".*\.go$",
- r".*/[M|m]akefile$",
- r".*\.mk$",
+ r'.*\.ebuild$',
+ r'.*\.eclass$',
+ r'.*\.go$',
+ r'.*/[M|m]akefile$',
+ r'.*\.mk$',
]
included, excluded = _parse_common_inclusion_options(options)
@@ -536,8 +536,8 @@
def _check_tabbed_indents(_project, commit, options=()):
"""Checks that indents use tabs only."""
TABS_REQUIRED_PATHS = [
- r".*\.ebuild$",
- r".*\.eclass$",
+ r'.*\.ebuild$',
+ r'.*\.eclass$',
]
LEADING_SPACE_RE = re.compile('[\t]* ')
@@ -1721,8 +1721,8 @@
# A dictionary of project-specific hooks(callbacks), indexed by project name.
# dict[project] = [callback1, callback2]
_PROJECT_SPECIFIC_HOOKS = {
- "chromiumos/third_party/kernel": [_kernel_configcheck],
- "chromiumos/third_party/kernel-next": [_kernel_configcheck],
+ 'chromiumos/third_party/kernel': [_kernel_configcheck],
+ 'chromiumos/third_party/kernel-next': [_kernel_configcheck],
}
@@ -1891,7 +1891,7 @@
remote_branch = _run_command(['git', 'rev-parse', '--abbrev-ref',
'--symbolic-full-name', '@{u}']).strip()
if not remote_branch:
- print('Your project %s doesn\'t track any remote repo.' % project_name,
+ print("Your project %s doesn't track any remote repo." % project_name,
file=sys.stderr)
remote = None
else:
@@ -1970,7 +1970,7 @@
msg = ('Preupload failed due to errors in project(s). HINTS:\n'
'- To disable some source style checks, and for other hints, see '
'<checkout_dir>/src/repohooks/README\n'
- '- To upload only current project, run \'repo upload .\'')
+ "- To upload only current project, run 'repo upload .'")
print(msg, file=sys.stderr)
sys.exit(1)
@@ -2011,14 +2011,14 @@
parser.add_argument('--rerun-since', default=None,
help='Rerun hooks on old commits since some point '
'in the past. The argument could be a date (should '
- 'match git log\'s concept of a date, e.g. 2012-06-20), '
+ "match git log's concept of a date, e.g. 2012-06-20), "
'or a SHA1, or just a number of commits to check (from 1 '
'to 99). This option is mutually exclusive with '
'--pre-submit.')
- parser.add_argument('--pre-submit', action="store_true",
+ parser.add_argument('--pre-submit', action='store_true',
help='Run the check against the pending commit. '
- 'This option should be used at the \'git commit\' '
- 'phase as opposed to \'repo upload\'. This option '
+ "This option should be used at the 'git commit' "
+ "phase as opposed to 'repo upload'. This option "
'is mutually exclusive with --rerun-since.')
parser.add_argument('commits', nargs='*',
help='Check specific commits')
@@ -2026,7 +2026,7 @@
if opts.rerun_since:
if opts.commits:
- raise BadInvocation('Can\'t pass commits and use rerun-since: %s' %
+ raise BadInvocation("Can't pass commits and use rerun-since: %s" %
' '.join(opts.commits))
if len(opts.rerun_since) < 3 and opts.rerun_since.isdigit():
@@ -2051,7 +2051,7 @@
'used together')
if opts.pre_submit:
if opts.commits:
- raise BadInvocation('Can\'t pass commits and use pre-submit: %s' %
+ raise BadInvocation("Can't pass commits and use pre-submit: %s" %
' '.join(opts.commits))
opts.commits = [PRE_SUBMIT,]
diff --git a/pre-upload_unittest.py b/pre-upload_unittest.py
index 5fadf24..179617d 100755
--- a/pre-upload_unittest.py
+++ b/pre-upload_unittest.py
@@ -60,14 +60,14 @@
def testCheck(self):
self.PatchObject(pre_upload, '_get_affected_files', return_value=['x.py'])
self.diff_mock.return_value = [
- (1, u"x" * 80), # OK
- (2, "\x80" * 80), # OK
- (3, u"x" * 81), # Too long
- (4, "\x80" * 81), # Too long
- (5, u"See http://" + (u"x" * 80)), # OK (URL)
- (6, u"See https://" + (u"x" * 80)), # OK (URL)
- (7, u"# define " + (u"x" * 80)), # OK (compiler directive)
- (8, u"#define" + (u"x" * 74)), # Too long
+ (1, u'x' * 80), # OK
+ (2, '\x80' * 80), # OK
+ (3, u'x' * 81), # Too long
+ (4, '\x80' * 81), # Too long
+ (5, u'See http://' + (u'x' * 80)), # OK (URL)
+ (6, u'See https://' + (u'x' * 80)), # OK (URL)
+ (7, u'# define ' + (u'x' * 80)), # OK (compiler directive)
+ (8, u'#define' + (u'x' * 74)), # Too long
]
failure = pre_upload._check_no_long_lines(ProjectNamed('PROJECT'), 'COMMIT')
self.assertTrue(failure)
@@ -113,7 +113,7 @@
self.PatchObject(pre_upload,
'_get_affected_files',
return_value=['foo.txt'])
- self.diff_mock.return_value = [(1, u"x" * 81)]
+ self.diff_mock.return_value = [(1, u'x' * 81)]
self.assertFalse(pre_upload._check_no_long_lines(
ProjectNamed('PROJECT'), 'COMMIT'))
self.assertTrue(pre_upload._check_no_long_lines(
@@ -123,7 +123,7 @@
self.PatchObject(pre_upload,
'_get_affected_files',
return_value=['foo.py'])
- self.diff_mock.return_value = [(1, u"x" * 81)]
+ self.diff_mock.return_value = [(1, u'x' * 81)]
self.assertTrue(pre_upload._check_no_long_lines(
ProjectNamed('PROJECT'), 'COMMIT'))
self.assertFalse(pre_upload._check_no_long_lines(
@@ -358,10 +358,10 @@
'/foo/bar.txt',
'/cat/pkg/Manifest',
]
- self.content_mock.return_value = '''# Comment and blank lines.
+ self.content_mock.return_value = """# Comment and blank lines.
DIST lines
-'''
+"""
ret = pre_upload._check_manifests('PROJECT', 'COMMIT')
self.assertIsNone(ret)
self.content_mock.assert_called_once_with('/cat/pkg/Manifest', 'COMMIT')