Skip to content

Don't use subscription brackets to break long lines? #951

@yurkobb

Description

@yurkobb

Consider this input:

class Test:
    def method(self):
        ctx = super().get_context_data(**kwargs)
        ctx["shipping_methods"] = list(
            ShippingMethod.objects.all().values("id", "labels__identifier")
        )
        ctx["shipping_method_fields"] = (
            MyCheckoutForm.Meta.shipping_required_fields
        )
        return ctx

And output:

class Test:
    def method(self):
        ctx = super().get_context_data(**kwargs)
        ctx["shipping_methods"] = list(
            ShippingMethod.objects.all().values("id", "labels__identifier")
        )
        ctx[
            "shipping_method_fields"
        ] = MyCheckoutForm.Meta.shipping_required_fields
        return ctx

I would (subjectively) expect the third assignment to stay the way it was.

Do "a[...]" often contain more than 1 element between the brackets? (Ignore this argument please; of course they do if it's something other than a string literal)


Operating system:
Python version: 3.7.3
Black version: 19.3b0
Does also happen on master: yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: linebreakHow should we split up lines?T: 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