Skip to content

Line too long: Lambda with many parameters #809

@mikelane

Description

@mikelane

Operating system: macos 10.14.4
Python version: 3.6.7
Black version: 19.3b0
Does also happen on master: Yes

We have an interesting way to create pytest fixtures. We've created a function called lambda_fixture() that lets us skip most of the boilerplate issues when creating fixtures. It looks something like this:

my_user = lambda_fixture(lambda user_factory: user_factory(name='Mike'))

That's all well and good, but sometimes these things can have a pretty long list of parameters. Unfortunately, black doesn't handle this very well:

my_long_variable_name = lambda_fixture(
    lambda fixture_1, another_long_fixture_name, some_fixture_factory, some_long_fixture_name_again, short, wow, long_fixture_name: some_fixture_factory.create_batch(
        size=10,
        something=short,
        something_else=long_fixture_name,
    )
)

It would be nice to have black wrap and/or chop down the lambda parameter list. Bonus points if the indent of the wrap/chop is different than the indent of the body of the lambda.

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: linetoolongBlack makes our lines too longT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions