Skip to content

Commit d0e35fe

Browse files
committed
Replace capture_output shortcut with explicit args
The `capture_output` parameter is a shortcut for setting `stderr` and `stdout` to `PIPE`, but is not available on Python 3.6. To ensure compatibility, this uses the longer form. This approach also has the advantage of not capturing `stdout` when it's not required on the first call to `dmypy`.
1 parent 42491d8 commit d0e35fe

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pylsp_mypy/plugin.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ def pylsp_lint(
190190
args.extend(["--incremental", "--follow-imports", "silent"])
191191

192192
log.info("executing mypy args = %s", args)
193-
completed_process = subprocess.run(["mypy", *args], capture_output=True)
193+
completed_process = subprocess.run(
194+
["mypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE
195+
)
194196
report = completed_process.stdout.decode()
195197
errors = completed_process.stderr.decode()
196198
else:
@@ -199,7 +201,7 @@ def pylsp_lint(
199201
# If daemon is hung, kill will reset
200202
# If daemon is dead/absent, kill will no-op.
201203
# In either case, reset to fresh state
202-
completed_process = subprocess.run(["dmypy", *args], capture_output=True)
204+
completed_process = subprocess.run(["dmypy", *args], stderr=subprocess.PIPE)
203205
_err = completed_process.stderr.decode()
204206
_status = completed_process.returncode
205207
if _status != 0:
@@ -209,7 +211,9 @@ def pylsp_lint(
209211
# run to use existing daemon or restart if required
210212
args = ["run", "--"] + args
211213
log.info("dmypy run args = %s", args)
212-
completed_process = subprocess.run(["dmypy", *args], capture_output=True)
214+
completed_process = subprocess.run(
215+
["dmypy", *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE
216+
)
213217
report = completed_process.stdout.decode()
214218
errors = completed_process.stderr.decode()
215219

0 commit comments

Comments
 (0)