Skip to content

Commit

Permalink
Prevent warnings from causing dmypy to fail (#14102)
Browse files Browse the repository at this point in the history
Fixes: #14101

This prevents non-error messages (e.g. warnings) from causing dmypy to
return exit code 1.
  • Loading branch information
neob91-close committed Nov 15, 2022
1 parent 0d2a954 commit e01359d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
14 changes: 14 additions & 0 deletions test-data/unit/daemon.test
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ mypy-daemon: error: Missing target module, package, files, or command.
$ dmypy stop
Daemon stopped

[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
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]
Expand Down

0 comments on commit e01359d

Please sign in to comment.