|
10 | 10 | import tempfile
|
11 | 11 | import os
|
12 | 12 | import os.path
|
| 13 | +import subprocess |
13 | 14 | from pathlib import Path
|
14 | 15 | import logging
|
15 |
| -from mypy import api as mypy_api |
16 | 16 | from pylsp import hookimpl
|
17 | 17 | from pylsp.workspace import Document, Workspace
|
18 | 18 | from pylsp.config.config import Config
|
@@ -190,22 +190,32 @@ def pylsp_lint(
|
190 | 190 | args.extend(["--incremental", "--follow-imports", "silent"])
|
191 | 191 |
|
192 | 192 | log.info("executing mypy args = %s", args)
|
193 |
| - report, errors, _ = mypy_api.run(args) |
| 193 | + completed_process = subprocess.run( |
| 194 | + ["mypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE |
| 195 | + ) |
| 196 | + report = completed_process.stdout.decode() |
| 197 | + errors = completed_process.stderr.decode() |
194 | 198 | else:
|
195 | 199 | # If dmypy daemon is non-responsive calls to run will block.
|
196 | 200 | # Check daemon status, if non-zero daemon is dead or hung.
|
197 | 201 | # If daemon is hung, kill will reset
|
198 | 202 | # If daemon is dead/absent, kill will no-op.
|
199 | 203 | # In either case, reset to fresh state
|
200 |
| - _, _err, _status = mypy_api.run_dmypy(["status"]) |
| 204 | + completed_process = subprocess.run(["dmypy", *args], stderr=subprocess.PIPE) |
| 205 | + _err = completed_process.stderr.decode() |
| 206 | + _status = completed_process.returncode |
201 | 207 | if _status != 0:
|
202 | 208 | log.info("restarting dmypy from status: %s message: %s", _status, _err.strip())
|
203 |
| - mypy_api.run_dmypy(["kill"]) |
| 209 | + subprocess.run(["dmypy", "kill"]) |
204 | 210 |
|
205 | 211 | # run to use existing daemon or restart if required
|
206 | 212 | args = ["run", "--"] + args
|
207 | 213 | log.info("dmypy run args = %s", args)
|
208 |
| - report, errors, _ = mypy_api.run_dmypy(args) |
| 214 | + completed_process = subprocess.run( |
| 215 | + ["dmypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE |
| 216 | + ) |
| 217 | + report = completed_process.stdout.decode() |
| 218 | + errors = completed_process.stderr.decode() |
209 | 219 |
|
210 | 220 | log.debug("report:\n%s", report)
|
211 | 221 | log.debug("errors:\n%s", errors)
|
|
0 commit comments