10000 Clean up the traceback from the `run` mode (#5066) · python/mypy@fae1f25 · GitHub
[go: up one dir, main page]

Skip to content

Commit fae1f25

Browse files
authored
Clean up the traceback from the run mode (#5066)
Don't start the server from inside a catch block, since that produces and ugly traceback if the server crashes.
1 parent 6519eb6 commit fae1f25

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

mypy/dmypy.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,7 @@ def do_run(args: argparse.Namespace) -> None:
212212
since we don't want to duplicate mypy's huge list of flags.
213213
(The -- is only necessary if flags are specified.)
214214
"""
215-
try:
216-
get_status()
217-
except BadStatus as err:
215+
if not is_running():
218216
# Bad or missing status file or dead process; good to start.
219217
start_server(args, allow_sources=True)
220218

@@ -441,6 +439,15 @@ def read_status() -> Dict[str, object]:
441439
return data
442440

443441

442+
def is_running() -> bool:
443+
"""Check if the server is running cleanly"""
444+
try:
445+
get_status()
446+
except BadStatus as err:
447+
return False
448+
return True
449+
450+
444451
# Run main().
445452

446453
if __name__ == '__main__':

0 commit comments

Comments
 (0)
0