使用 VSCode 对 Python 进行实时 linting [英] Real-time linting of Python with VSCode
问题描述
最近我使用 VSCode 作为我的 Python IDE,并且我安装了DonJayamanne/pythonVSCode,支持 linting.但是,linter 仅在保存时有效,但我想要的是实时 linting.作者建议的解决方法是设置files.autoSave
到 on
,这样只要文件自动保存,linter 就会工作.有 Github 上的相关讨论,供您参考.
Recently I'm using VSCode as my Python IDE, and I install
DonJayamanne/pythonVSCode, which supports linting. However, the linter only works when saving, but what I want is real-time linting. The workaround suggested by the author is to set files.autoSave
to on
, so that the linter will work whenever the file is automatically saved. There's a relevant discussion on Github, for your reference.
既然我不想打开自动保存功能,有什么办法可以用 VSCode 对 Python 进行实时 linting?或者有没有推荐的扩展名?
Since I don't want to turn on auto-save function, is there any way to do real-time linting of Python with VSCode? Or is there any suggested extension?
推荐答案
如果你使用 shift + cmd + P(或者 ^+ctrl+P for windows)或者转到 View >命令面板并输入Lint"
If you use shift + cmd + P (or ^+ctrl+P for windows) or go to View > Command Palette and type "Lint"
命令面板允许您执行不同的命令,从这里您可以启用/禁用 Linting 并选择您想要使用的 Linter.最受欢迎的是 PyLint,但您可以选择 Flake8 或 Pep8 或任何您喜欢的.
The Command Palette allows you to execute different commands, from here you can enable/disable Linting and select which Linter you would like to use. Most popular is PyLint but you can select Flake8 or Pep8 or whatever you like.
我相信你需要在 linter 实时工作之前做这些事情.
I believe you need to do these things before the linter works in real-time.
要在不保存的情况下扫描代码问题,请使用 shift + cmd + M,您将在 vscode 终端中收到错误代码.
To scan for problems with your code without saving first, use shift + cmd + M, you will receive an error code in the vscode Terminal.
这篇关于使用 VSCode 对 Python 进行实时 linting的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!