From 2e25222ad0ea127f9d2b5e5d4546503474bfecb6 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Wed, 16 May 2018 18:50:44 -0400 Subject: [PATCH] Clean up the traceback from the `run` mode Don't start the server from inside a catch block, since that produces and ugly traceback if the server crashes. --- mypy/dmypy.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mypy/dmypy.py b/mypy/dmypy.py index faf2921060e9..76fcd5a9cc9b 100644 --- a/mypy/dmypy.py +++ b/mypy/dmypy.py @@ -212,9 +212,7 @@ def do_run(args: argparse.Namespace) -> None: since we don't want to duplicate mypy's huge list of flags. (The -- is only necessary if flags are specified.) """ - try: - get_status() - except BadStatus as err: + if not is_running(): # Bad or missing status file or dead process; good to start. start_server(args, allow_sources=True) @@ -441,6 +439,15 @@ def read_status() -> Dict[str, object]: return data +def is_running() -> bool: + """Check if the server is running cleanly""" + try: + get_status() + except BadStatus as err: + return False + return True + + # Run main(). if __name__ == '__main__':