-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show errors for whole workspace, not just open files #145
Comments
Given the speed of ruff, this sounds awesome! |
I have to look into how this works with Pylance, I'm totally unfamiliar with how it does that 😅 |
(But no such setting exists right now AFAIK, to answer the original question.) |
Ah yeah, maybe it's Microsoft granting special privileges to Pylance. I know that the Mypy extension by Matan Grover does a similar thing, so should be possible! Being able to quickly see all the problems and use the "Go to next" shortcut in VSCode makes migrating an old codebase to ruff, or enabling new rules, much easier. |
Also looking for this feature! 😄 |
yeah this would be a great feature! |
upvote |
If anyone is willing to make a contribution or do research on how other tools do this, I'm happy to collaborate. Otherwise, please use the 👍 reaction on the first post instead of bumping the thread. |
I have digged into how mypy extension does this. Mypy has a "daemon mode". Mypy daemon outputs all of its data to stdout, as it does not have LSP capabilities. It is more like invoking Basically, mypy extension launches mypy in daemon mode, passing the entire project directory as argument. Then, as new data arrives to stdout, it continuously parses it and updates problems list. This has its own downsides: you only get problem updates after you save a file, not while typing. I have not yet got into how LSP works and ruff/ruff-vscode codebase, though. Anyway, @zanieb, I would be happy to collaborate on this. |
I haven't researched this deeply, but based on the above, I think my main questions would be (and these are largely focused on implementation):
I do want to mention that I think there's a decent change we rewrite the LSP some time in the next few months. We want to integrate it into Ruff more deeply -- as written, it's basically a wrapper around the Ruff executable CLI. I don't know when that will happen (perhaps not for a long time), we don't have a concrete plan around it, it's just something that has come up a few times. So while I'm happy to support this, if anyone works on it, I don't want them to be caught off guard if that happens (which would probably make some but not all of this work redundant, since we'd be completely redesigning the LSP). |
@charliermarsh for the first point, here's the function in mypy plugin repository which shows how to set diagnostics for any file in a workspace: https://github.com/matangover/mypy-vscode/blob/master/src/extension.ts#L440C2-L440C2 For the second point, there are For the third: there is For the fourth: yes, I agree, this could be a good starting point. There are already examples of how we can populate diagnostics list for different files in mypy repository, so this shouldn't be difficult. There should also be a possibility to use VS Code's own file watcher instead of Doing push approach would move most of the work on this feature to As for LSP rewrite — I will do some research on what LSP provides as an interface and how ruff implements it. I will research LSP specification and be back :) |
Update: I also noticed that rust-analyzer extension shows errors for non-open files. |
vscode-mypy has recently implemented it: microsoft/vscode-mypy#81 (comment) |
Thanks @MartinBernstorff, that's really helpful since we use the same template as that extension so there's some common code. I think we could mostly follow the patterns implemented in there although it may actually be easier for us since Mypy returns diagnostics by following imports (so they have to filter out irrelevant diagnostics if the scope isn't set to So, something like:
I'd be happy to review PRs in this direction. |
Actually, there's at least one issue with this approach (I assume it impacts the Mypy extension too?) which is that if we run |
Personally I use autosave, which avoids (amongst others) this... |
Hm what if I like.. switch git branches and don't have the changed files open? I think we may be better off with the approach Charlie outlined, even if it doesn't solve the "on-disk vs in-buffer" issue. |
I think @charliermarsh approach is pretty good as an explicit command. The command description could indicate that it will analyze files on disk and warn users they have unsaved files open. |
In case it helps, the Go VS Code extension has a similar option which is very handy: Personally, I would love it if Ruff always showed all errors for my entire workspace. I think linting the entire workspace on save of any file would probably be optimal as a change in one file may result in different violations or fixes in other files. golangci-lint (Go's linter) is actually significantly slower than Ruff and appears to do just this. Personally, I think this is the one change that would make Ruff a lot more useable in VS Code. Presently, I am running it via the CLI a lot to see where my issues reside (especially on larger projects with hundreds of files). Cheers |
but causes other issues, such as making hotreload workflows really annoying. Typing almost immediately restarts your flask server and then the page reloads to a crash. |
One more upvote there. An absence of such feature confuses some engineers migrating to VS Code, and would certainly help a looot for deeper code review sessions. We consider to run ruff separately and just create simple plugin to review the reports, but it feels ugly. |
This is a feature that's on the roadmap for the red knot project that's currently a WIP. |
Hi!
Is there a setting, that would enable this behavior?
Equivalent to Pylance's
python.analysis.diagnosticMode
setting.The text was updated successfully, but these errors were encountered: