Skip to content

Check idempotence in tests#113

Merged
NathanLovato merged 4 commits intoGDQuest:mainfrom
shadr:improve-tests
Sep 30, 2025
Merged

Check idempotence in tests#113
NathanLovato merged 4 commits intoGDQuest:mainfrom
shadr:improve-tests

Conversation

@shadr
Copy link
Copy Markdown
Contributor

@shadr shadr commented Sep 29, 2025

This PR adds an idempotence check in tests.
To make tests pass with the idempotence check I made two fixes:

  1. Fix the case when extends statement was stealing docstring from the next statement

    extends Node
    
    ## docstring
    func foo():
        pass

    previously formatted as

    extends Node
    ## docstring
    
    func foo():
        pass

    and when there is no blank line around docstring attach it to the next statement instead of the extends statement:

    extends Node
    ## docstring
    func foo():
        pass

    previously formatted as

    extends Node
    ## docstring
    
    func foo():
        pass

    Now in both cases it attaches docstring to the statemet

  2. When reordering attach docstring to the class only if it does not attached to the statement
    Previously code with --reorder-code

    extends Node
    
    ## docstring
    func foo():
        pass

    got transformed into

    extends Node
    ## docstring
    
    
    func foo():
        pass

    Now it correctly attaches docstring to the function definition.

    I'm not that familiar with the reordering code, so I hope I didn't break anything. I also left the TODO intact because I have a feeling I didn't cover all the cases.

@NathanLovato NathanLovato merged commit 5196e92 into GDQuest:main Sep 30, 2025
@NathanLovato
Copy link
Copy Markdown
Contributor

Great, thank you! Just added a message for context that will tell us if it's the first formatting pass or idempotence check that failed.

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