Skip to content

Commit

Permalink
fix(linter): raise error when pylint fails instead of failing silently (
Browse files Browse the repository at this point in the history
  • Loading branch information
justinchuby authored Jan 29, 2024
1 parent fa504b1 commit 902ee6e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lintrunner_adapters/adapters/pylint_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import logging
import re
import subprocess
import sys
from typing import Pattern

Expand Down Expand Up @@ -109,11 +110,13 @@ def check_files(
sys.executable,
"-mpylint",
"--score=n",
"--exit-zero",
*([f"--rcfile={rcfile}"] if rcfile else []),
f"--jobs={jobs}",
*filenames,
],
retries=retries,
check=True,
)
except OSError as err:
return [
Expand All @@ -129,6 +132,24 @@ def check_files(
description=(f"Failed due to {err.__class__.__name__}:\n{err}"),
)
]
except subprocess.CalledProcessError as err:
return [
LintMessage(
path=None,
line=None,
char=None,
code=LINTER_CODE,
severity=LintSeverity.ERROR,
name="command-failed",
original=None,
replacement=None,
description=(
f"Linter exited with return code {err.returncode}.\n"
f"STDOUT: {err.output.decode('utf-8')}\n\n"
f"STDERR: {err.stderr.decode('utf-8')}"
),
)
]
stdout = str(proc.stdout, "utf-8").strip()
return [
LintMessage(
Expand Down

0 comments on commit 902ee6e

Please sign in to comment.