astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
1.11k stars 53 forks source link

fallback to using bundled ruff? #118

Closed shapiromatron closed 1 year ago

shapiromatron commented 1 year ago

The vscode-flake8 extension states:

The bundled flake8 is only used if there is no installed version of flake8 found in the selected python environment.

This is nice behavior; if a team specifies a specific version of flake8, then that's used instead of the version in the extension.

It would be nice if this extension had the same behavior. Right now I guess we could update our developer instructions to set a path to a custom version of ruff in work workspace, but if a workspace has a version already installed, it might be a desirable default behavior instead, and is consistent with the flake8 extension.

PS - ruff is awesome, nice work!

charliermarsh commented 1 year ago

I think we have this behavior -- if you use fromEnvironment, then we fallback to the bundled version if we can't find an extension in the workspace:

Screen Shot 2023-01-28 at 10 22 37 PM

Can you give that a try and let me know if it works for you (or doesn't)?

(And thank you for the kind words :))

shapiromatron commented 1 year ago

Confirmed, it works brilliantly and as expected. Easy to debug and confirm when I viewed the output terminal vscode:

Using interpreter executable: /Users/me/dev/hawc/venv/bin/ruff

At a minimum, it'd be good to document importStrategy in the readme, I didn't see this option. I'd be happy to submit a PR with this if you'd like.

An additional step might be to change the default to fromEnvironment, since that would fall-back to the bundled if one isn't installed, and that's consistent with how the built flake8 vscode python tools appear to work.

Let me know if I should go ahead with the docs change, I'm happy to help, and looking forward to switching all my repos over to ruff.

charliermarsh commented 1 year ago

Yeah those are all good ideas. PRs welcome on any of them! I feel like I used to have importStrategy on there, but that it got removed.

Oh, probably because I copied this table over from ruff-lsp, and the underlying LSP doesn't really support fromEnvironment (it's a VS Code thing)... It looks like it was present in 7431c2e439c38d1ae1f33ac3bfdb4e90adb27652, but could probably be improved beyond what it used to say there.

charliermarsh commented 1 year ago

Added to docs!

shapiromatron commented 1 year ago

Wow thanks! I had the PR on my list but you beat me too it, thanks again!