microsoft / vscode-flake8

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

Add quickfix for adding "ignore warning" to project configuration #136

Open dciborow opened 1 year ago

dciborow commented 1 year ago

Issue description

Currently, when a flake8 error is reported, users have to manually update their configuration files (.flake8 or pyproject.toml) to suppress the error. This can be a time-consuming and error-prone process, especially for users who are not familiar with the flake8 configuration.

To improve the user experience, a quickfix should be provided for all flake8 problems that updates the configuration file with the necessary settings to suppress the error. For example, if the error message 'F401 | module imported but unused' is reported, the quickfix should offer to add the following configuration to the file:

[flake8]
extend-ignore = E203,F401

If the proposal in issue #135 is accepted, which adds flake8 configuration support for pyproject.toml, the updated configuration would look like this:

[tools.flake8]
extend-ignore = [  "E203",  "F401"]

If a user does not have a configuration file, we should create a new section in the pyproject.toml for them. Alternatively, we could create the new .flake8 file for the user.

An alternative solution would be to include these configurations in the vscode/settings.json file, which is already used to store configurations. However, the 'pylance' module already uses the pyproject.toml directly, so adding these configurations to vscode/settings.json may not be the best solution.

Providing a quickfix for flake8 errors would greatly improve the user experience and reduce the time and effort required to configure flake8.