1

I have a python project with flake8 and mypy activated using settings.json

"python.linting.mypyEnabled": true,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,

However I am not able to see quick fix

enter image description here

Selva
  • 951
  • 7
  • 23
  • Flake8 and MyPy don't provide quick fixes. From what I understand, only Pylance does. Do you have it enabled? Check out this question: [Visual Studio Code quick-fix & python](/q/55582277/4518341), though a bunch of info is outdated. – wjandrea Sep 07 '22 at 17:27
  • Try installing the [python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) (not just pylance). Quick fixes work out of the box with that extension, so provided you don't have some other conflicting configuration, it should just work. If you still have trouble, try renaming your config file and restarting code to use default settings. – thisisrandy Sep 09 '22 at 02:08
  • @thisisrandy Pylance depends on Python extension. – MingJie-MSFT Sep 09 '22 at 03:17
  • @MingJie-MSFT I think you have that backwards. Regardless, the recommended way to use the Microsoft python extensions is to install the python extension, so we should be directing OP to do so in the absence of any specific reason not to. – thisisrandy Sep 09 '22 at 03:27

1 Answers1

1

Thank @wjandrea for his comments and corrections. This function is provided by Pylance. You can install the Pylance extension and use pylint.

This does not affect the use of flake8 or mypy.

Adding the following codes to your settings.json:

"python.linting.pylintEnabled": true,

enter image description here

enter image description here

You can choose the selected package or all unused packages.

MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13
  • I tried this, but I'm not seeing any Quick Fixes available. Are you sure they're not provided by something else, like Pylance? – wjandrea Sep 08 '22 at 17:50
  • @wjandrea Have you installed `pylint`? Use command `pip install pylint`. Pylance is just the integration of Python and jupyter notebook extensions. I adjusted the answer. The second line of setting is unnecessary. Thank you for your correction – MingJie-MSFT Sep 09 '22 at 01:28
  • Yes I've installed Pylint. I get the warning from it, `Unused import pytest pylint(unused-import)`. On the other hand, [Pylance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) is actually a language server, not an integration, and from what I can tell from the answers on [this question](/q/55582277/4518341), it's the only extension that can provide Quick Fixes. I'm surprised you weren't aware of that, working for Microsoft, since Pylance is such a useful tool. I'm using Codium, so I'm stuck with Jedi, which is fine, just less feature-full. – wjandrea Sep 09 '22 at 01:50
  • 1
    @wjandrea Yes, you are right. I have a one-sided understanding of the pylance extension. – MingJie-MSFT Sep 09 '22 at 01:57