microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.29k stars 1.18k forks source link

Linting: show problems in problems window across all files in a workspace #19870

Closed brianjmurrell closed 1 year ago

brianjmurrell commented 2 years ago

Type: Bug

I have the flake8 python linter enabled but I am not seeing any of the problems that I see if I run flake8 on the CLI.

My python.linting.* settings are:

    "python.linting.pylintArgs": ["--rcfile=utils/cq/pylintrc"],
    "python.linting.pylintEnabled": true,
    "python.linting.flake8Path": "/usr/bin/flake8",
    "python.linting.flake8Enabled": true

Extension version: 2022.14.0 VS Code version: Code 1.71.2 (74b1f979648cc44d385a2286793c226e611f59e7, 2022-09-14T21:12:14.256Z) OS version: Linux x64 5.18.16-200.fc36.x86_64 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz (12 x 2859)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|1, 2, 2| |Memory (System)|62.58GB (7.81GB free)| |Process Argv|--unity-launch --crash-reporter-id d33a766b-28e9-45e5-942d-3a9085ddc0c0| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|gnome| |XDG_CURRENT_DESKTOP|GNOME| |XDG_SESSION_DESKTOP|gnome| |XDG_SESSION_TYPE|x11|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30557514 vsaa593:30376534 pythonvs932:30410667 cppdebug:30492333 vsclangdf:30486550 c4g48928:30535728 hb751961:30553087 dsvsc012:30540252 azure-dev_surveyone:30548225 2144e591:30553903 fc301958:30573243 ```
brettcannon commented 2 years ago

Can you try running flake8 with the command we show in the Output channel to see if that happens to be why things are not showing anything?

brianjmurrell commented 2 years ago

Assuming you mean the OUTPUT window for Python, there is no flake8 command showing as being run there. All that I have is:

Experiment 'pythonSurveyNotificationcf' is active
LSP Notebooks experiment is enabled
LSP Notebooks interactive window support is enabled
Python interpreter path: /usr/bin/python3
Starting Pylance language server.
karthiknadig commented 2 years ago

Can you try this extension: https://marketplace.visualstudio.com/items?itemName=ms-python.flake8 ? For pylint try this one: https://marketplace.visualstudio.com/items?itemName=ms-python.pylint, you may have to add the setting "pylint.args": ["--rcfile", "utils/cq/pylintrc"]. And disable pylint and flake8 linters from python extension. Those extensions will eventually replace the experience you see in python. And you get better error reporting, logging, and control over the experience.

brianjmurrell commented 2 years ago

I notice that this pre-release says:

Fedora 36 only has 4.0.1.

brianjmurrell commented 2 years ago

But also seeing zero new content in the OUTPUT window for Python.

brianjmurrell commented 2 years ago

Ahhh. Hrm. I am seeing flake8 issues in the PROBLEMS tab, but only on a file I open. How do I get it to show me all problems in all files like other liters do?

karthiknadig commented 2 years ago

How do I get it to show me all problems in all files like other liters do?

That is not supported. You can make that a feature request, the way it works in VS Code is we only show issues relevant to the files that are open in the editor. If you want full list of issues, you have to run the linter manually.

karthiknadig commented 2 years ago

Here is the relevant feature request for pylint: https://github.com/microsoft/vscode-pylint/issues/79

brianjmurrell commented 2 years ago

But that's not how most other linters seem to work, is it? I see all sorts of problems for files I don't have open from other linters. Am I misunderstanding what I am seeing?

karthiknadig commented 2 years ago

We run linter on file save, if we ran linter on the entire project everytime a user saves, it gets really expensive and slow. So, if you need project wide linting I recommend creating a task in "tasks.json".

In the extensions, we focus more on what you are working on (as in the open files you have). The problems in a particular open file are shown in the problems window, you can go to each one address them as needed. When you are done, you run your linting suite by setting up a task using the tasks.json. That will give you a list of errors across all the files in you project, the output will be in the terminal. you then open the next file that you want to work on to address issues.

brianjmurrell commented 2 years ago

I guess I would argue that what I am working on could be more than just the files I have open. I might have a hundred files in the various commits in my branch but I'm not keeping 100 file tabs open.

I like seeing all of the problems in my PROBLEMS tabs because that is where I can view the problem and [re-]open the file with the problem to fix it. Having to pick files from the TERMINAL tab after I manually run the linter really defeats a lot of the point of having the linter and output neatly in VS CODE. IMHO.

karthiknadig commented 2 years ago

Switching this to a feature request. We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

karthiknadig commented 2 years ago

Related: https://github.com/microsoft/vscode/issues/155673

Some linter report issues with project itself. So, we might need https://github.com/microsoft/vscode/issues/155673 support from VS Code as well.

brettcannon commented 2 years ago

I guess I would argue that what I am working on could be more than just the files I have open. I might have a hundred files in the various commits in my branch but I'm not keeping 100 file tabs open.

I like seeing all of the problems in my PROBLEMS tabs because that is where I can view the problem and [re-]open the file with the problem to fix it. Having to pick files from the TERMINAL tab after I manually run the linter really defeats a lot of the point of having the linter and output neatly in VS CODE. IMHO.

Think about it this way: after every save to a file or character you type, do you go to your terminal and run flake8 across all of your files, or just at good points to stop and check the results? I suspect it's the latter, which means you don't have to worry about how long it takes. But most of our users want a fast experience, so linting all files regardless of whether they are open is an expensive, slow thing for us to do that would upset most folks.

Plus, to an editor, what is in the scope of your work is what you have open. Now as you said, some folks like seeing every linting problem regardless of whether it applies to their open files. But we have found the vast majority of our users only care about the files they have open (and also want everything fast). Thus if you want to see all of your lint results show up we advise you create a task that you can run however frequently you want and still get the result you're after.

brianjmurrell commented 2 years ago

I guess, ultimately, if I have to go to the TERMINAL tab to run flake8 to see the results of all of the files in my repo/changeset, I just really don't see the point to a plugin in VS Code that only shows me some subset and gives me a false sense of security about the state of the files in my PR.

brettcannon commented 1 year ago

Thank you for submitting your feature request and everyone who considered it! Unfortunately, this issue did not receive enough votes over the allotted time, and so we are closing the issue.