From 08236723881ccee4150ee131f65efdc132658abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bartosi=C5=84ski?= Date: Tue, 15 Nov 2022 12:35:39 +0100 Subject: [PATCH 1/2] Prevent warnings from causing dmypy to fail --- mypy/dmypy_server.py | 3 ++- test-data/unit/daemon.test | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mypy/dmypy_server.py b/mypy/dmypy_server.py index be2f4ab8d618..7227cd559946 100644 --- a/mypy/dmypy_server.py +++ b/mypy/dmypy_server.py @@ -512,7 +512,8 @@ def initialize_fine_grained( print_memory_profile(run_gc=False) - status = 1 if messages else 0 + __, n_notes, __ = count_stats(messages) + status = 1 if messages and n_notes < len(messages) else 0 messages = self.pretty_messages(messages, len(sources), is_tty, terminal_width) return {"out": "".join(s + "\n" for s in messages), "err": "", "status": status} diff --git a/test-data/unit/daemon.test b/test-data/unit/daemon.test index 56966b2f740c..30db59bca96a 100644 --- a/test-data/unit/daemon.test +++ b/test-data/unit/daemon.test @@ -214,6 +214,20 @@ mypy-daemon: error: Missing target module, package, files, or command. $ dmypy stop Daemon stopped +[case testDaemonWarningSuccessExitCode] +$ dmypy run -- foo.py --follow-imports=error +Daemon started +foo.py:2: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs +Success: no issues found in 1 source file +$ echo $? +0 +$ dmypy stop +Daemon stopped +[file foo.py] +def foo(): + a: int = 1 + print(a + "2") + -- this is carefully constructed to be able to break if the quickstart system lets -- something through incorrectly. in particular, the files need to have the same size [case testDaemonQuickstart] From 08df5ed0dc109d3a9266eb1728c4f09327a87401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bartosi=C5=84ski?= Date: Tue, 15 Nov 2022 13:44:40 +0100 Subject: [PATCH 2/2] Add posix platform flag for warning exit code test --- test-data/unit/daemon.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-data/unit/daemon.test b/test-data/unit/daemon.test index 30db59bca96a..c72dc3a32bc7 100644 --- a/test-data/unit/daemon.test +++ b/test-data/unit/daemon.test @@ -214,7 +214,7 @@ mypy-daemon: error: Missing target module, package, files, or command. $ dmypy stop Daemon stopped -[case testDaemonWarningSuccessExitCode] +[case testDaemonWarningSuccessExitCode-posix] $ dmypy run -- foo.py --follow-imports=error Daemon started foo.py:2: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs