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 committed Dec 22, 2023
1 parent a4fac02 commit 7284a87
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 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,10 @@ 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' with args: {arguments} on '{document_path}'"

Check notice on line 524 in pylsp_ruff/plugin.py

View workflow job for this annotation

GitHub Actions / build (3.8)

Ruff

(E501) Line too long (102 > 88 characters)

Check notice on line 524 in pylsp_ruff/plugin.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Ruff

(E501) Line too long (102 > 88 characters)

Check notice on line 524 in pylsp_ruff/plugin.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff

(E501) Line too long (102 > 88 characters)

Check notice on line 524 in pylsp_ruff/plugin.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff

(E501) Line too long (102 > 88 characters)

Check notice on line 524 in pylsp_ruff/plugin.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Ruff

(E501) Line too long (102 > 88 characters)
)
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 7284a87

Please sign in to comment.