microsoft / vscode-flake8

Linting support for python using the flake8 library.
https://marketplace.visualstudio.com/items?itemName=ms-python.flake8
MIT License
40 stars 30 forks source link

flake8.lintOnChange option not available #292

Closed whitesnakeftw closed 6 months ago

whitesnakeftw commented 6 months ago

I'm using v2023.11.13551006 (pre-release). The flake8.lintOnChange option appears on the extension DETAILS tab, but it doesn't show in the FEATURE CONTRIBUTIONS tab or in @ext:ms-python.flake8. If I manually edit settings.json to add "flake8.lintOnChange": true, it shows greyed out as well.

khurd21 commented 6 months ago

Hi,

I noticed this as well on: v2023.10.0

karthiknadig commented 6 months ago

This is a mistake when writing the read me for this extension. We don't plan on adding lint on change. We tested this feature on pylint and seems like there is significant performance degradation to support this feature. We are reverting that feature on pylint as well.

The lint on change actually runs at your typing rate (i.e., every character you type) and flake8 is not performant enough to run per character. This can cause issues with the editor response time and user experience.

Alternatives:

  1. you can use auto-save and that will trigger linting at the auto save rate which is by default 1 second. In most cases the 1 second gap is enough for flake8 to run and respond.
  2. Ruff extension has support for this. ruff is significantly more performant and is able run fast enough that even if it runs on each character you type, it seems to be able to maintain a consistent user experience. ruff implements flake8 and pylint rules, and also supports several flake8 plugins.