Skip to content

Commit 23c2797

Browse files
committed
Silence code check.
1 parent ea76118 commit 23c2797

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Contributors:
88
* Alvin Francis (alvinfrancis);
99
* Anler Hp (ikame);
1010
* Anton Parkhomenko (chuwy);
11+
* Ashley Hewson (ashleyh);
1112
* Benjamin Ruston (bruston);
1213
* Boris Filippov (frenzykryger);
1314
* David Vogt (winged);

pymode/lint.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" Pylama integration. """
22

33
import vim # noqa
4-
from .utils import pymode_message
4+
from .utils import pymode_message, silence_stderr
55

66
import os.path
77

@@ -31,7 +31,8 @@ def code_check():
3131
vim.command('return')
3232
return False
3333

34-
errors = check_path(path, options=options)
34+
with silence_stderr():
35+
errors = check_path(path, options=options)
3536
sort_rules = vim.eval('g:pymode_lint_sort')
3637

3738
def sort(e):

pymode/utils.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
import vim # noqa
77

8+
try:
9+
from StringIO import StringIO
10+
except ImportError:
11+
from io import StringIO
12+
13+
from contextlib import contextmanager
14+
import threading
15+
816

917
PY2 = sys.version_info[0] == 2
1018

@@ -123,3 +131,18 @@ def wrapper(*args, **kwargs):
123131
pymode_error(e)
124132
return None
125133
return wrapper
134+
135+
136+
@contextmanager
137+
def silence_stderr():
138+
139+
""" Redirect stderr. """
140+
141+
with threading.Lock():
142+
stderr = sys.stderr
143+
sys.stderr = StringIO()
144+
145+
yield
146+
147+
with threading.Lock():
148+
sys.stderr = stderr

0 commit comments

Comments
 (0)