VSCODE 上的 Flake8 未突出显示错误
Flake8 on VSCODE not highlighting errors
只需使用以下代码创建一个名为 test.py 的文件:
print(x)
运行 flake8 test.py 按预期显示错误:
test.py:1:7: F821 undefined name 'x'
但在 VSCODE 中,没有突出显示任何内容!即使在保存时,它也表现得一切正常。我该如何解决这个问题?
我的相关设置:
{
"editor.tabSize": 2,
"editor.rulers": [
88
],
"sync.gist": "c39568aa1fdffb072eb23bbdcbb26f08",
"git.autofetch": true,
"workbench.editor.enablePreview": false,
"workbench.editorAssociations": [
{
"viewType": "jupyter.notebook.ipynb",
"filenamePattern": "*.ipynb"
}
],
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"kite.showWelcomeNotificationOnStartup": false,
"python.defaultInterpreterPath": "C:\Python\Python39\python.exe",
"python.linting.flake8Enabled": true,
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"python.linting.flake8Args": [
"--ignore=E203",
"--ignore=E266",
"--ignore=E501",
"--ignore=W503",
"--max-line-length=88",
"--select = B,C,E,F,W,T4,B9",
"--max-complexity = 18"
],
"workbench.colorTheme": "Material Theme Darker",
"workbench.iconTheme": "eq-material-theme-icons-darker",
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe",
"terminal.integrated.shellArgs.windows": [
"--login"
],
"python.linting.flake8CategorySeverity.F": "Error",
"python.linting.flake8CategorySeverity.E": "Error",
"python.linting.flake8Path": "C:\Users\panda\Documents\classrosterbot\crb2\Scripts\flake8"
}
您的 --ignore
、--select
和 --max-complexity
选项格式不正确
我相信你想要这个:
"python.linting.flake8Args": [
"--extend-ignore=E203,E266,E501,W503",
"--max-line-length=88",
"--select=B,C,E,F,W,T4,B9",
"--max-complexity=18"
],
with --ignore
,最后一个将获胜 - 空格将无法正确解析
通常最好在配置文件中指定这些,而在您的编辑器设置中 而不是 ,这样其他工具和贡献者就可以受益,而不必选择您的 IDE
免责声明:我是当前的 flake8 维护者
只需使用以下代码创建一个名为 test.py 的文件:
print(x)
运行 flake8 test.py 按预期显示错误:
test.py:1:7: F821 undefined name 'x'
但在 VSCODE 中,没有突出显示任何内容!即使在保存时,它也表现得一切正常。我该如何解决这个问题?
我的相关设置:
{
"editor.tabSize": 2,
"editor.rulers": [
88
],
"sync.gist": "c39568aa1fdffb072eb23bbdcbb26f08",
"git.autofetch": true,
"workbench.editor.enablePreview": false,
"workbench.editorAssociations": [
{
"viewType": "jupyter.notebook.ipynb",
"filenamePattern": "*.ipynb"
}
],
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"kite.showWelcomeNotificationOnStartup": false,
"python.defaultInterpreterPath": "C:\Python\Python39\python.exe",
"python.linting.flake8Enabled": true,
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"python.linting.flake8Args": [
"--ignore=E203",
"--ignore=E266",
"--ignore=E501",
"--ignore=W503",
"--max-line-length=88",
"--select = B,C,E,F,W,T4,B9",
"--max-complexity = 18"
],
"workbench.colorTheme": "Material Theme Darker",
"workbench.iconTheme": "eq-material-theme-icons-darker",
"terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe",
"terminal.integrated.shellArgs.windows": [
"--login"
],
"python.linting.flake8CategorySeverity.F": "Error",
"python.linting.flake8CategorySeverity.E": "Error",
"python.linting.flake8Path": "C:\Users\panda\Documents\classrosterbot\crb2\Scripts\flake8"
}
您的 --ignore
、--select
和 --max-complexity
选项格式不正确
我相信你想要这个:
"python.linting.flake8Args": [
"--extend-ignore=E203,E266,E501,W503",
"--max-line-length=88",
"--select=B,C,E,F,W,T4,B9",
"--max-complexity=18"
],
with --ignore
,最后一个将获胜 - 空格将无法正确解析
通常最好在配置文件中指定这些,而在您的编辑器设置中 而不是 ,这样其他工具和贡献者就可以受益,而不必选择您的 IDE
免责声明:我是当前的 flake8 维护者