[英]Formatting python with Black in VSCode is causing arrays to expand vertically, any way to compress them?
我在 VSCode 中使用 Black 格式化 python,它使我所有的 arrays 超高而不是超寬。 我已經將 pep8 和 flake8 以及 black 的最大行長度設置為 150(但我是 Black 的新手,不確定它是否使用這些設置中的任何一個):
"python.formatting.blackArgs": ["--line-length", "150"],
這是它的樣子:
expected = make_dict_of_rows(
[
10,
11,
15,
24,
26,
30,
32,
35,
36,
37,
50,
53,
54,
74,
76,
81,
114,
115,
118,
119,
120,
123,
],
)
是我得到的,而不是更簡潔的:
expected = make_dict_of_rows(
[
10, 11, 15, 24, 26, 30, 32, 35, 36, 37, 50, 53, 54, 74, 76, 81, 114, 115, 118, 119, 120, 123,
],
)
(或者更可取的是,這會有一些折疊的括號):
expected = make_dict_of_rows([
10, 11, 15, 24, 26, 30, 32, 35, 36, 37, 50, 53, 54, 74, 76, 81, 114, 115, 118, 119, 120, 123
])
如果 Black 有尾隨逗號,它總是會將列表分解為多行。 您可以刪除黑色的尾隨逗號以壓縮列表。 您還可以使用--skip-magic-trailing-comma
:
"python.formatting.blackArgs": ["--line-length", "150", "--skip-magic-trailing-comma"],
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.