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

Inconsistent formatting of method call chain with comment #3998

Open
robmoss opened this issue Oct 30, 2023 · 0 comments
Open

Inconsistent formatting of method call chain with comment #3998

robmoss opened this issue Oct 30, 2023 · 0 comments
Labels
T: bug Something isn't working

Comments

@robmoss
Copy link

robmoss commented Oct 30, 2023

Describe the bug

I noticed what appears to be inconsistent formatting when comparing black's output (v23.10.1) to ruff's new formatter (v0.1.3), as I reported to ruff and can demonstrate here:

x = (
    very_long_function_name_with_many_arguments(100, 200, 300, 400, 500, 600, 700, 800, 900, 1000).f()
    # Comment
    .g()
)
y = (
    very_long_function_name_with_many_arguments(100, 200, 300, 400, 500, 600, 700, 800, 900, 1000).f()
    # Comment
    .g()
    .h()
)

To Reproduce

Black doesn't move .f() to a new line in the first assignment (x = ...) but does move .f() to a new line in the second assignment (y = ...), as shown here:

x = (
    very_long_function_name_with_many_arguments(
        100, 200, 300, 400, 500, 600, 700, 800, 900, 1000
    ).f()
    # Comment
    .g()
)
y = (
    very_long_function_name_with_many_arguments(
        100, 200, 300, 400, 500, 600, 700, 800, 900, 1000
    )
    .f()
    # Comment
    .g()
    .h()
)

Expected behavior

I did not expect that adding/removing the line .h() would affect how .f() is formatted.

Environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant