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

Unstable formatting: Comment is moved to lower line twice #3701

Open
Zac-HD opened this issue May 24, 2023 · 1 comment
Open

Unstable formatting: Comment is moved to lower line twice #3701

Zac-HD opened this issue May 24, 2023 · 1 comment
Labels
C: unstable formatting Formatting changed on the second pass T: bug Something isn't working

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented May 24, 2023

With current latest black, 23.3.0 (compiled: yes):

import black

code = """
assert some_long_name, (  # long __________________________ comment
        'long ___________________________________ string %s' % str(variable))
"""
black.format_file_contents(code, fast=False, mode=black.FileMode())

Specifically, this stabilizes at the second run:

assert some_long_name, (  # long __________________________ comment
        'long ___________________________________ string %s' % str(variable))


assert some_long_name, (
    "long ___________________________________ string %s"
    % str(variable)  # long __________________________ comment
)


assert some_long_name, "long ___________________________________ string %s" % str(
    variable
)  # long __________________________ comment
@JelleZijlstra
Copy link
Collaborator

#3706 and #4384 reported additional cases of what looks like the same bug.

@JelleZijlstra JelleZijlstra changed the title Black produced different code on the second pass of the formatter Unstable formatting: Comment is moved to lower line twice Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: unstable formatting Formatting changed on the second pass T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants