Skip to content

Commit 90523f6

Browse files
committed
specify encoding
1 parent 2b966ac commit 90523f6

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

pylsp_mypy/plugin.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,11 @@ def get_diagnostics(
252252
# mypy exists on path
253253
# -> use mypy on path
254254
log.info("executing mypy args = %s on path", args)
255-
completed_process = subprocess.run(["mypy", *args], capture_output=True, **windows_flag)
256-
report = completed_process.stdout.decode()
257-
errors = completed_process.stderr.decode()
255+
completed_process = subprocess.run(
256+
["mypy", *args], capture_output=True, **windows_flag, encoding="utf-8"
257+
)
258+
report = completed_process.stdout
259+
errors = completed_process.stderr
258260
exit_status = completed_process.returncode
259261
else:
260262
# mypy does not exist on path, but must exist in the env pylsp-mypy is installed in
@@ -275,8 +277,9 @@ def get_diagnostics(
275277
["dmypy", "--status-file", dmypy_status_file, "status"],
276278
capture_output=True,
277279
**windows_flag,
280+
encoding="utf-8",
278281
)
279-
errors = completed_process.stderr.decode()
282+
errors = completed_process.stderr
280283
exit_status = completed_process.returncode
281284
if exit_status != 0:
282285
log.info(
@@ -288,6 +291,7 @@ def get_diagnostics(
288291
["dmypy", "--status-file", dmypy_status_file, "restart"],
289292
capture_output=True,
290293
**windows_flag,
294+
encoding="utf-8",
291295
)
292296
else:
293297
# dmypy does not exist on path, but must exist in the env pylsp-mypy is installed in
@@ -310,10 +314,10 @@ def get_diagnostics(
310314
# -> use mypy on path
311315
log.info("dmypy run args = %s via path", args)
312316
completed_process = subprocess.run(
313-
["dmypy", *args], capture_output=True, **windows_flag
317+
["dmypy", *args], capture_output=True, **windows_flag, encoding="utf-8"
314318
)
315-
report = completed_process.stdout.decode()
316-
errors = completed_process.stderr.decode()
319+
report = completed_process.stdout
320+
errors = completed_process.stderr
317321
exit_status = completed_process.returncode
318322
else:
319323
# dmypy does not exist on path, but must exist in the env pylsp-mypy is installed in

test/test_plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def test_option_overrides_dmypy(last_diagnostics_monkeypatch, workspace):
201201
else {},
202202
)
203203

204-
m = Mock(wraps=lambda a, **_: Mock(returncode=0, **{"stdout.decode": lambda: ""}))
204+
m = Mock(wraps=lambda a, **_: Mock(returncode=0, **{"stdout": ""}))
205205
last_diagnostics_monkeypatch.setattr(plugin.subprocess, "run", m)
206206

207207
document = Document(DOC_URI, workspace, DOC_TYPE_ERR)
@@ -223,7 +223,7 @@ def test_option_overrides_dmypy(last_diagnostics_monkeypatch, workspace):
223223
"--show-column-numbers",
224224
document.path,
225225
]
226-
m.assert_called_with(expected, capture_output=True, **windows_flag)
226+
m.assert_called_with(expected, capture_output=True, **windows_flag, encoding="utf-8")
227227

228228

229229
def test_dmypy_status_file(tmpdir, last_diagnostics_monkeypatch, workspace):

0 commit comments

Comments
 (0)