diff options
author | Jack Lloyd <[email protected]> | 2018-08-02 17:49:20 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-02 17:49:20 -0400 |
commit | 6e8f5f1a1d5c03ec5c12ce6febe021f9aad00dcd (patch) | |
tree | e458d67df39da00a4e70aafdc3ff1d668e034037 /src/scripts | |
parent | 5ed67bfbf96a80af77807443177b4925e0a94797 (diff) |
Fix complaints from latest pylint
Diffstat (limited to 'src/scripts')
-rwxr-xr-x | src/scripts/ci_build.py | 12 | ||||
-rwxr-xr-x | src/scripts/cleanup.py | 2 | ||||
-rwxr-xr-x | src/scripts/dist.py | 14 | ||||
-rwxr-xr-x | src/scripts/test_cli.py | 12 | ||||
-rw-r--r-- | src/scripts/test_python.py | 1 |
5 files changed, 23 insertions, 18 deletions
diff --git a/src/scripts/ci_build.py b/src/scripts/ci_build.py index 3c2cb49f5..6626ea18e 100755 --- a/src/scripts/ci_build.py +++ b/src/scripts/ci_build.py @@ -62,7 +62,7 @@ def determine_flags(target, target_os, target_cpu, target_cc, cc_bin, ccache, ro if target_cc == 'msvc': flags += ['--ack-vc2013-deprecated'] - if target_cpu != None: + if target_cpu is not None: flags += ['--cpu=%s' % (target_cpu)] if target in ['shared', 'mini-shared']: @@ -354,7 +354,7 @@ def main(args=None): root_dir = options.root_dir - if os.access(root_dir, os.R_OK) != True: + if not os.access(root_dir, os.R_OK): raise Exception('Bad root dir setting, dir %s not readable' % (root_dir)) cmds = [] @@ -372,6 +372,10 @@ def main(args=None): # too-many-locals: variable counting differs from pylint3 py2_flags = '--disable=superfluous-parens,too-many-locals' + # Some disabled rules specific to Python3 + # useless-object-inheritance: complains about code still useful in Python2 + py3_flags = '--disable=useless-object-inheritance' + py_scripts = [ 'configure.py', 'src/python/botan2.py', @@ -394,7 +398,7 @@ def main(args=None): cmds.append(['python2', '-m', 'pylint'] + pylint_flags + [py2_flags, target_path]) if use_python3: - cmds.append(['python3', '-m', 'pylint'] + pylint_flags + [target_path]) + cmds.append(['python3', '-m', 'pylint'] + pylint_flags + [py3_flags, target_path]) else: config_flags, run_test_command, make_prefix = determine_flags( @@ -430,7 +434,7 @@ def main(args=None): elif options.compiler_cache == 'clcache': cmds.append(['clcache', '-s']) - if run_test_command != None: + if run_test_command is not None: cmds.append(run_test_command) if target in ['coverage', 'fuzzers']: diff --git a/src/scripts/cleanup.py b/src/scripts/cleanup.py index 29f8e8ede..35920f90f 100755 --- a/src/scripts/cleanup.py +++ b/src/scripts/cleanup.py @@ -78,7 +78,7 @@ def main(args=None): build_dir = options.build_dir - if os.access(build_dir, os.X_OK) != True: + if not os.access(build_dir, os.X_OK): logging.debug('No build directory found') # No build dir: clean enough! return 0 diff --git a/src/scripts/dist.py b/src/scripts/dist.py index 36237c42c..a27784453 100755 --- a/src/scripts/dist.py +++ b/src/scripts/dist.py @@ -100,7 +100,7 @@ def gpg_sign(keyid, passphrase_file, files, detached=True): options = ['--armor', '--detach-sign'] if detached else ['--clearsign'] gpg_cmd = ['gpg', '--batch'] + options + ['--local-user', keyid] - if passphrase_file != None: + if passphrase_file is not None: gpg_cmd[1:1] = ['--passphrase-file', passphrase_file] for filename in files: @@ -248,7 +248,7 @@ def write_archive(output_basename, archive_type, rel_epoch, all_files, hash_file archive_hash = sha256.hexdigest().upper() logging.info('SHA-256(%s) = %s' % (output_archive, archive_hash)) - if hash_file != None: + if hash_file is not None: hash_file.write("%s %s\n" % (archive_hash, output_archive)) return output_archive @@ -259,7 +259,7 @@ def configure_logging(options): super(ExitOnErrorLogHandler, self).emit(record) # Exit script if and ERROR or worse occurred if record.levelno >= logging.ERROR: - if sys.exc_info()[2] != None: + if sys.exc_info()[2] is not None: logging.info(traceback.format_exc()) sys.exit(1) @@ -276,7 +276,7 @@ def configure_logging(options): logging.getLogger().setLevel(log_level()) def main(args=None): - # pylint: disable=too-many-branches,too-many-locals + # pylint: disable=too-many-branches,too-many-locals,too-many-statements if args is None: args = sys.argv[1:] @@ -382,19 +382,19 @@ def main(args=None): output_files = [] hash_file = None - if options.write_hash_file != None: + if options.write_hash_file is not None: hash_file = open(options.write_hash_file, 'w') for archive_type in archives: output_files.append(write_archive(output_basename, archive_type, rel_epoch, all_files, hash_file)) - if hash_file != None: + if hash_file is not None: hash_file.close() shutil.rmtree(output_basename) if options.pgp_key_id != 'none': - if options.write_hash_file != None: + if options.write_hash_file is not None: output_files += gpg_sign(options.pgp_key_id, options.pgp_passphrase_file, [options.write_hash_file], False) else: diff --git a/src/scripts/test_cli.py b/src/scripts/test_cli.py index 86d9e1900..1753592cc 100755 --- a/src/scripts/test_cli.py +++ b/src/scripts/test_cli.py @@ -75,7 +75,7 @@ def test_cli(cmd, cmd_options, expected_output=None, cmd_input=None): output = stdout.decode('ascii').strip() - if expected_output != None: + if expected_output is not None: if output != expected_output: logging.error("Got unexpected output running cmd %s %s", cmd, cmd_options) logging.info("Output lengths %d vs expected %d", len(output), len(expected_output)) @@ -321,7 +321,7 @@ def cli_compress_tests(): test_cli("compress", input_file) - if os.access(output_file, os.R_OK) != True: + if not os.access(output_file, os.R_OK): logging.error("Compression did not created expected output file") is_py3 = sys.version_info[0] == 3 @@ -339,7 +339,7 @@ def cli_compress_tests(): test_cli("decompress", output_file) - if os.access(input_file, os.R_OK) != True: + if not os.access(input_file, os.R_OK): logging.error("Decompression did not created expected output file") recovered = open(input_file).read() @@ -362,7 +362,7 @@ def cli_dl_group_info_tests(): dl_output = re.compile('(P|G) = [A-F0-9]+') - for bits in [1024,1536,2048,3072,4096,6144,8192]: + for bits in [1024, 1536, 2048, 3072, 4096, 6144, 8192]: output = test_cli("dl_group_info", "modp/ietf/%d" % (bits)) lines = output.split('\n') @@ -370,7 +370,7 @@ def cli_dl_group_info_tests(): logging.error('Unexpected output from dl_group_info') for l in lines: - if dl_output.match(l) == None: + if not dl_output.match(l): logging.error('Unexpected output from dl_group_info') @@ -650,7 +650,7 @@ def main(args=None): logging.error("Usage: ./cli_tests.py path_to_botan_cli") return 1 - if os.access(args[1], os.X_OK) != True: + if not os.access(args[1], os.X_OK): logging.error("Could not access/execute %s", args[1]) return 2 diff --git a/src/scripts/test_python.py b/src/scripts/test_python.py index d3e6cafd7..fa3f49655 100644 --- a/src/scripts/test_python.py +++ b/src/scripts/test_python.py @@ -17,6 +17,7 @@ def hex_decode(buf): return binascii.unhexlify(buf.encode('ascii')) def test(): + # pylint: disable=too-many-statements def test_version(): |