英文:
Why does VS-Code Autopep8 format 2 white lines?
问题
以下是已翻译好的内容:
print("Hello")
def world():
print("Hello")
world()
请注意,这段代码看起来已经正确,没有需要修复的问题。如果您遇到任何其他问题,请提供更多详细信息以获取帮助。
英文:
print("Hello")
def world():
print("Hello")
world()
Gets corrected to:
print("Hello")
def world():
print("Hello")
world()
I have tried to:
- Reinstall Virtual Studio Code
- Reinstall Python 3.8
- Computer Reboot
- Using other formatters like Black and yapf but got the same result
答案1
得分: 4
因为autopep8遵循PEP8,该规范建议在顶级函数周围使用2个空行。
> 用两个空行包围顶级函数和类定义。
英文:
Because autopep8 follows PEP8 which suggests 2 blank lines around top-level functions.
> Surround top-level function and class definitions with two blank lines.
答案2
得分: 4
你可以通过在你的 .vscode/settings.json
中使用以下配置来禁用它:
{
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--ignore=E302"
]
}
这里解释了所有 autopep8
的功能:https://github.com/hhatto/autopep8#features
英文:
You can disable this by using the following configuration in your .vscode/settings.json
{
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--ignore=E302"
]
}
Here are all the autopep8
features explained: https://github.com/hhatto/autopep8#features
答案3
得分: 0
你还可以在您的VS Code设置中配置python.formatting.autopep8Args
。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论