From 1335882b2a7287c4173dd0b1b15805e3373d998b Mon Sep 17 00:00:00 2001 From: Aaron Orenstein Date: Thu, 23 Jan 2025 21:40:53 -0800 Subject: [PATCH] If mypy fails it should report the error back to lintrunner (#145550) This happened to me because I had a bad LD_LIBRARY_PATH and mypy was failing to run (.so load error) - but lintrunner was silent about the underlying problem. Differential Revision: [D68593081](https://our.internmc.facebook.com/intern/diff/D68593081) Pull Request resolved: https://github.com/pytorch/pytorch/pull/145550 Approved by: https://github.com/bobrenjc93, https://github.com/Skylion007 --- tools/linter/adapters/mypy_linter.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/linter/adapters/mypy_linter.py b/tools/linter/adapters/mypy_linter.py index cc5367b1921..9e9c9054916 100644 --- a/tools/linter/adapters/mypy_linter.py +++ b/tools/linter/adapters/mypy_linter.py @@ -149,6 +149,21 @@ def check_files( ] stdout = str(proc.stdout, "utf-8").strip() stderr = str(proc.stderr, "utf-8").strip() + if proc.returncode not in (0, 1): + return [ + LintMessage( + path=None, + line=None, + char=None, + code=code, + severity=LintSeverity.ERROR, + name="command-failed", + original=None, + replacement=None, + description=stderr, + ) + ] + rc = [ LintMessage( path=match["file"],