yapf icon indicating copy to clipboard operation
yapf copied to clipboard

Dictionary comments are oddly and inconsistently indented with SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES

Open jamesderlin opened this issue 4 years ago • 2 comments

Reproducible example:

table = {
    # Description #1
    "foo": "lorem ipsum dolor est",

    # Description #2
    "bar": "lorem ipsum dolor est",

    # Description #2
    "baz": "lorem ipsum dolor est",
}

with a .style.yapf file:

[style]
SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES = True

running yapf --diff (0.31.0) outputs:

@@ -2,9 +2,9 @@
     # Description #1
     "foo": "lorem ipsum dolor est",
 
-    # Description #2
+  # Description #2
     "bar": "lorem ipsum dolor est",
 
-    # Description #2
+  # Description #2
     "baz": "lorem ipsum dolor est",
 }

The first comment was left alone, but the subsequent comments were inexplicably(?) unindented by two spaces.

jamesderlin avatar Jun 05 '21 08:06 jamesderlin

Does it happen with SPLIT_ALL_COMMA_SEPARATED_VALUES (without the TOP_LEVEL) as well?

sergiogiro avatar Aug 15 '21 11:08 sergiogiro

No, this does not happen with just SPLIT_ALL_COMMA_SEPARATED_VALUES. This seems specific to SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES.

jamesderlin avatar Aug 15 '21 19:08 jamesderlin