Skip to content

Commit e01359d

Browse files
authored
Prevent warnings from causing dmypy to fail (#14102)
Fixes: #14101 This prevents non-error messages (e.g. warnings) from causing dmypy to return exit code 1.
1 parent 0d2a954 commit e01359d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

mypy/dmypy_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ def initialize_fine_grained(
512512

513513
print_memory_profile(run_gc=False)
514514

515-
status = 1 if messages else 0
515+
__, n_notes, __ = count_stats(messages)
516+
status = 1 if messages and n_notes < len(messages) else 0
516517
messages = self.pretty_messages(messages, len(sources), is_tty, terminal_width)
517518
return {"out": "".join(s + "\n" for s in messages), "err": "", "status": status}
518519

test-data/unit/daemon.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ mypy-daemon: error: Missing target module, package, files, or command.
214214
$ dmypy stop
215215
Daemon stopped
216216

217+
[case testDaemonWarningSuccessExitCode-posix]
218+
$ dmypy run -- foo.py --follow-imports=error
219+
Daemon started
220+
foo.py:2: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs
221+
Success: no issues found in 1 source file
222+
$ echo $?
223+
0
224+
$ dmypy stop
225+
Daemon stopped
226+
[file foo.py]
227+
def foo():
228+
a: int = 1
229+
print(a + "2")
230+
217231
-- this is carefully constructed to be able to break if the quickstart system lets
218232
-- something through incorrectly. in particular, the files need to have the same size
219233
[case testDaemonQuickstart]

0 commit comments

Comments
 (0)