So basically when I parse src = '\nimport i1\nimport i2\n\nif True:\n pass\n and dump immediately, it emits the same result as the source.
But if I parse that and insert a root-level node, it adds an extra \n in the very end.
fst = RedBaron(src)
imp1, imp2 = fst.find_all('import')
imp2.insert_after(imp1)
fst.dumps()
The above returns '\nimport i1\nimport i2\nimport i1\n\nif True:\n pass\n\n'. (Note double LF in the end)
I could only reproduce this with an if-block (if-else too), but other nested constructs (like def or with-block) are not affected by this bug.
So basically when I parse
src = '\nimport i1\nimport i2\n\nif True:\n pass\nand dump immediately, it emits the same result as the source.But if I parse that and insert a root-level node, it adds an extra
\nin the very end.The above returns
'\nimport i1\nimport i2\nimport i1\n\nif True:\n pass\n\n'. (Note double LF in the end)I could only reproduce this with an if-block (if-else too), but other nested constructs (like
deforwith-block) are not affected by this bug.