aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-02 17:49:20 -0400
committerJack Lloyd <[email protected]>2018-08-02 17:49:20 -0400
commit6e8f5f1a1d5c03ec5c12ce6febe021f9aad00dcd (patch)
treee458d67df39da00a4e70aafdc3ff1d668e034037
parent5ed67bfbf96a80af77807443177b4925e0a94797 (diff)
Fix complaints from latest pylint
-rwxr-xr-xconfigure.py29
-rwxr-xr-xsrc/scripts/ci_build.py12
-rwxr-xr-xsrc/scripts/cleanup.py2
-rwxr-xr-xsrc/scripts/dist.py14
-rwxr-xr-xsrc/scripts/test_cli.py12
-rw-r--r--src/scripts/test_python.py1
6 files changed, 38 insertions, 32 deletions
diff --git a/configure.py b/configure.py
index 386f0ba5e..b1a988bdb 100755
--- a/configure.py
+++ b/configure.py
@@ -276,7 +276,7 @@ class BuildPaths(object): # pylint: disable=too-many-instance-attributes
else:
raise InternalError("Unknown src info type '%s'" % (typ))
-def process_command_line(args): # pylint: disable=too-many-locals
+def process_command_line(args): # pylint: disable=too-many-locals,too-many-statements
"""
Handle command line options
Do not use logging in this method as command line options need to be
@@ -757,6 +757,7 @@ class ModuleInfo(InfoObject):
"""
def __init__(self, infofile):
+ # pylint: disable=too-many-statements
super(ModuleInfo, self).__init__(infofile)
lex = lex_me_harder(
infofile,
@@ -962,7 +963,7 @@ class ModuleInfo(InfoObject):
def dependencies(self, osinfo):
# base is an implicit dep for all submodules
deps = ['base']
- if self.parent_module != None:
+ if self.parent_module is not None:
deps.append(self.parent_module)
for req in self.requires:
@@ -1208,7 +1209,7 @@ class CompilerInfo(InfoObject): # pylint: disable=too-many-instance-attributes
for what in mach_abi_groups():
if what in self.mach_abi_linking:
flag = self.mach_abi_linking.get(what)
- if flag != None and flag != '' and flag not in abi_link:
+ if flag is not None and flag != '' and flag not in abi_link:
abi_link.add(flag)
if options.msvc_runtime:
@@ -1421,7 +1422,7 @@ class OsInfo(InfoObject): # pylint: disable=too-many-instance-attributes
return False
def building_shared_supported(self):
- return self.soname_pattern_base != None
+ return self.soname_pattern_base is not None
def enabled_features(self, options):
feats = []
@@ -1469,7 +1470,7 @@ def guess_processor(archinfo):
for info_part in system_cpu_info():
if info_part:
match = canon_processor(archinfo, info_part)
- if match != None:
+ if match is not None:
logging.debug("Matched '%s' to processor '%s'" % (info_part, match))
return match, info_part
else:
@@ -1730,13 +1731,13 @@ def create_template_vars(source_paths, build_paths, options, modules, cc, arch,
"""
Figure out what external libraries/frameworks are needed based on selected modules
"""
- if not (module_member_name == 'libs' or module_member_name == 'frameworks'):
+ if module_member_name not in ['libs', 'frameworks']:
raise InternalError("Invalid argument")
libs = set()
for module in modules:
for (osname, module_link_to) in getattr(module, module_member_name).items():
- if osname == 'all' or osname == osinfo.basename:
+ if osname in ['all', osinfo.basename]:
libs |= set(module_link_to)
else:
match = re.match('^all!(.*)', osname)
@@ -1790,7 +1791,7 @@ def create_template_vars(source_paths, build_paths, options, modules, cc, arch,
return osinfo.ar_command
def choose_endian(arch_info, options):
- if options.with_endian != None:
+ if options.with_endian is not None:
return options.with_endian
if options.cpu.endswith('eb') or options.cpu.endswith('be'):
@@ -1985,15 +1986,15 @@ def create_template_vars(source_paths, build_paths, options, modules, cc, arch,
variables['static_suffix'])
if options.build_shared_lib:
- if osinfo.soname_pattern_base != None:
+ if osinfo.soname_pattern_base is not None:
variables['soname_base'] = osinfo.soname_pattern_base.format(**variables)
variables['shared_lib_name'] = variables['soname_base']
- if osinfo.soname_pattern_abi != None:
+ if osinfo.soname_pattern_abi is not None:
variables['soname_abi'] = osinfo.soname_pattern_abi.format(**variables)
variables['shared_lib_name'] = variables['soname_abi']
- if osinfo.soname_pattern_patch != None:
+ if osinfo.soname_pattern_patch is not None:
variables['soname_patch'] = osinfo.soname_pattern_patch.format(**variables)
variables['lib_link_cmd'] = variables['lib_link_cmd'].format(**variables)
@@ -2717,7 +2718,7 @@ def set_defaults_for_unset_options(options, info_arch, info_cc): # pylint: disab
return 'gcc'
return None
- if options.compiler is None and options.compiler_binary != None:
+ if options.compiler is None and options.compiler_binary is not None:
options.compiler = deduce_compiler_type_from_cc_bin(options.compiler_binary)
if options.compiler is None:
@@ -2841,7 +2842,7 @@ def validate_options(options, info_os, info_cc, available_module_policies):
if options.os != options.cpu:
raise UserError('LLVM target requires both CPU and OS be set to llvm')
- if options.build_fuzzers != None:
+ if options.build_fuzzers is not None:
if options.build_fuzzers not in ['libfuzzer', 'afl', 'klee', 'test']:
raise UserError('Bad value to --build-fuzzers')
@@ -2962,7 +2963,7 @@ def check_compiler_arch(options, ccinfo, archinfo, source_paths):
return cc_output
def do_io_for_build(cc, arch, osinfo, using_mods, build_paths, source_paths, template_vars, options):
- # pylint: disable=too-many-locals,too-many-branches
+ # pylint: disable=too-many-locals,too-many-branches,too-many-statements
try:
robust_rmtree(build_paths.build_dir)
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():