Skip to content

(fix) Proposing to collect empty separation lines with comments #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MementoRC
Copy link
Contributor

@MementoRC MementoRC commented Dec 5, 2022

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?)

@MementoRC MementoRC closed this Dec 6, 2022
@MementoRC MementoRC reopened this Dec 6, 2022
@MementoRC
Copy link
Contributor Author

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).

@MementoRC
Copy link
Contributor Author

MementoRC commented Dec 10, 2022

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.

Copy link
Owner

@isidentical isidentical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the test failures, if textwrap.dedent is doing something it shouldn't do (e.g. if the result is more precise without it, I think it makes a lot of sense to remove it and maybe use something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants