From bf98ffca9ee67a6a942b9abf96b536692370cf03 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Tue, 23 Apr 2019 14:55:02 +0200 Subject: [PATCH 1/7] Fix blind exceptions --- mesonbuild/ast/introspection.py | 2 +- mesonbuild/compilers/c.py | 2 +- mesonbuild/dependencies/base.py | 2 +- mesonbuild/minstall.py | 2 +- mesonbuild/scripts/depfixer.py | 2 +- mesonbuild/wrap/wrap.py | 2 +- run_project_tests.py | 2 +- run_unittests.py | 6 +++--- sideci.yml | 2 ++ 9 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 49d531f1b..34e3e0998 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -122,7 +122,7 @@ class IntrospectionInterpreter(AstInterpreter): subi.analyze() subi.project_data['name'] = dirname self.project_data['subprojects'] += [subi.project_data] - except: + except (mesonlib.MesonException, RuntimeError): return def func_add_languages(self, node, args, kwargs): diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 54ca894dc..8da0518dc 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -1036,7 +1036,7 @@ class CCompiler(Compiler): elf_class = 2 else: elf_class = 1 - except: + except (MesonException, KeyError): # TODO evaluate if catching KeyError is wanted here elf_class = 0 # Search in the specified dirs, and then in the system libraries for d in itertools.chain(extra_dirs, self.get_library_dirs(env, elf_class)): diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 6063fd377..313f2a016 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -1107,7 +1107,7 @@ class CMakeDependency(ExternalDependency): for l in lexer1: if l.func == 'set': self._cmake_set(l) - except: + except MesonException: return None # Extract the variables and sanity check them diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index c6b6bbf8e..04aba2fa7 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -93,7 +93,7 @@ def set_chown(path, user=None, group=None, dir_fd=None, follow_symlinks=True): dir_fd=dir_fd, follow_symlinks=follow_symlinks) shutil.chown(path, user, group) - except: + except Exception: raise finally: os.chown = real_os_chown diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index 7294186e7..19fe0febe 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -123,7 +123,7 @@ class Elf(DataSizes): self.parse_header() self.parse_sections() self.parse_dynamic() - except: + except (struct.error, RuntimeError): self.bf.close() raise diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 4d9d03241..4a5d726a0 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -84,7 +84,7 @@ class PackageDefinition: try: self.config = configparser.ConfigParser(interpolation=None) self.config.read(fname) - except: + except configparser.Error: raise WrapException('Failed to parse {}'.format(self.basename)) if len(self.config.sections()) < 1: raise WrapException('Missing sections in {}'.format(self.basename)) diff --git a/run_project_tests.py b/run_project_tests.py index c1d42fce1..8fb351c2a 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -774,7 +774,7 @@ def detect_system_compiler(): try: comp = env.compiler_from_language(lang, env.is_cross_build()) details = '%s %s' % (' '.join(comp.get_exelist()), comp.get_version_string()) - except: + except mesonlib.MesonException: comp = None details = 'not found' print('%-7s: %s' % (lang, details)) diff --git a/run_unittests.py b/run_unittests.py index 2457a5037..ab7ad0446 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1244,7 +1244,7 @@ class BasePlatformTests(unittest.TestCase): print('Stderr:\n') print(err) raise RuntimeError('Configure failed') - except: + except Exception: self._print_meson_log() raise finally: @@ -1257,7 +1257,7 @@ class BasePlatformTests(unittest.TestCase): out = self._run(self.setup_command + args + extra_args) except unittest.SkipTest: raise unittest.SkipTest('Project requested skipping: ' + srcdir) - except: + except Exception: self._print_meson_log() raise return out @@ -4443,7 +4443,7 @@ class LinuxlikeTests(BasePlatformTests): self.assertIn(cmd_std, cmd) try: self.build() - except: + except Exception: print('{} was {!r}'.format(lang_std, v)) raise self.wipe() diff --git a/sideci.yml b/sideci.yml index 2e95afd9c..38eb811d1 100644 --- a/sideci.yml +++ b/sideci.yml @@ -1,3 +1,5 @@ linter: flake8: version: 3 + plugins: + - flake8-blind-except From e75211d321d7416b8a4871d3015a7915fb86b53b Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Tue, 23 Apr 2019 14:58:18 +0200 Subject: [PATCH 2/7] Fix builtin variable names --- mesonbuild/ast/introspection.py | 6 +++--- mesonbuild/backend/ninjabackend.py | 4 ++-- mesonbuild/compilers/cs.py | 4 ++-- mesonbuild/dependencies/ui.py | 8 ++++---- mesonbuild/mesonlib.py | 16 ++++++++-------- mesonbuild/mesonmain.py | 30 +++++++++++++++--------------- mesonbuild/minstall.py | 2 +- mesonbuild/mlog.py | 10 +++++----- mesonbuild/modules/python.py | 6 +++--- mesonbuild/modules/windows.py | 4 ++-- mesonbuild/munstable_coredata.py | 10 +++++----- run_unittests.py | 4 ++-- setup.cfg | 2 ++ sideci.yml | 1 + 14 files changed, 55 insertions(+), 52 deletions(-) diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 34e3e0998..b6ec45012 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -173,9 +173,9 @@ class IntrospectionInterpreter(AstInterpreter): arg_node = curr.args elif isinstance(curr, IdNode): # Try to resolve the ID and append the node to the queue - id = curr.value - if id in self.assignments and self.assignments[id]: - tmp_node = self.assignments[id][0] + var_name = curr.value + if var_name in self.assignments and self.assignments[var_name]: + tmp_node = self.assignments[var_name][0] if isinstance(tmp_node, (ArrayNode, IdNode, FunctionNode)): srcqueue += [tmp_node] elif isinstance(curr, ArithmeticNode): diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 9a6fdadac..04838c719 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -406,9 +406,9 @@ int dummy; } } ''' - id = target.get_id() + tid = target.get_id() lang = comp.get_language() - tgt = self.introspection_data[id] + tgt = self.introspection_data[tid] # Find an existing entry or create a new one id_hash = (lang, tuple(parameters)) src_block = tgt.get(id_hash, None) diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py index cd67da0a1..c6355f28f 100644 --- a/mesonbuild/compilers/cs.py +++ b/mesonbuild/compilers/cs.py @@ -28,10 +28,10 @@ cs_optimization_args = {'0': [], } class CsCompiler(Compiler): - def __init__(self, exelist, version, id, runner=None): + def __init__(self, exelist, version, comp_id, runner=None): self.language = 'cs' super().__init__(exelist, version) - self.id = id + self.id = comp_id self.is_cross = False self.runner = runner diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index ce1ca6834..b473ac8da 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -298,8 +298,8 @@ class QtBaseDependency(ExternalDependency): # the Qt + m_name there is not a symlink, it's a file mod_private_dir = qt_inc_dir mod_private_inc = _qt_get_private_includes(mod_private_dir, m_name, m.version) - for dir in mod_private_inc: - self.compile_args.append('-I' + dir) + for directory in mod_private_inc: + self.compile_args.append('-I' + directory) self.link_args += m.get_link_args() if 'Core' in modules: @@ -402,8 +402,8 @@ class QtBaseDependency(ExternalDependency): if self.private_headers: priv_inc = self.get_private_includes(mincdir, module) - for dir in priv_inc: - self.compile_args.append('-I' + dir) + for directory in priv_inc: + self.compile_args.append('-I' + directory) libfile = self.clib_compiler.find_library(self.qtpkgname + module + modules_lib_suffix, self.env, libdir) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 721994601..d5e60fd1e 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -722,11 +722,11 @@ def has_path_sep(name, sep='/\\'): return True return False -def do_replacement(regex, line, format, confdata): +def do_replacement(regex, line, variable_format, confdata): missing_variables = set() start_tag = '@' backslash_tag = '\\@' - if format == 'cmake': + if variable_format == 'cmake': start_tag = '${' backslash_tag = '\\${' @@ -779,7 +779,7 @@ def do_mesondefine(line, confdata): raise MesonException('#mesondefine argument "%s" is of unknown type.' % varname) -def do_conf_file(src, dst, confdata, format, encoding='utf-8'): +def do_conf_file(src, dst, confdata, variable_format, encoding='utf-8'): try: with open(src, encoding=encoding, newline='') as f: data = f.readlines() @@ -787,15 +787,15 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'): raise MesonException('Could not read input file %s: %s' % (src, str(e))) # Only allow (a-z, A-Z, 0-9, _, -) as valid characters for a define # Also allow escaping '@' with '\@' - if format in ['meson', 'cmake@']: + if variable_format in ['meson', 'cmake@']: regex = re.compile(r'(?:\\\\)+(?=\\?@)|\\@|@([-a-zA-Z0-9_]+)@') - elif format == 'cmake': + elif variable_format == 'cmake': regex = re.compile(r'(?:\\\\)+(?=\\?\$)|\\\${|\${([-a-zA-Z0-9_]+)}') else: - raise MesonException('Format "{}" not handled'.format(format)) + raise MesonException('Format "{}" not handled'.format(variable_format)) search_token = '#mesondefine' - if format != 'meson': + if variable_format != 'meson': search_token = '#cmakedefine' result = [] @@ -808,7 +808,7 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'): confdata_useless = False line = do_mesondefine(line, confdata) else: - line, missing = do_replacement(regex, line, format, confdata) + line, missing = do_replacement(regex, line, variable_format, confdata) missing_variables.update(missing) if missing: confdata_useless = False diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 4326c2042..c94f1bf9d 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -41,41 +41,41 @@ class CommandLineParser: self.subparsers = self.parser.add_subparsers(title='Commands', description='If no command is specified it defaults to setup command.') self.add_command('setup', msetup.add_arguments, msetup.run, - help='Configure the project') + help_msg='Configure the project') self.add_command('configure', mconf.add_arguments, mconf.run, - help='Change project options',) + help_msg='Change project options',) self.add_command('install', minstall.add_arguments, minstall.run, - help='Install the project') + help_msg='Install the project') self.add_command('introspect', mintro.add_arguments, mintro.run, - help='Introspect project') + help_msg='Introspect project') self.add_command('init', minit.add_arguments, minit.run, - help='Create a new project') + help_msg='Create a new project') self.add_command('test', mtest.add_arguments, mtest.run, - help='Run tests') + help_msg='Run tests') self.add_command('wrap', wraptool.add_arguments, wraptool.run, - help='Wrap tools') + help_msg='Wrap tools') self.add_command('subprojects', msubprojects.add_arguments, msubprojects.run, - help='Manage subprojects') + help_msg='Manage subprojects') self.add_command('help', self.add_help_arguments, self.run_help_command, - help='Print help of a subcommand') + help_msg='Print help of a subcommand') self.add_command('rewrite', lambda parser: rewriter.add_arguments(parser, self.formater), rewriter.run, - help='Modify the project definition') + help_msg='Modify the project definition') # Hidden commands self.add_command('runpython', self.add_runpython_arguments, self.run_runpython_command, - help=argparse.SUPPRESS) + help_msg=argparse.SUPPRESS) self.add_command('unstable-coredata', munstable_coredata.add_arguments, munstable_coredata.run, - help=argparse.SUPPRESS) + help_msg=argparse.SUPPRESS) - def add_command(self, name, add_arguments_func, run_func, help, aliases=None): + def add_command(self, name, add_arguments_func, run_func, help_msg, aliases=None): aliases = aliases or [] # FIXME: Cannot have hidden subparser: # https://bugs.python.org/issue22848 - if help == argparse.SUPPRESS: + if help_msg == argparse.SUPPRESS: p = argparse.ArgumentParser(prog='meson ' + name, formatter_class=self.formater) self.hidden_commands.append(name) else: - p = self.subparsers.add_parser(name, help=help, aliases=aliases, formatter_class=self.formater) + p = self.subparsers.add_parser(name, help=help_msg, aliases=aliases, formatter_class=self.formater) add_arguments_func(p) p.set_defaults(run_func=run_func) for i in [name] + aliases: diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index 04aba2fa7..ed82c3791 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -65,7 +65,7 @@ class DirMaker: def __enter__(self): return self - def __exit__(self, type, value, traceback): + def __exit__(self, exception_type, value, traceback): self.dirs.reverse() for d in self.dirs: append_to_log(self.lf, d) diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index e8ee6c826..21212829a 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -234,14 +234,14 @@ def exception(e: Exception, prefix: AnsiDecorator = red('ERROR:')) -> None: # Format a list for logging purposes as a string. It separates # all but the last item with commas, and the last with 'and'. -def format_list(list_: typing.List[str]) -> str: - l = len(list_) +def format_list(input_list: typing.List[str]) -> str: + l = len(input_list) if l > 2: - return ' and '.join([', '.join(list_[:-1]), list_[-1]]) + return ' and '.join([', '.join(input_list[:-1]), input_list[-1]]) elif l == 2: - return ' and '.join(list_) + return ' and '.join(input_list) elif l == 1: - return list_[0] + return input_list[0] else: return '' diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index a0ebe0eea..04941eaba 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -477,9 +477,9 @@ class PythonModule(ExtensionModule): ver = {'python2': '-2', 'python3': '-3'}[name_or_path] cmd = ['py', ver, '-c', "import sysconfig; print(sysconfig.get_config_var('BINDIR'))"] _, stdout, _ = mesonlib.Popen_safe(cmd) - dir = stdout.strip() - if os.path.exists(dir): - return os.path.join(dir, 'python') + directory = stdout.strip() + if os.path.exists(directory): + return os.path.join(directory, 'python') else: return None diff --git a/mesonbuild/modules/windows.py b/mesonbuild/modules/windows.py index e8d266e54..87a83fe26 100644 --- a/mesonbuild/modules/windows.py +++ b/mesonbuild/modules/windows.py @@ -59,7 +59,7 @@ class WindowsModule(ExtensionModule): if not rescomp.found(): raise MesonException('Could not find Windows resource compiler') - for (arg, match, type) in [ + for (arg, match, rc_type) in [ ('/?', '^.*Microsoft.*Resource Compiler.*$', ResourceCompilerType.rc), ('--version', '^.*GNU windres.*$', ResourceCompilerType.windres), ]: @@ -67,7 +67,7 @@ class WindowsModule(ExtensionModule): m = re.search(match, o, re.MULTILINE) if m: mlog.log('Windows resource compiler: %s' % m.group()) - self._rescomp = (rescomp, type) + self._rescomp = (rescomp, rc_type) break else: raise MesonException('Could not determine type of Windows resource compiler') diff --git a/mesonbuild/munstable_coredata.py b/mesonbuild/munstable_coredata.py index aaf652300..795722254 100644 --- a/mesonbuild/munstable_coredata.py +++ b/mesonbuild/munstable_coredata.py @@ -51,7 +51,7 @@ def run(options): 'change the working directory to it.') return 1 - all = options.all + all_backends = options.all print('This is a dump of the internal unstable cache of meson. This is for debugging only.') print('Do NOT parse, this will change from version to version in incompatible ways') @@ -64,18 +64,18 @@ def run(options): # use `meson configure` to view these pass elif k in ['install_guid', 'test_guid', 'regen_guid']: - if all or backend.startswith('vs'): + if all_backends or backend.startswith('vs'): print(k + ': ' + v) elif k == 'target_guids': - if all or backend.startswith('vs'): + if all_backends or backend.startswith('vs'): print(k + ':') dump_guids(v) elif k in ['lang_guids']: - if all or backend.startswith('vs') or backend == 'xcode': + if all_backends or backend.startswith('vs') or backend == 'xcode': print(k + ':') dump_guids(v) elif k == 'meson_command': - if all or backend.startswith('vs'): + if all_backends or backend.startswith('vs'): print('Meson command used in build file regeneration: ' + ' '.join(v)) elif k == 'pkgconf_envvar': print('Last seen PKGCONFIG enviroment variable value: ' + v) diff --git a/run_unittests.py b/run_unittests.py index ab7ad0446..0cc1531db 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2681,9 +2681,9 @@ int main(int argc, char **argv) { if ninja is None: raise unittest.SkipTest('This test currently requires ninja. Fix this once "meson build" works.') for lang in ('c', 'cpp'): - for type in ('executable', 'library'): + for target_type in ('executable', 'library'): with tempfile.TemporaryDirectory() as tmpdir: - self._run(self.meson_command + ['init', '--language', lang, '--type', type], + self._run(self.meson_command + ['init', '--language', lang, '--type', target_type], workdir=tmpdir) self._run(self.setup_command + ['--backend=ninja', 'builddir'], workdir=tmpdir) diff --git a/setup.cfg b/setup.cfg index 7a94d8535..d81878675 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,4 +28,6 @@ ignore = E722 # W504: line break after binary operator W504 + # A003: builtin class attribute + A003 max-line-length = 120 diff --git a/sideci.yml b/sideci.yml index 38eb811d1..af654574d 100644 --- a/sideci.yml +++ b/sideci.yml @@ -3,3 +3,4 @@ linter: version: 3 plugins: - flake8-blind-except + - flake8-builtins From 2b5831f94fdfdbce711189502c6f41606c12af61 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Tue, 23 Apr 2019 14:59:54 +0200 Subject: [PATCH 3/7] Fix flake8-bugbear warnings --- mesonbuild/ast/visitor.py | 2 -- mesonbuild/backend/backends.py | 4 ++- mesonbuild/coredata.py | 2 +- mesonbuild/dependencies/base.py | 6 +++-- mesonbuild/interpreterbase.py | 2 +- mesonbuild/mintro.py | 2 +- mesonbuild/mlog.py | 43 ++++++++++++++++++--------------- mesonbuild/mparser.py | 2 +- sideci.yml | 1 + 9 files changed, 35 insertions(+), 29 deletions(-) diff --git a/mesonbuild/ast/visitor.py b/mesonbuild/ast/visitor.py index c8769d436..fab4ed24a 100644 --- a/mesonbuild/ast/visitor.py +++ b/mesonbuild/ast/visitor.py @@ -134,7 +134,5 @@ class AstVisitor: self.visit_default_func(node) for i in node.arguments: i.accept(self) - for i in node.commas: - pass for val in node.kwargs.values(): val.accept(self) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 4a4f7f493..5ff9b550a 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -320,12 +320,14 @@ class Backend: raise MesonException('Unknown data type in object list.') return obj_list - def serialize_executable(self, tname, exe, cmd_args, workdir, env={}, + def serialize_executable(self, tname, exe, cmd_args, workdir, env=None, extra_paths=None, capture=None): ''' Serialize an executable for running with a generator or a custom target ''' import hashlib + if env is None: + env = {} if extra_paths is None: # The callee didn't check if we needed extra paths, so check it here if mesonlib.is_windows() or mesonlib.is_cygwin(): diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 9281019c8..b8360863d 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -20,7 +20,7 @@ from pathlib import PurePath from collections import OrderedDict from .mesonlib import ( MesonException, MachineChoice, PerMachine, - default_libdir, default_libexecdir, default_prefix, stringlistify + default_libdir, default_libexecdir, default_prefix ) from .wrap import WrapMode import ast diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 313f2a016..c34b1028f 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -924,9 +924,11 @@ class CMakeTraceLine: return s.format(self.file, self.line, self.func, self.args) class CMakeTarget: - def __init__(self, name, type, properies = {}): + def __init__(self, name, target_type, properies = None): + if properies is None: + properies = {} self.name = name - self.type = type + self.type = target_type self.properies = properies def __repr__(self): diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index c148cbdb1..8a67f2516 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -144,7 +144,7 @@ def stringArgs(f): return wrapped def noArgsFlattening(f): - setattr(f, 'no-args-flattening', True) + setattr(f, 'no-args-flattening', True) # noqa: B010 return f def disablerIfNotFound(f): diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index a4a6978a7..c47fffdba 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -27,7 +27,7 @@ from . import mlog from .backend import backends from .mparser import FunctionNode, ArrayNode, ArgumentNode, StringNode from typing import List, Optional -import sys, os +import os import pathlib def get_meson_info_file(info_dir: str): diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 21212829a..79dee4781 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -19,6 +19,7 @@ import time import platform from contextlib import contextmanager import typing +from typing import Any, Generator, List, Optional, Sequence, TextIO, Union """This is (mostly) a standalone module used to write logging information about Meson runs. Some output goes to screen, @@ -43,11 +44,11 @@ if platform.system().lower() == 'windows': colorize_console = os.isatty(sys.stdout.fileno()) and _windows_ansi() # type: bool else: colorize_console = os.isatty(sys.stdout.fileno()) and os.environ.get('TERM') != 'dumb' -log_dir = None # type: typing.Optional[str] -log_file = None # type: typing.Optional[typing.TextIO] +log_dir = None # type: Optional[str] +log_file = None # type: Optional[TextIO] log_fname = 'meson-log.txt' # type: str log_depth = 0 # type: int -log_timestamp_start = None # type: typing.Optional[float] +log_timestamp_start = None # type: Optional[float] log_fatal_warnings = False # type: bool log_disable_stdout = False # type: bool log_errors_only = False # type: bool @@ -78,7 +79,7 @@ def set_timestamp_start(start: float) -> None: global log_timestamp_start log_timestamp_start = start -def shutdown() -> typing.Optional[str]: +def shutdown() -> Optional[str]: global log_file if log_file is not None: path = log_file.name @@ -124,8 +125,8 @@ def cyan(text: str) -> AnsiDecorator: # This really should be AnsiDecorator or anything that implements # __str__(), but that requires protocols from typing_extensions -def process_markup(args: typing.Sequence[typing.Union[AnsiDecorator, str]], keep: bool) -> typing.List[str]: - arr = [] # type: typing.List[str] +def process_markup(args: Sequence[Union[AnsiDecorator, str]], keep: bool) -> List[str]: + arr = [] # type: List[str] if log_timestamp_start is not None: arr = ['[{:.3f}]'.format(time.monotonic() - log_timestamp_start)] for arg in args: @@ -139,7 +140,7 @@ def process_markup(args: typing.Sequence[typing.Union[AnsiDecorator, str]], keep arr.append(str(arg)) return arr -def force_print(*args: str, **kwargs: typing.Any) -> None: +def force_print(*args: str, **kwargs: Any) -> None: global log_disable_stdout if log_disable_stdout: return @@ -160,14 +161,14 @@ def force_print(*args: str, **kwargs: typing.Any) -> None: print(cleaned, end='') # We really want a heterogenous dict for this, but that's in typing_extensions -def debug(*args: typing.Union[str, AnsiDecorator], **kwargs: typing.Any) -> None: +def debug(*args: Union[str, AnsiDecorator], **kwargs: Any) -> None: arr = process_markup(args, False) if log_file is not None: print(*arr, file=log_file, **kwargs) log_file.flush() -def log(*args: typing.Union[str, AnsiDecorator], is_error: bool = False, - **kwargs: typing.Any) -> None: +def log(*args: Union[str, AnsiDecorator], is_error: bool = False, + **kwargs: Any) -> None: global log_errors_only arr = process_markup(args, False) if log_file is not None: @@ -178,7 +179,7 @@ def log(*args: typing.Union[str, AnsiDecorator], is_error: bool = False, if not log_errors_only or is_error: force_print(*arr, **kwargs) -def _log_error(severity: str, *rargs: typing.Union[str, AnsiDecorator], **kwargs: typing.Any) -> None: +def _log_error(severity: str, *rargs: Union[str, AnsiDecorator], **kwargs: Any) -> None: from .mesonlib import get_error_location_string from .environment import build_filename from .mesonlib import MesonException @@ -186,7 +187,7 @@ def _log_error(severity: str, *rargs: typing.Union[str, AnsiDecorator], **kwargs # The tping requirements here are non-obvious. Lists are invariant, # therefore List[A] and List[Union[A, B]] are not able to be joined if severity == 'warning': - label = [yellow('WARNING:')] # type: typing.List[typing.Union[str, AnsiDecorator]] + label = [yellow('WARNING:')] # type: List[Union[str, AnsiDecorator]] elif severity == 'error': label = [red('ERROR:')] elif severity == 'deprecation': @@ -202,7 +203,7 @@ def _log_error(severity: str, *rargs: typing.Union[str, AnsiDecorator], **kwargs location_str = get_error_location_string(location_file, location.lineno) # Unions are frankly awful, and we have to cast here to get mypy # to understand that the list concatenation is safe - location_list = typing.cast(typing.List[typing.Union[str, AnsiDecorator]], [location_str]) + location_list = typing.cast(List[Union[str, AnsiDecorator]], [location_str]) args = location_list + args log(*args, **kwargs) @@ -211,18 +212,20 @@ def _log_error(severity: str, *rargs: typing.Union[str, AnsiDecorator], **kwargs if log_fatal_warnings: raise MesonException("Fatal warnings enabled, aborting") -def error(*args: typing.Union[str, AnsiDecorator], **kwargs: typing.Any) -> None: +def error(*args: Union[str, AnsiDecorator], **kwargs: Any) -> None: return _log_error('error', *args, **kwargs, is_error=True) -def warning(*args: typing.Union[str, AnsiDecorator], **kwargs: typing.Any) -> None: +def warning(*args: Union[str, AnsiDecorator], **kwargs: Any) -> None: return _log_error('warning', *args, **kwargs, is_error=True) -def deprecation(*args: typing.Union[str, AnsiDecorator], **kwargs: typing.Any) -> None: +def deprecation(*args: Union[str, AnsiDecorator], **kwargs: Any) -> None: return _log_error('deprecation', *args, **kwargs, is_error=True) -def exception(e: Exception, prefix: AnsiDecorator = red('ERROR:')) -> None: +def exception(e: Exception, prefix: Optional[AnsiDecorator] = None) -> None: + if prefix is None: + prefix = red('ERROR:') log() - args = [] # type: typing.List[typing.Union[AnsiDecorator, str]] + args = [] # type: List[Union[AnsiDecorator, str]] if hasattr(e, 'file') and hasattr(e, 'lineno') and hasattr(e, 'colno'): # Mypy can't figure this out, and it's pretty easy to vidual inspect # that this is correct, so we'll just ignore it. @@ -234,7 +237,7 @@ def exception(e: Exception, prefix: AnsiDecorator = red('ERROR:')) -> None: # Format a list for logging purposes as a string. It separates # all but the last item with commas, and the last with 'and'. -def format_list(input_list: typing.List[str]) -> str: +def format_list(input_list: List[str]) -> str: l = len(input_list) if l > 2: return ' and '.join([', '.join(input_list[:-1]), input_list[-1]]) @@ -246,7 +249,7 @@ def format_list(input_list: typing.List[str]) -> str: return '' @contextmanager -def nested() -> typing.Generator[None, None, None]: +def nested() -> Generator[None, None, None]: global log_depth log_depth += 1 try: diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 4305a7cb4..b4fb03284 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -217,7 +217,7 @@ class BaseNode: fname = 'visit_{}'.format(type(self).__name__) if hasattr(visitor, fname): func = getattr(visitor, fname) - if hasattr(func, '__call__'): + if callable(func): func(self) class ElementaryNode(BaseNode): diff --git a/sideci.yml b/sideci.yml index af654574d..5c5619692 100644 --- a/sideci.yml +++ b/sideci.yml @@ -4,3 +4,4 @@ linter: plugins: - flake8-blind-except - flake8-builtins + - flake8-bugbear From 3581839f4c611eeb14e64ca2ed6de4dd652ad84b Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Tue, 23 Apr 2019 15:00:39 +0200 Subject: [PATCH 4/7] Fix unused variables warnings --- mesonbuild/backend/ninjabackend.py | 10 +++++----- mesonbuild/backend/vs2010backend.py | 2 +- mesonbuild/backend/xcodebackend.py | 4 ++-- mesonbuild/interpreter.py | 2 +- mesonbuild/mintro.py | 6 +++--- mesonbuild/scripts/depfixer.py | 2 +- mesonbuild/wrap/wrap.py | 2 +- run_project_tests.py | 2 +- run_tests.py | 2 +- tools/boost_names.py | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 04838c719..0eb6e9808 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -520,7 +520,7 @@ int dummy; # This will be set as dependencies of all the target's sources. At the # same time, also deal with generated sources that need to be compiled. generated_source_files = [] - for rel_src, gensrc in generated_sources.items(): + for rel_src, _ in generated_sources.items(): dirpart, fnamepart = os.path.split(rel_src) raw_src = File(True, dirpart, fnamepart) if self.environment.is_source(rel_src) and not self.environment.is_header(rel_src): @@ -585,7 +585,7 @@ int dummy; obj_list.append(self.generate_single_compile(target, src, 'vala', [], header_deps)) # Generate compile targets for all the pre-existing sources for this target - for f, src in target_sources.items(): + for _, src in target_sources.items(): if not self.environment.is_header(src): if self.environment.is_llvm_ir(src): obj_list.append(self.generate_llvm_ir_compile(target, src)) @@ -912,7 +912,7 @@ int dummy; # Add possible java generated files to src list generated_sources = self.get_target_generated_sources(target) gen_src_list = [] - for rel_src, gensrc in generated_sources.items(): + for rel_src, _ in generated_sources.items(): dirpart, fnamepart = os.path.split(rel_src) raw_src = File(True, dirpart, fnamepart) if rel_src.endswith('.java'): @@ -1041,7 +1041,7 @@ int dummy; def generate_single_java_compile(self, src, target, compiler, args): deps = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets] generated_sources = self.get_target_generated_sources(target) - for rel_src, gensrc in generated_sources.items(): + for rel_src, _ in generated_sources.items(): if rel_src.endswith('.java'): deps.append(rel_src) rel_src = src.rel_to_builddir(self.build_to_src) @@ -1227,7 +1227,7 @@ int dummy; if len(target.install_dir) > 3 and target.install_dir[3] is True: target.install_dir[3] = os.path.join(self.environment.get_datadir(), 'gir-1.0') # Detect gresources and add --gresources arguments for each - for (gres, gensrc) in other_src[1].items(): + for (_, gensrc) in other_src[1].items(): if isinstance(gensrc, modules.GResourceTarget): gres_xml, = self.get_custom_target_sources(gensrc) args += ['--gresources=' + gres_xml] diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index d1bf1e58f..dcf889ca3 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -457,7 +457,7 @@ class Vs2010Backend(backends.Backend): def add_target_deps(self, root, target): target_dict = {target.get_id(): target} - for name, dep in self.get_target_deps(target_dict).items(): + for _, dep in self.get_target_deps(target_dict).items(): if dep.get_id() in self.handled_target_deps[target.get_id()]: # This dependency was already handled manually. continue diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 7dd367430..a23f42401 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -345,7 +345,7 @@ class XCodeBackend(backends.Backend): self.ofile.write('/* End PBXFileReference section */\n') def generate_pbx_frameworks_buildphase(self): - for tname, t in self.build.targets.items(): + for _, t in self.build.targets.items(): self.ofile.write('\n/* Begin PBXFrameworksBuildPhase section */\n') self.write_line('%s /* %s */ = {\n' % (t.buildphasemap['Frameworks'], 'Frameworks')) self.indent_level += 1 @@ -587,7 +587,7 @@ class XCodeBackend(backends.Backend): def generate_pbx_sources_build_phase(self): self.ofile.write('\n/* Begin PBXSourcesBuildPhase section */\n') - for name, phase_id in self.source_phase.items(): + for name, _ in self.source_phase.items(): t = self.build.targets[name] self.write_line('%s /* Sources */ = {' % (t.buildphasemap[name])) self.indent_level += 1 diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 8ca7758f5..d125a0c02 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2193,7 +2193,7 @@ class Interpreter(InterpreterBase): def check_cross_stdlibs(self): if self.build.environment.is_cross_build(): props = self.build.environment.properties.host - for l, c in self.build.cross_compilers.items(): + for l, _ in self.build.cross_compilers.items(): try: di = mesonlib.stringlistify(props.get_stdlib(l)) if len(di) != 2: diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index c47fffdba..8c8aa15a9 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -117,11 +117,11 @@ def list_installed(installdata): for t in installdata.targets: res[os.path.join(installdata.build_dir, t.fname)] = \ os.path.join(installdata.prefix, t.outdir, os.path.basename(t.fname)) - for path, installpath, unused_prefix in installdata.data: + for path, installpath, _ in installdata.data: res[path] = os.path.join(installdata.prefix, installpath) - for path, installdir, unused_custom_install_mode in installdata.headers: + for path, installdir, _ in installdata.headers: res[path] = os.path.join(installdata.prefix, installdir, os.path.basename(path)) - for path, installpath, unused_custom_install_mode in installdata.man: + for path, installpath, _ in installdata.man: res[path] = os.path.join(installdata.prefix, installpath) return res diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index 19fe0febe..cc4669cb9 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -180,7 +180,7 @@ class Elf(DataSizes): def parse_sections(self): self.bf.seek(self.e_shoff) self.sections = [] - for i in range(self.e_shnum): + for _ in range(self.e_shnum): self.sections.append(SectionHeader(self.bf, self.ptrsize, self.is_le)) def read_str(self): diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 4a5d726a0..3eb68a7f7 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -338,7 +338,7 @@ class Resolver: """ Copy directory tree. Overwrites also read only files. """ - for src_dir, dirs, files in os.walk(root_src_dir): + for src_dir, _, files in os.walk(root_src_dir): dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1) if not os.path.exists(dst_dir): os.makedirs(dst_dir) diff --git a/run_project_tests.py b/run_project_tests.py index 8fb351c2a..4406e1e12 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -819,7 +819,7 @@ if __name__ == '__main__': print(l, '\n') except UnicodeError: print(l.encode('ascii', errors='replace').decode(), '\n') - for name, dirs, skip in all_tests: + for name, dirs, _ in all_tests: dirs = (x.name for x in dirs) for k, g in itertools.groupby(dirs, key=lambda x: x.split()[0]): tests = list(g) diff --git a/run_tests.py b/run_tests.py index fb3bc28f5..a4b0fa27b 100755 --- a/run_tests.py +++ b/run_tests.py @@ -136,7 +136,7 @@ def find_vcxproj_with_target(builddir, target): p = r'{}\s*\{}'.format(t, ext) else: p = r'{}'.format(t) - for root, dirs, files in os.walk(builddir): + for _, _, files in os.walk(builddir): for f in fnmatch.filter(files, '*.vcxproj'): f = os.path.join(builddir, f) with open(f, 'r', encoding='utf-8') as o: diff --git a/tools/boost_names.py b/tools/boost_names.py index d381162bd..d0e544449 100755 --- a/tools/boost_names.py +++ b/tools/boost_names.py @@ -132,7 +132,7 @@ def get_modules_2(): # The python module uses an older build system format and is not easily parseable. # We add the python module libraries manually. modules.append(Module('python', 'Python', ['boost_python', 'boost_python3', 'boost_numpy', 'boost_numpy3'])) - for (root, dirs, files) in os.walk(LIBS): + for (root, _, files) in os.walk(LIBS): for f in files: if f == "libraries.json": projectdir = os.path.dirname(root) From 5ec79185a035f42b15d646f304a2b3eb1a281952 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Wed, 24 Apr 2019 09:48:51 +0200 Subject: [PATCH 5/7] Address code review --- mesonbuild/dependencies/base.py | 2 +- mesonbuild/interpreterbase.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index c34b1028f..c09f7994a 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -924,7 +924,7 @@ class CMakeTraceLine: return s.format(self.file, self.line, self.func, self.args) class CMakeTarget: - def __init__(self, name, target_type, properies = None): + def __init__(self, name, target_type, properies=None): if properies is None: properies = {} self.name = name diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 8a67f2516..71a4ef389 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -144,7 +144,7 @@ def stringArgs(f): return wrapped def noArgsFlattening(f): - setattr(f, 'no-args-flattening', True) # noqa: B010 + setattr(f, 'no-args-flattening', True) # noqa: B010 return f def disablerIfNotFound(f): From 236221061a14d5758f47531a49efddde42c73df7 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Wed, 24 Apr 2019 21:34:25 +0200 Subject: [PATCH 6/7] Fixed unnecessary .items() --- mesonbuild/backend/ninjabackend.py | 12 ++++++------ mesonbuild/backend/vs2010backend.py | 6 +++--- mesonbuild/backend/xcodebackend.py | 4 ++-- mesonbuild/interpreter.py | 2 +- mesonbuild/wrap/wraptool.py | 2 +- run_unittests.py | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 0eb6e9808..7eafcad2a 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -520,7 +520,7 @@ int dummy; # This will be set as dependencies of all the target's sources. At the # same time, also deal with generated sources that need to be compiled. generated_source_files = [] - for rel_src, _ in generated_sources.items(): + for rel_src in generated_sources.keys(): dirpart, fnamepart = os.path.split(rel_src) raw_src = File(True, dirpart, fnamepart) if self.environment.is_source(rel_src) and not self.environment.is_header(rel_src): @@ -585,7 +585,7 @@ int dummy; obj_list.append(self.generate_single_compile(target, src, 'vala', [], header_deps)) # Generate compile targets for all the pre-existing sources for this target - for _, src in target_sources.items(): + for src in target_sources.values(): if not self.environment.is_header(src): if self.environment.is_llvm_ir(src): obj_list.append(self.generate_llvm_ir_compile(target, src)) @@ -912,7 +912,7 @@ int dummy; # Add possible java generated files to src list generated_sources = self.get_target_generated_sources(target) gen_src_list = [] - for rel_src, _ in generated_sources.items(): + for rel_src in generated_sources.keys(): dirpart, fnamepart = os.path.split(rel_src) raw_src = File(True, dirpart, fnamepart) if rel_src.endswith('.java'): @@ -1041,7 +1041,7 @@ int dummy; def generate_single_java_compile(self, src, target, compiler, args): deps = [os.path.join(self.get_target_dir(l), l.get_filename()) for l in target.link_targets] generated_sources = self.get_target_generated_sources(target) - for rel_src, _ in generated_sources.items(): + for rel_src in generated_sources.keys(): if rel_src.endswith('.java'): deps.append(rel_src) rel_src = src.rel_to_builddir(self.build_to_src) @@ -1227,7 +1227,7 @@ int dummy; if len(target.install_dir) > 3 and target.install_dir[3] is True: target.install_dir[3] = os.path.join(self.environment.get_datadir(), 'gir-1.0') # Detect gresources and add --gresources arguments for each - for (_, gensrc) in other_src[1].items(): + for gensrc in other_src[1].values(): if isinstance(gensrc, modules.GResourceTarget): gres_xml, = self.get_custom_target_sources(gensrc) args += ['--gresources=' + gres_xml] @@ -2751,7 +2751,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) return super().get_introspection_data(target_id, target) result = [] - for _, i in self.introspection_data[target_id].items(): + for i in self.introspection_data[target_id].values(): result += [i] return result diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index dcf889ca3..3950a2eb5 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -306,7 +306,7 @@ class Vs2010Backend(backends.Backend): target = self.build.targets[prj[0]] lang = 'default' if hasattr(target, 'compilers') and target.compilers: - for (lang_out, _) in target.compilers.items(): + for lang_out in target.compilers.keys(): lang = lang_out break prj_line = prj_templ % ( @@ -380,7 +380,7 @@ class Vs2010Backend(backends.Backend): for p in projlist: if p[1].parent != PurePath('.'): ofile.write("\t\t{%s} = {%s}\n" % (p[2], self.subdirs[p[1].parent][0])) - for (_, subdir) in self.subdirs.items(): + for subdir in self.subdirs.values(): if subdir[1]: ofile.write("\t\t{%s} = {%s}\n" % (subdir[0], subdir[1])) ofile.write('\tEndGlobalSection\n') @@ -457,7 +457,7 @@ class Vs2010Backend(backends.Backend): def add_target_deps(self, root, target): target_dict = {target.get_id(): target} - for _, dep in self.get_target_deps(target_dict).items(): + for dep in self.get_target_deps(target_dict).values(): if dep.get_id() in self.handled_target_deps[target.get_id()]: # This dependency was already handled manually. continue diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index a23f42401..be22c7846 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -345,7 +345,7 @@ class XCodeBackend(backends.Backend): self.ofile.write('/* End PBXFileReference section */\n') def generate_pbx_frameworks_buildphase(self): - for _, t in self.build.targets.items(): + for t in self.build.targets.values(): self.ofile.write('\n/* Begin PBXFrameworksBuildPhase section */\n') self.write_line('%s /* %s */ = {\n' % (t.buildphasemap['Frameworks'], 'Frameworks')) self.indent_level += 1 @@ -587,7 +587,7 @@ class XCodeBackend(backends.Backend): def generate_pbx_sources_build_phase(self): self.ofile.write('\n/* Begin PBXSourcesBuildPhase section */\n') - for name, _ in self.source_phase.items(): + for name in self.source_phase.keys(): t = self.build.targets[name] self.write_line('%s /* Sources */ = {' % (t.buildphasemap[name])) self.indent_level += 1 diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index d125a0c02..ef58d8fe7 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2193,7 +2193,7 @@ class Interpreter(InterpreterBase): def check_cross_stdlibs(self): if self.build.environment.is_cross_build(): props = self.build.environment.properties.host - for l, _ in self.build.cross_compilers.items(): + for l in self.build.cross_compilers.keys(): try: di = mesonlib.stringlistify(props.get_stdlib(l)) if len(di) != 2: diff --git a/mesonbuild/wrap/wraptool.py b/mesonbuild/wrap/wraptool.py index 132decfde..80cc02700 100644 --- a/mesonbuild/wrap/wraptool.py +++ b/mesonbuild/wrap/wraptool.py @@ -177,7 +177,7 @@ def promote(options): # check if the argument is a full path to a subproject directory or wrap file system_native_path_argument = argument.replace('/', os.sep) - for _, matches in sprojs.items(): + for matches in sprojs.values(): if system_native_path_argument in matches: do_promotion(system_native_path_argument, spdir_name) return diff --git a/run_unittests.py b/run_unittests.py index 0cc1531db..5c9917a2a 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -5527,7 +5527,7 @@ class RewriterTests(BasePlatformTests): out = self.rewrite(self.builddir, os.path.join(self.builddir, 'info.json')) expected = {'name': 'myExe', 'sources': ['main.cpp']} self.assertEqual(len(out['target']), 2) - for _, val in out['target'].items(): + for val in out['target'].values(): self.assertDictEqual(expected, val) def test_kwargs_info(self): From 74b535fea74843c83944e9f22d40e6259ca105b8 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Mon, 29 Apr 2019 19:00:46 +0200 Subject: [PATCH 7/7] Do not pass None to mlog.exception --- mesonbuild/interpreter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index ef58d8fe7..9bb4a3c81 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2454,7 +2454,7 @@ external dependencies (including libraries) must go to "dependencies".''') with mlog.nested(): # Suppress the 'ERROR:' prefix because this exception is not # fatal and VS CI treat any logs with "ERROR:" as fatal. - mlog.exception(e, prefix=None) + mlog.exception(e, prefix=mlog.yellow('Exception:')) mlog.log('\nSubproject', mlog.bold(dirname), 'is buildable:', mlog.red('NO'), '(disabling)') return self.disabled_subproject(dirname) raise e