Yapf: dedent_closing_brackets = false not respected for square brackets.

Created on 29 Aug 2017  路  7Comments  路  Source: google/yapf

With the dedent_closing_brackets setting set to false, I would expect the following line to not be changed by YAPF

        source, destination, options = [conf.get(key) for key in
                                        ('source', 'destination', 'options')]

or, if it was, to be changed to:

        source, destination, options = [
            conf.get(key) for key in ('source', 'destination', 'options')]

but instead I get:

        source, destination, options = [
            conf.get(key) for key in ('source', 'destination', 'options')
        ]

which seems to go directly against the setting. (which does seem to work for parentheses, but the documentation claims: "Applies to all kinds of brackets, including function definitions and calls.")

Most helpful comment

I think this can be closed as there is now a separate knob to control this.

All 7 comments

If this behaviour is confirmed to be undesirable, I can try and figure out how to fix it.

The flag isn't having an effect because YAPF is requiring a split before the ending bracket. This is because it's splitting after the opening bracket. It's arguably not the correct behavior. (The knob was added by Facebook to comply with their style: 94089878.)

The documentation is misleading as it explicitly shows a dict literal being affected by this knob yet yapf insists on giving the closing brace its own line.

Is there a workaround to this?

See #525

thank you!

I think this can be closed as there is now a separate knob to control this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Harkirat155 picture Harkirat155  路  7Comments

tschijnmo picture tschijnmo  路  6Comments

stevenleeS0ht picture stevenleeS0ht  路  4Comments

samypr100 picture samypr100  路  6Comments

qv-pat picture qv-pat  路  3Comments