From 4d7031437c7a81b52c776d4ae1e32741bdb851ca Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 31 Aug 2021 09:55:01 -0700 Subject: pylint: turn on superflous-parens We have a lot of these. Some of them are harmless, if unidiomatic, such as `if (condition)`, others are potentially dangerous `assert(...)`, as `assert(condtion)` works as expected, but `assert(condition, message)` will result in an assertion that never triggers, as what you're actually asserting is `bool(tuple[2])`, which will always be true. --- mesonbuild/ast/interpreter.py | 12 ++++++------ mesonbuild/ast/introspection.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'mesonbuild/ast') diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index 0299014..8c2be37 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -182,7 +182,7 @@ class AstInterpreter(InterpreterBase): return with open(absname, encoding='utf-8') as f: code = f.read() - assert(isinstance(code, str)) + assert isinstance(code, str) try: codeblock = mparser.Parser(code, absname).parse() except mesonlib.MesonException as me: @@ -199,7 +199,7 @@ class AstInterpreter(InterpreterBase): return True def evaluate_fstring(self, node: mparser.FormatStringNode) -> str: - assert(isinstance(node, mparser.FormatStringNode)) + assert isinstance(node, mparser.FormatStringNode) return node.value def evaluate_arithmeticstatement(self, cur: ArithmeticNode) -> int: @@ -212,7 +212,7 @@ class AstInterpreter(InterpreterBase): return 0 def evaluate_ternary(self, node: TernaryNode) -> None: - assert(isinstance(node, TernaryNode)) + assert isinstance(node, TernaryNode) self.evaluate_statement(node.condition) self.evaluate_statement(node.trueblock) self.evaluate_statement(node.falseblock) @@ -223,7 +223,7 @@ class AstInterpreter(InterpreterBase): return node.value return '__AST_UNKNOWN__' arguments, kwargs = self.reduce_arguments(node.args, key_resolver=resolve_key) - assert (not arguments) + assert not arguments self.argument_depth += 1 for key, value in kwargs.items(): if isinstance(key, BaseNode): @@ -232,7 +232,7 @@ class AstInterpreter(InterpreterBase): return {} def evaluate_plusassign(self, node: PlusAssignmentNode) -> None: - assert(isinstance(node, PlusAssignmentNode)) + assert isinstance(node, PlusAssignmentNode) # Cheat by doing a reassignment self.assignments[node.var_name] = node.value # Save a reference to the value node if node.value.ast_id: @@ -298,7 +298,7 @@ class AstInterpreter(InterpreterBase): return 0 def assignment(self, node: AssignmentNode) -> None: - assert(isinstance(node, AssignmentNode)) + assert isinstance(node, AssignmentNode) self.assignments[node.var_name] = node.value # Save a reference to the value node if node.value.ast_id: self.reverse_assignment[node.value.ast_id] = node diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index 42813db..9bd73d7 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -211,7 +211,7 @@ class IntrospectionInterpreter(AstInterpreter): while inqueue: curr = inqueue.pop(0) arg_node = None - assert(isinstance(curr, BaseNode)) + assert isinstance(curr, BaseNode) if isinstance(curr, FunctionNode): arg_node = curr.args elif isinstance(curr, ArrayNode): -- cgit v1.1