Skip to content

Fix handling of trailing target comment#9051

Merged
MichaReiser merged 1 commit intomainfrom
fix-statement-target-with-trailing-comment
Dec 8, 2023
Merged

Fix handling of trailing target comment#9051
MichaReiser merged 1 commit intomainfrom
fix-statement-target-with-trailing-comment

Conversation

@MichaReiser
Copy link
Copy Markdown
Member

Summary

This PR fixes an issue where Ruff moved a trailing target comment past the statement end

c = b[dddddd, aaaaaa] =  (
    a[
        aaaaaaa,
        bbbbbbbbbbbbbbbbbbb
    ] 
    # comment 2
) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Before

c = b[dddddd, aaaaaa] = a[
    aaaaaaa, bbbbbbbbbbbbbbbbbbb
] = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# comment 2

Now

c = b[dddddd, aaaaaa] = (
    a[aaaaaaa, bbbbbbbbbbbbbbbbbbb]
    # comment 2
) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Which matches black's formatting

Test Plan

Added test

@MichaReiser
Copy link
Copy Markdown
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@MichaReiser MichaReiser added bug Something isn't working formatter Related to the formatter labels Dec 8, 2023
@MichaReiser MichaReiser force-pushed the fix-statement-target-with-trailing-comment branch from e3eccf3 to abf64db Compare December 8, 2023 04:35
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 8, 2023

ruff-ecosystem results

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser merged commit d0d88d9 into main Dec 8, 2023
@MichaReiser MichaReiser deleted the fix-statement-target-with-trailing-comment branch December 8, 2023 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working formatter Related to the formatter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants