为了方便对相关语法调试与满足pep8格式风格,在VScode设置相关配置。
flake8:辅助检测 Python 代码是否规范的工具
Pep8:静态检查 PEP8 编码风格的工具。
{
"workbench.editorAssociations": {
"*.ipynb": "jupyter.notebook.ipynb"
},
},
"jupyter.jupyterServerType": "local",
"git.ignoreLegacyWarning": true,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"editor.formatOnSave": true,
"python.linting.pylintEnabled": false,
"python.formatting.provider": "yapf",
"python.formatting.yapfArgs": [
"--style={column_limit=128}"
],
"python.linting.flake8Enabled": true,
python.linting.flake8Args": ["--max-line-length=248","--ignore=W191, E266, W504"],
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
}
}
注意这里的-max-line-length长度要大于column_limit,以适应屏幕宽度。使用alt+shift+F可快速进行格式转换。
注意如果装了 pylint 的话,设置“python.linting.pylintEnabled: false”,否则不用