我目前正在研究将Black作为我们的默认格式化程序,但是,我遇到了一些无法很好格式化的边缘情况,我想知道是否有办法获得我想要的结果。
Black的文档部分探讨了我的问题,我有一个水平分布的字典表达式,我希望保持这种状态,因为我希望添加行,例如:
# Black would keep this as-is because of the trailing comma
TRANSLATIONS = {
"en_us": "English (US)",
"pl_pl": "polski",
}
但在我的情况下,字典在列表理解中:
res = [
{
'id': item.id,
'name': item.name,
}
for item in items.select()
]
无论尾随逗号如何,哪个黑方崩溃,如下所示:
res = [
{"id": item.id, "name": item.name,}
for item in items.select()
]
有没有办法告诉黑方在这些情况下保持水平结构?