Fixed flake8

pull/4929/head
Daniel Mensinger 6 years ago
parent 631dbc4b24
commit 4b7b5a7185
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 2
      mesonbuild/mparser.py
  2. 16
      mesonbuild/rewriter.py
  3. 2
      test cases/rewrite/2 subdirs/rmTgt.json

@ -524,7 +524,7 @@ class Parser:
value = self.e1()
if not isinstance(left, IdNode):
raise ParseException('Plusassignment target must be an id.', self.getline(), left.lineno, left.colno)
return PlusAssignmentNode(left.subdir,left.lineno, left.colno, left.value, value)
return PlusAssignmentNode(left.subdir, left.lineno, left.colno, left.value, value)
elif self.accept('assign'):
value = self.e1()
if not isinstance(left, IdNode):

@ -28,7 +28,7 @@ from mesonbuild.mesonlib import MesonException
from . import mlog, mparser, environment
from functools import wraps
from pprint import pprint
from .mparser import Token, ArrayNode, ArgumentNode, AssignmentNode, BaseNode, IdNode, FunctionNode, StringNode
from .mparser import Token, ArrayNode, ArgumentNode, AssignmentNode, IdNode, FunctionNode, StringNode
import json, os
class RewriterException(MesonException):
@ -590,7 +590,7 @@ class Rewriter:
src_list = []
for i in target['sources']:
for j in arg_list_from_node(i):
if isinstance(j, mparser.StringNode):
if isinstance(j, StringNode):
src_list += [j.value]
test_data = {
'name': target['name'],
@ -609,8 +609,8 @@ class Rewriter:
def apply_changes(self):
assert(all(hasattr(x, 'lineno') and hasattr(x, 'colno') and hasattr(x, 'subdir') for x in self.modefied_nodes))
assert(all(hasattr(x, 'lineno') and hasattr(x, 'colno') and hasattr(x, 'subdir') for x in self.to_remove_nodes))
assert(all(isinstance(x, (mparser.ArrayNode, mparser.FunctionNode)) for x in self.modefied_nodes))
assert(all(isinstance(x, (mparser.ArrayNode, mparser.AssignmentNode, mparser.FunctionNode)) for x in self.to_remove_nodes))
assert(all(isinstance(x, (ArrayNode, FunctionNode)) for x in self.modefied_nodes))
assert(all(isinstance(x, (ArrayNode, AssignmentNode, FunctionNode)) for x in self.to_remove_nodes))
# Sort based on line and column in reversed order
work_nodes = [{'node': x, 'action': 'modify'} for x in self.modefied_nodes]
work_nodes += [{'node': x, 'action': 'rm'} for x in self.to_remove_nodes]
@ -671,7 +671,7 @@ class Rewriter:
col = node.colno
start = offsets[line] + col
end = start
if isinstance(node, mparser.ArrayNode):
if isinstance(node, ArrayNode):
if raw[end] != '[':
mlog.warning('Internal error: expected "[" at {}:{} but got "{}"'.format(line, col, raw[end]))
return
@ -684,7 +684,7 @@ class Rewriter:
counter -= 1
end += 1
elif isinstance(node, mparser.FunctionNode):
elif isinstance(node, FunctionNode):
while raw[end] != '(':
end += 1
end += 1
@ -698,8 +698,8 @@ class Rewriter:
end += 1
# Only removal is supported for assignments
elif isinstance(node, mparser.AssignmentNode) and i['action'] == 'rm':
if isinstance(node.value, (mparser.ArrayNode, mparser.FunctionNode)):
elif isinstance(node, AssignmentNode) and i['action'] == 'rm':
if isinstance(node.value, (ArrayNode, FunctionNode)):
remove_node({'file': i['file'], 'str': '', 'node': node.value, 'action': 'rm'})
raw = files[i['file']]['raw']
while raw[end] != '=':

@ -4,4 +4,4 @@
"target": "something",
"operation": "tgt_rm"
}
]
]

Loading…
Cancel
Save