Skip to content
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 python module if ruff executable is missing #70

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pylsp_ruff/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ def run_ruff(

arguments = subcommand.build_args(document_path, settings, fix, extra_arguments)

p = None
if executable is not None:
log.debug(f"Calling {executable} with args: {arguments} on '{document_path}'")
try:
Expand All @@ -518,7 +519,11 @@ def run_ruff(
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
except Exception:
log.error(f"Can't execute ruff with given executable '{executable}'.")
else:
if p is None:
log.debug(
f"Calling ruff via '{sys.executable} -m ruff'"
f" with args: {arguments} on '{document_path}'"
)
cmd = [sys.executable, "-m", "ruff", str(subcommand)]
cmd.extend(arguments)
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
Expand Down