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

Lambdas are reformatted into (potentially) very long lines #1290

Open
jjmaestro opened this issue Aug 31, 2024 · 0 comments
Open

Lambdas are reformatted into (potentially) very long lines #1290

jjmaestro opened this issue Aug 31, 2024 · 0 comments

Comments

@jjmaestro
Copy link

As I mentioned in #890, I have the following code:

def foo(foobar):
    return struct(
        bar = 123,
        some_very_long_line = lambda arg1, arg2, arg3:
            _some_other_method(foobar, arg1, arg2, arg3),
)

I was expecting buildifier to respect my line returns there but instead, it reformats the lambda in one very long line:

def foo(foobar):
    return struct(
        bar = 123,
        some_very_long_line = lambda arg1, arg2, arg3: _some_other_method(foobar, arg1, arg2, arg3),
)

The next-best-match is the following:

def foo(foobar):
    return struct(
        bar = 123,
        some_very_long_line = lambda arg1, arg2, arg3: _some_other_method(
            foobar, arg1, arg2, arg3
        ),
)

which gets reformatted to:

def foo(foobar):
    return struct(
        bar = 123,
        some_very_long_line = lambda arg1, arg2, arg3: _some_other_method(
            foobar,
            arg1,
            arg2,
            arg3,
        ),
)

This is OK-ish and it does make sense but it can also turn into a very long line "over 80+ chars".

Is there a way to get buildifier to respect a line return like I did and/or to break after the ':' in lambdas that would end up being a very long line?

Thanks!

@jjmaestro jjmaestro changed the title Lambdas are reformatted to (potentially) very long lines Lambdas are reformatted into (potentially) very long lines Aug 31, 2024
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

No branches or pull requests

1 participant