From 6daf7e9d7ff67259804489e54f26252d108b3e57 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sat, 13 Apr 2019 17:38:23 -0400 Subject: [PATCH] tools: python: activate more flake8 rules PR-URL: https://github.com/nodejs/node/pull/25614 Reviewed-By: Sakthipriyan Vairamani (cherry picked from commit a16a0fe9629325ae1dd81827c6071ca972d7449a) --- tools/configure.d/nodedownload.py | 2 +- tools/icu/icutrim.py | 8 ++++---- tools/js2c.py | 3 ++- tools/test.py | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/configure.d/nodedownload.py b/tools/configure.d/nodedownload.py index e3fe2c517cc1bb..8734770fc78fff 100644 --- a/tools/configure.d/nodedownload.py +++ b/tools/configure.d/nodedownload.py @@ -107,7 +107,7 @@ def parse(opt): if not anOpt or anOpt == "": # ignore stray commas, etc. continue - elif anOpt is 'all': + elif anOpt == 'all': # all on theRet = dict((key, True) for (key) in download_types) else: diff --git a/tools/icu/icutrim.py b/tools/icu/icutrim.py index 517bf39bad323d..008f99029daf2d 100755 --- a/tools/icu/icutrim.py +++ b/tools/icu/icutrim.py @@ -100,7 +100,7 @@ print "Unknown endianness: %s" % options.endian sys.exit(1) -if options.endian is "host": +if options.endian == "host": options.endian = endian if not os.path.isdir(options.tmpdir): @@ -143,8 +143,8 @@ def runcmd(tool, cmd, doContinue=False): print "# " + cmd rc = os.system(cmd) - if rc is not 0 and not doContinue: - print "FAILED: %s" % cmd + if rc != 0 and not doContinue: + print("FAILED: %s" % cmd) sys.exit(1) return rc @@ -310,7 +310,7 @@ def removeList(count=0): print >>fi, i fi.close() rc = runcmd("icupkg","-r %s %s 2> %s" % (removefile,outfile,hackerrfile),True) - if rc is not 0: + if rc != 0: if(options.verbose>5): print "## Damage control, trying to parse stderr from icupkg.." fi = open(hackerrfile, 'rb') diff --git a/tools/js2c.py b/tools/js2c.py index d2d63ad571205d..39bfdefebc0b3b 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -138,7 +138,8 @@ def ReadMacros(lines): hash = line.find('#') if hash != -1: line = line[:hash] line = line.strip() - if len(line) is 0: continue + if len(line) == 0: + continue const_match = CONST_PATTERN.match(line) if const_match: name = const_match.group(1) diff --git a/tools/test.py b/tools/test.py index a51b475b1f23cd..ade51a184697e8 100755 --- a/tools/test.py +++ b/tools/test.py @@ -329,7 +329,7 @@ def HasRun(self, output): logger.info(' ---') logger.info(' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000)) - if self.severity is not 'ok' or self.traceback is not '': + if self.severity != 'ok' or self.traceback != '': if output.HasTimedOut(): self.traceback = 'timeout\n' + output.output.stdout + output.output.stderr self._printDiagnostic() @@ -1660,9 +1660,9 @@ def Main(): continue archEngineContext = Execute([vm, "-p", "process.arch"], context) vmArch = archEngineContext.stdout.rstrip() - if archEngineContext.exit_code is not 0 or vmArch == "undefined": - print "Can't determine the arch of: '%s'" % vm - print archEngineContext.stderr.rstrip() + if archEngineContext.exit_code != 0 or vmArch == "undefined": + print("Can't determine the arch of: '%s'" % vm) + print(archEngineContext.stderr.rstrip()) continue env = { 'mode': mode,