Commit 6ec5b62b authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

trace_division: more support for multiline divisions

parent e6472154
......@@ -38,6 +38,9 @@ class FixTraceDivision(lib2to3.fixer_base.BaseFix):
def transform(self, node, results):
lineno = node.get_lineno()
divisor = node.children[0].clone()
if node.prefix == divisor.prefix:
divisor.prefix = ''
comma = lib2to3.fixer_util.Comma()
comma.prefix = prefix=node.children[1].prefix
......@@ -47,7 +50,7 @@ class FixTraceDivision(lib2to3.fixer_base.BaseFix):
args=(
lib2to3.fixer_util.Number(self.ids[lineno]),
lib2to3.fixer_util.Comma(),
node.children[0].clone(),
divisor,
comma,
node.children[2].clone(),
),
......
......@@ -34,6 +34,13 @@ class testFixTraceDivision(FixerTestCase):
, y)"""
self.check(b, a)
def test_multiline_division_2(self):
b = """foo = \
x / y"""
a = """foo = \
division_traced(0,x , y)"""
self.check(b, a)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment