-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Hi!
I've been searching a bit on why this code containing a single inline-dict is expanded into multiple lines with hanging braces by black, but couldn't find anything about configuring it, if it's expected, or a bug.
# In
func({
# expand me
'a':37,
'b':42,
'c':927,
})
# Out
func(
{
# expand me
"a": 37,
"b": 42,
"c": 927,
}
)
I personally would prefer the dict to keep it's original formatting for better readability, and lose the extra indentation and Allman-style hanging bracket. Essentially we would keep the input formatting in this example.
This pattern is also much more common in the python code I regularly read, including the standard library, django and a couple of other codebases. Grepping \({$ vs \(\n\s*{$ shows usages.
However, I expect this pattern might be fairly set in stone by now and would maybe cause a lot of unnecessary diffs for existing black users. What do you think?
Either way, I think something like this would be a useful example to add to the Black code style. That way people like me who are wondering why the function call is expanded can find out that it is to be expected.
(I'm opening this issue partly to be able to google for it myself in coming years.)
Hopefully the feedback is somewhat useful!