Skip to content

Commit 53db79e

Browse files
authored
Parse mypy diagnostics from stderr when non_interactive is set\n\nIn some configurations (e.g. non_interactive), mypy emits diagnostics on stderr.\nAggregate stdout+stderr when parsing so errors aren’t dropped when stdout is empty.\n\nFixes #364 (#375)
1 parent 0c4492c commit 53db79e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

bundled/tool/lsp_server.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,17 @@ def _linting_helper(document: workspace.Document) -> None:
235235
extra_args += ["--show-error-end"]
236236

237237
result = _run_tool_on_document(document, extra_args=extra_args)
238-
if result and result.stdout:
239-
log_to_output(f"{document.uri} :\r\n{result.stdout}")
238+
# Some mypy modes (e.g., non_interactive) emit diagnostics on stderr.
239+
# Prefer parsing combined output so we don't miss errors when stdout is empty.
240+
if result and (result.stdout or result.stderr):
241+
combined_output = "\n".join(
242+
[s for s in [result.stdout or "", result.stderr or ""] if s]
243+
)
244+
# Keep existing stdout logging for consistency; stderr is logged separately above.
245+
if result.stdout:
246+
log_to_output(f"{document.uri} :\r\n{result.stdout}")
240247
parse_results = _parse_output_using_regex(
241-
result.stdout, settings["severity"]
248+
combined_output, settings["severity"]
242249
)
243250
reportingScope = settings["reportingScope"]
244251
for file_path, diagnostics in parse_results.items():

0 commit comments

Comments
 (0)