Skip to content
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

Formatter generates invalid code with StmtAssign, parentheses and comments #7892

Closed
konstin opened this issue Oct 10, 2023 · 0 comments · Fixed by #7873
Closed

Formatter generates invalid code with StmtAssign, parentheses and comments #7892

konstin opened this issue Oct 10, 2023 · 0 comments · Fixed by #7873
Assignees
Labels
bug Something isn't working formatter Related to the formatter

Comments

@konstin
Copy link
Member

konstin commented Oct 10, 2023

Input:

x = (
    # a
    ( # b
        1
    )
)

Output:

x = # a
(  # b
    1
)

Playground link: https://play.ruff.rs/70f3526e-34ac-46e3-a0cf-098a60537a91

@konstin konstin added bug Something isn't working formatter Related to the formatter labels Oct 10, 2023
@konstin konstin self-assigned this Oct 10, 2023
@MichaReiser MichaReiser added this to the Formatter: Beta milestone Oct 16, 2023
konstin added a commit that referenced this issue Oct 19, 2023
<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

Fixes #7448
Fixes #7892

I've removed automatic dangling comment formatting, we're doing manual
dangling comment formatting everywhere anyway (the
assert-all-comments-formatted ensures this) and dangling comments would
break the formatting there.

## Test Plan

New test file.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
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 a pull request may close this issue.

2 participants