()
| 42 | |
| 43 | |
| 44 | def main() -> None: |
| 45 | parser = argparse.ArgumentParser( |
| 46 | description="Compile mypy and collect a trace log while type checking (by default, self check)." |
| 47 | ) |
| 48 | parser.add_argument( |
| 49 | "--multi-file", |
| 50 | action="store_true", |
| 51 | help="compile mypy into one C file per module (to reduce RAM use during compilation)", |
| 52 | ) |
| 53 | parser.add_argument( |
| 54 | "--skip-compile", action="store_true", help="use compiled mypy from previous run" |
| 55 | ) |
| 56 | parser.add_argument( |
| 57 | "-c", |
| 58 | metavar="CODE", |
| 59 | default=None, |
| 60 | type=str, |
| 61 | help="type check Python code fragment instead of mypy self-check", |
| 62 | ) |
| 63 | args = parser.parse_args() |
| 64 | multi_file: bool = args.multi_file |
| 65 | skip_compile: bool = args.skip_compile |
| 66 | code: str | None = args.c |
| 67 | |
| 68 | target_dir = TARGET_DIR |
| 69 | |
| 70 | if not skip_compile: |
| 71 | clone(target_dir, "HEAD") |
| 72 | |
| 73 | print(f"Building mypy in {target_dir} with trace logging enabled...") |
| 74 | build_mypy(target_dir, multi_file, log_trace=True, opt_level="0") |
| 75 | elif not os.path.isdir(target_dir): |
| 76 | sys.exit("error: Can't find compile mypy from previous run -- can't use --skip-compile") |
| 77 | |
| 78 | perform_type_check(target_dir, code) |
| 79 | |
| 80 | trace_fnam = os.path.join(target_dir, "mypyc_trace.txt") |
| 81 | print(f"Generated event trace log in {trace_fnam}") |
| 82 | |
| 83 | |
| 84 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…