(fix) Proposing to collect empty separation lines with comments
This is not fully tested, in particular the added test fails because the :
expected_src = textwrap.dedent(
"""\
def foo():
# indented but not connected comment
cannot hold a line of spaces, but the modification automatically produces them, so the test fails with no possibility to make it pass (maybe this is a dedent peculiarity?)
To pass the test, the proposed Unparser need to not use textwrap.dedent in the INPUT/EXPECTED strings to not remove the indented spaces on the empty lines that are set when an empty line is found (whether with or without spaces).
The issue was due to collecting empty lines after the node to replace and somehow double counting them in some cases. Restoring the original test.
It would be good to look more closely, the new unparser created duplicated newlines in the insert_after test at the Replace statement, it added an extra newline and made the test fail with the newline appearing at the end of the 3 try/except blocks.