Skip to content

Commit

Permalink
Fall back to python module if ruff executable is missing
Browse files Browse the repository at this point in the history
Fixes #69.
  • Loading branch information
chris-reeves authored and jhossbach committed Dec 26, 2023
1 parent a4fac02 commit 8a6fac9
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 8a6fac9

Please sign in to comment.