Skip to content

Commit 7ceb7da

Browse files
committed
catch FileNotFoundError
1 parent fc6adcd commit 7ceb7da

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pylsp_ruff/ruff_lint.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ def run_ruff_lint(ruff_executable: str, document: Document, arguments: list) ->
9191
cmd = [ruff_executable]
9292
cmd.extend(arguments)
9393
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
94-
except SubprocessError as e:
94+
(stdout, stderr) = p.communicate(document.source.encode())
95+
96+
if stderr:
97+
log.error(f"Error running ruff: {stderr.decode()}")
98+
99+
return stdout.decode()
100+
except FileNotFoundError as e:
95101
# Ruff doesn't yet support calling with python -m ruff,
96102
# see https://github.com/charliermarsh/ruff/issues/593
97103
log.error(f"Error running {ruff_executable}: {e}")
98-
(stdout, stderr) = p.communicate(document.source.encode())
99-
100-
if stderr:
101-
log.error(f"Error running ruff: {stderr.decode()}")
102-
return stdout.decode()
103104

104105

105106
def parse_ruff_stdout(stdout: str) -> list:

0 commit comments

Comments
 (0)