为什么 VS-Code Autopep8 会格式化 2 条白线?
Why does VS-Code Autopep8 format 2 white lines?
print("Hello")
def world():
print("Hello")
world()
更正为:
print("Hello")
def world():
print("Hello")
world()
我尝试过:
- 重新安装虚拟工作室代码
- 重新安装 Python 3.8
- 计算机重启
- 使用其他格式化程序,如 Black 和 yapf,但得到相同的结果
因为 autopep8 跟在 PEP8 之后,这表明顶级函数周围有 2 个空行。
Surround top-level function and class definitions with two blank lines.
您可以通过在 .vscode/settings.json
中使用以下配置来禁用此功能
{
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--ignore=E302"
]
}
以下是所有 autopep8
功能的解释:https://github.com/hhatto/autopep8#features
print("Hello")
def world():
print("Hello")
world()
更正为:
print("Hello")
def world():
print("Hello")
world()
我尝试过:
- 重新安装虚拟工作室代码
- 重新安装 Python 3.8
- 计算机重启
- 使用其他格式化程序,如 Black 和 yapf,但得到相同的结果
因为 autopep8 跟在 PEP8 之后,这表明顶级函数周围有 2 个空行。
Surround top-level function and class definitions with two blank lines.
您可以通过在 .vscode/settings.json
{
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--ignore=E302"
]
}
以下是所有 autopep8
功能的解释:https://github.com/hhatto/autopep8#features