From dc87909eb4a77fdc9fc19a24f7b4e48a4fa26e12 Mon Sep 17 00:00:00 2001 From: James Mochizuki-Freeman Date: Tue, 4 Jul 2023 19:20:11 -0500 Subject: [PATCH] Fix spurious output for `--follow-imports=normal` --- bundled/tool/lsp_server.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bundled/tool/lsp_server.py b/bundled/tool/lsp_server.py index ceea88e..199f9ad 100644 --- a/bundled/tool/lsp_server.py +++ b/bundled/tool/lsp_server.py @@ -60,6 +60,7 @@ def update_sys_path(path_to_add: str, strategy: str) -> None: TOOL_ARGS = [ "--no-color-output", "--no-error-summary", + "--show-absolute-path", "--show-column-numbers", "--show-error-code", "--no-pretty", @@ -113,7 +114,9 @@ def _linting_helper(document: workspace.Document) -> list[lsp.Diagnostic]: # deep copy here to prevent accidentally updating global settings. settings = copy.deepcopy(_get_settings_by_document(document)) - return _parse_output_using_regex(result.stdout, settings["severity"]) + return _parse_output_using_regex( + result.stdout, settings["severity"], document + ) except Exception: LSP_SERVER.show_message_log( f"Linting failed with error:\r\n{traceback.format_exc()}", @@ -136,7 +139,7 @@ def _get_group_dict(line: str) -> Optional[Dict[str, str | None]]: def _parse_output_using_regex( - content: str, severity: Dict[str, str] + content: str, severity: Dict[str, str], document: workspace.Document ) -> list[lsp.Diagnostic]: lines: list[str] = content.splitlines() diagnostics: list[lsp.Diagnostic] = [] @@ -153,6 +156,11 @@ def _parse_output_using_regex( if not data: continue + # skip output from other documents + # (causes --follow-imports=normal to behave like silent). + if data["filepath"] != document.path: + continue + type_ = data["type"] code = data["code"]