Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pygame greeting breaking pylint diagnostics #148

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pylsp/plugins/pylint_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
import re
from subprocess import Popen, PIPE
import os

from pylint.epylint import py_run
from pylsp import hookimpl, lsp
Expand All @@ -19,6 +20,15 @@

log = logging.getLogger(__name__)

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


class PylintLinter:
last_diags = collections.defaultdict(list)
Expand Down