Skip to content

Commit 902ee6e

Browse files
authored
fix(linter): raise error when pylint fails instead of failing silently (#91)
PYLINT now fails when there is a config error: ![image](https://github.com/justinchuby/lintrunner-adapters/assets/11205048/e0bca49c-530c-45fc-a3d0-fd64f77d6068)
1 parent fa504b1 commit 902ee6e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lintrunner_adapters/adapters/pylint_linter.py

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import argparse
44
import logging
55
import re
6+
import subprocess
67
import sys
78
from typing import Pattern
89

@@ -109,11 +110,13 @@ def check_files(
109110
sys.executable,
110111
"-mpylint",
111112
"--score=n",
113+
"--exit-zero",
112114
*([f"--rcfile={rcfile}"] if rcfile else []),
113115
f"--jobs={jobs}",
114116
*filenames,
115117
],
116118
retries=retries,
119+
check=True,
117120
)
118121
except OSError as err:
119122
return [
@@ -129,6 +132,24 @@ def check_files(
129132
description=(f"Failed due to {err.__class__.__name__}:\n{err}"),
130133
)
131134
]
135+
except subprocess.CalledProcessError as err:
136+
return [
137+
LintMessage(
138+
path=None,
139+
line=None,
140+
char=None,
141+
code=LINTER_CODE,
142+
severity=LintSeverity.ERROR,
143+
name="command-failed",
144+
original=None,
145+
replacement=None,
146+
description=(
147+
f"Linter exited with return code {err.returncode}.\n"
148+
f"STDOUT: {err.output.decode('utf-8')}\n\n"
149+
f"STDERR: {err.stderr.decode('utf-8')}"
150+
),
151+
)
152+
]
132153
stdout = str(proc.stdout, "utf-8").strip()
133154
return [
134155
LintMessage(

0 commit comments

Comments
 (0)