-
Notifications
You must be signed in to change notification settings - Fork 23
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
fall back to system ruff executable without executable setting #97
Conversation
Hi, sorry for the delay. I am not sure what the use case for this is though - if the executable is not set the python-lsp-ruff/pylsp_ruff/plugin.py Lines 534 to 541 in 9117709
Does this not work for you? |
Hi! - no worries :) I think it's alright to use What do you think? |
Ah, I wasn't aware of this issue. |
you could have a look once if ruff has an entry point in |
Instead of using importlib, I moved finding the correct executable to a new function which is now cached, so it should only run once with the given executable. |
Hmm, I seemed to have missed those issues before pushing, let me look into it. |
This should work now, please check if it does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from what I understand now, what you whish is:
- if
executable
is set and exists, use it - otherwise, try the ruff module
- otherwise, use the system executable
I'd propose to implement is this way:
- if
executable
is set, use it, and crash if it doesn't exist. silent swiches of the used program are unexpected and hard to debug. - otherwise, check once if the ruff module exists and use it
- otherwise, use the system executable found by
which
.
maybe some way to prefer the executable would be better, because then we could bypass invoking a new python interpreter for every ruff invocation eats a bit of latency. or calling the python module in the same interpreter.
4bf5086
to
c235923
Compare
I've implemented an improved version, which uses the configuration value without fallback, or it tries the python module and then system executable next. one could optimize this to eliminate the extra python interpreter invocation if using the module (for latency improvement) by re-using the current interpreter instead. |
67c77da
to
12925c5
Compare
Looks really nice, but I am not sure the ImportError is propagated the way you probably want it to, e.g. when testing with neovim the error does not reach the editor. |
which import error, if no executable/module is found? if there's a better way than crashing with an exception, we should surely use it :) |
Similarly to |
maybe we could merge this for now since it's not making it worse than before when no ruff was found :) |
12925c5
to
d9993ae
Compare
db15d0f
to
c0ed81d
Compare
I took the liberty of removing the RuntimeErrors for now, otherwise thanks a lot for the PR! |
great :) |
otherwise I have to either configure the path in the project's pyproject.toml or unnecessarily in the lsp configuration :)