MCPcopy Index your code
hub / github.com/python/mypy / main

Function main

misc/find_type.py:71–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70
71def main() -> None:
72 filename, start_line_str, start_col_str, end_line_str, end_col_str, *mypy_and_args = sys.argv[
73 1:
74 ]
75 start_line = int(start_line_str)
76 start_col = int(start_col_str)
77 end_line = int(end_line_str)
78 end_col = int(end_col_str)
79 with open(filename) as f:
80 lines = f.readlines()
81 lines[end_line - 1] = update_line(
82 lines[end_line - 1], REVEAL_TYPE_END, end_col
83 ) # insert after end_col
84 lines[start_line - 1] = update_line(lines[start_line - 1], REVEAL_TYPE_START, start_col)
85 with tempfile.NamedTemporaryFile(mode="w", prefix="mypy") as tmp_f:
86 tmp_f.writelines(lines)
87 tmp_f.flush()
88
89 output = run_mypy(mypy_and_args, filename, tmp_f.name)
90 revealed_type, error = process_output(output, filename, start_line)
91 if revealed_type:
92 print(revealed_type)
93 if error:
94 print(output)
95 exit(int(error))
96
97
98if __name__ == "__main__":

Callers 1

find_type.pyFile · 0.70

Calls 9

intClass · 0.85
update_lineFunction · 0.85
process_outputFunction · 0.85
printFunction · 0.85
exitFunction · 0.85
readlinesMethod · 0.80
writelinesMethod · 0.80
run_mypyFunction · 0.70
flushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…