()
| 12 | |
| 13 | |
| 14 | def 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 | |
| 51 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…