Skip to content

Commit 3b2c283

Browse files
committed
Use return code instead of stderr to detect errors
1 parent 6a01dd3 commit 3b2c283

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pylsp_ruff/plugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def run_ruff(
458458
p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
459459
(stdout, stderr) = p.communicate(document_source.encode())
460460

461-
if stderr:
461+
if p.returncode != 0:
462462
log.error(f"Error running ruff: {stderr.decode()}")
463463

464464
return stdout.decode()
@@ -491,6 +491,8 @@ def build_arguments(
491491
args = []
492492
# Suppress update announcements
493493
args.append("--quiet")
494+
# Suppress exit 1 when violations were found
495+
args.append("--exit-zero")
494496
# Use the json formatting for easier evaluation
495497
args.append("--output-format=json")
496498
if fix:

tests/test_ruff_lint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def f():
177177
assert call_args == [
178178
"ruff",
179179
"--quiet",
180+
"--exit-zero",
180181
"--output-format=json",
181182
"--no-fix",
182183
"--force-exclude",

0 commit comments

Comments
 (0)