From 20d76b835372c0caf9cc3aac14b4984cac42f67a Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 7 Sep 2022 12:12:41 -0700 Subject: pylint: enable unnecessary-comprehension --- .pylintrc | 1 - mesonbuild/ast/interpreter.py | 4 ++-- mesonbuild/ast/printer.py | 3 +-- mesonbuild/cmake/interpreter.py | 2 +- mesonbuild/modules/pkgconfig.py | 3 +-- mesonbuild/modules/rust.py | 4 +--- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.pylintrc b/.pylintrc index acf78c3..4969aab 100644 --- a/.pylintrc +++ b/.pylintrc @@ -70,7 +70,6 @@ disable= typevar-name-incorrect-variance, undefined-loop-variable, unidiomatic-typecheck, - unnecessary-comprehension, unnecessary-dict-index-lookup, unnecessary-lambda, unnecessary-lambda-assignment, diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index c510eee..7484e04 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -365,10 +365,10 @@ class AstInterpreter(InterpreterBase): result = not result elif isinstance(node, ArrayNode): - result = [x for x in node.args.arguments] + result = node.args.arguments.copy() elif isinstance(node, ArgumentNode): - result = [x for x in node.arguments] + result = node.arguments.copy() elif isinstance(node, ArithmeticNode): if node.operation != 'add': diff --git a/mesonbuild/ast/printer.py b/mesonbuild/ast/printer.py index b095f53..1e33cf0 100644 --- a/mesonbuild/ast/printer.py +++ b/mesonbuild/ast/printer.py @@ -173,9 +173,8 @@ class AstPrinter(AstVisitor): def visit_ForeachClauseNode(self, node: mparser.ForeachClauseNode) -> None: node.lineno = self.curr_line or node.lineno - varnames = [x for x in node.varnames] self.append_padded('foreach', node) - self.append_padded(', '.join(varnames), node) + self.append_padded(', '.join(node.varnames), node) self.append_padded(':', node) node.items.accept(self) self.newline() diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 72f1d20..b15b48d 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -519,7 +519,7 @@ class ConverterTarget: def _all_source_suffixes(self) -> 'ImmutableListProtocol[str]': suffixes = [] # type: T.List[str] for exts in lang_suffixes.values(): - suffixes += [x for x in exts] + suffixes.extend(exts) return suffixes @lru_cache(maxsize=None) diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 474226c..d475618 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -271,8 +271,7 @@ class DependenciesHelper: # Note that pkg-config is picky about whitespace. # 'foo > 1.2' is ok but 'foo>1.2' is not. # foo, bar' is ok, but 'foo,bar' is not. - new_vreqs = [s for s in mesonlib.stringlistify(version_reqs)] - self.version_reqs[name].update(new_vreqs) + self.version_reqs[name].update(version_reqs) def split_version_req(self, s: str) -> T.Tuple[str, T.Optional[str]]: for op in ['>=', '<=', '!=', '==', '=', '>', '<']: diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index bdbc3d0..9d7627e 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -134,8 +134,6 @@ class RustModule(ExtensionModule): del extra_args[i] break - dependencies = [d for d in kwargs['dependencies']] - # We need to cast here, as currently these don't have protocol in them, but test itself does. tkwargs = T.cast('_kwargs.FuncTest', kwargs.copy()) @@ -147,7 +145,7 @@ class RustModule(ExtensionModule): # one new_target_kwargs['rust_args'] = new_target_kwargs.get('rust_args', []) + ['--test'] new_target_kwargs['install'] = False - new_target_kwargs['dependencies'] = new_target_kwargs.get('dependencies', []) + dependencies + new_target_kwargs['dependencies'] = new_target_kwargs.get('dependencies', []) + kwargs['dependencies'] new_target = Executable( name, base_target.subdir, state.subproject, base_target.for_machine, -- cgit v1.1