MCPcopy
hub / github.com/python/mypy / console_entry

Function console_entry

mypy/__main__.py:14–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13
14def console_entry() -> None:
15 try:
16 main()
17 sys.stdout.flush()
18 sys.stderr.flush()
19 except BrokenPipeError:
20 # Python flushes standard streams on exit; redirect remaining output
21 # to devnull to avoid another BrokenPipeError at shutdown
22 devnull = os.open(os.devnull, os.O_WRONLY)
23 os.dup2(devnull, sys.stdout.fileno())
24 sys.exit(2)
25 except KeyboardInterrupt:
26 # Setting fscache prevents bogus errors when --package-root is set.
27 _, options = process_options(args=sys.argv[1:], fscache=FileSystemCache())
28 if options.show_traceback:
29 sys.stdout.write(traceback.format_exc())
30 formatter = FancyFormatter(sys.stdout, sys.stderr, False)
31 msg = "Interrupted\n"
32 sys.stdout.write(formatter.style(msg, color="red", bold=True))
33 sys.stdout.flush()
34 sys.stderr.flush()
35 sys.exit(2)
36 except Exception as e:
37 # Try reporting any uncaught error canonically, otherwise just flush the traceback.
38 try:
39 import mypy.errors
40
41 _, options = process_options(args=sys.argv[1:], fscache=FileSystemCache())
42 mypy.errors.report_internal_error(e, None, 0, None, options)
43 except Exception:
44 pass
45 sys.stdout.write(traceback.format_exc())
46 sys.stdout.flush()
47 sys.stderr.flush()
48 sys.exit(2)
49
50
51if __name__ == "__main__":

Callers 1

__main__.pyFile · 0.70

Calls 9

styleMethod · 0.95
mainFunction · 0.90
process_optionsFunction · 0.90
FileSystemCacheClass · 0.90
FancyFormatterClass · 0.90
filenoMethod · 0.80
exitMethod · 0.80
flushMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…