yapf
yapf copied to clipboard
DEDENT_CLOSING_BRACKETS doesn't always dedent
I've DEDENT_CLOSING_BRACKETS = true, and it most of the times, but not sometimes.
Here's a change that yapf applies:
@@ -942,13 +934,12 @@ class Order(BaseOrder):
paths[link_name] = target
for image in p.product.images.all():
- link_name = (
- '{product}/P-{order}/originals/{filename}'
- ).format(
- product=p.product_name,
- order=self.pk,
- filename=image.photo.original_filename,
- )
+ link_name = ('{product}/P-{order}/originals/{filename}'
+ ).format(
+ product=p.product_name,
+ order=self.pk,
+ filename=image.photo.original_filename,
+ )
target = image.photo.image
paths[link_name] = target
I think that becuase ).format doesn't fit in this line, it moves it into the next (although the arguments and the closing bracket by themselves do fit), but doesn't respect dedenting.
I also tried setting SPLIT_BEFORE_DOT, but it renders the same result -- even though the closing bracket should be placed in the first line in this case.
Also for assigning returned multiple results of a function call:
a, b = func(arg1,
arg2,
arg3)
is expected to format to this:
a, b = func(
arg1,
arg2,
arg3
)
but it does not
Another sample, and fiddling notes:
Result one:
cast_to_bool = SwitchAttr(('bool', 'b'),
list=True,
argname='YAMLPATH',
help="Cast any nodes matching the given YAML Path query as booleans")
This is achieved with the following config:
coalesce_brackets = true
dedent_closing_brackets = true
column_limit = 99
If we remove either or both of column_limit and coalesce_brackets, we get result two:
cast_to_bool = SwitchAttr(
('bool', 'b'),
list=True,
argname='YAMLPATH',
help="Cast any nodes matching the given YAML Path query as booleans"
)