|
10 | 10 | from subprocess import Popen, PIPE |
11 | 11 | import os |
12 | 12 |
|
13 | | -from pylint.epylint import py_run |
14 | 13 | from pylsp import hookimpl, lsp |
15 | 14 |
|
16 | 15 | try: |
@@ -85,20 +84,21 @@ def lint(cls, document, is_saved, flags=''): |
85 | 84 | # save. |
86 | 85 | return cls.last_diags[document.path] |
87 | 86 |
|
88 | | - # py_run will call shlex.split on its arguments, and shlex.split does |
89 | | - # not handle Windows paths (it will try to perform escaping). Turn |
90 | | - # backslashes into forward slashes first to avoid this issue. |
91 | | - path = document.path |
92 | | - if sys.platform.startswith('win'): |
93 | | - path = path.replace('\\', '/') |
94 | | - |
95 | | - pylint_call = '{} -f json {}'.format(path, flags) |
96 | | - log.debug("Calling pylint with '%s'", pylint_call) |
97 | | - json_out, err = py_run(pylint_call, return_std=True) |
98 | | - |
99 | | - # Get strings |
100 | | - json_out = json_out.getvalue() |
101 | | - err = err.getvalue() |
| 87 | + cmd = [ |
| 88 | + 'python', |
| 89 | + '-c', |
| 90 | + 'import sys; from pylint.lint import Run; Run(sys.argv[1:])', |
| 91 | + '-f', |
| 92 | + 'json', |
| 93 | + document.path |
| 94 | + ] + (str(flags).split(' ') if flags else []) |
| 95 | + log.debug("Calling pylint with '%s'", ' '.join(cmd)) |
| 96 | + |
| 97 | + with Popen(cmd, stdout=PIPE, stderr=PIPE, |
| 98 | + cwd=document._workspace.root_path, universal_newlines=True) as process: |
| 99 | + process.wait() |
| 100 | + json_out = process.stdout.read() |
| 101 | + err = process.stderr.read() |
102 | 102 |
|
103 | 103 | if err != '': |
104 | 104 | log.error("Error calling pylint: '%s'", err) |
|
0 commit comments