Skip to content

Commit 4c05ac4

Browse files
Fix pygame greeting breaking pylint JSON output (#148)
1 parent c14a95e commit 4c05ac4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pylsp/plugins/pylint_lint.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import re
1010
from subprocess import Popen, PIPE
11+
import os
1112

1213
from pylint.epylint import py_run
1314
from pylsp import hookimpl, lsp
@@ -19,6 +20,15 @@
1920

2021
log = logging.getLogger(__name__)
2122

23+
# Pylint fails to suppress STDOUT when importing whitelisted C
24+
# extensions, mangling their output into the expected JSON which breaks the
25+
# parser. The most prominent example (and maybe the only one out there) is
26+
# pygame - we work around that by asking pygame to NOT display the message upon
27+
# import via an (otherwise harmless) environment variable. This is an ad-hoc
28+
# fix for a very specific upstream issue.
29+
# Related: https://github.com/PyCQA/pylint/issues/3518
30+
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = 'hide'
31+
2232

2333
class PylintLinter:
2434
last_diags = collections.defaultdict(list)

0 commit comments

Comments
 (0)