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

Function generate_html_report

mypyc/annotate.py:434–465  ·  view source on GitHub ↗
(sources: list[AnnotatedSource])

Source from the content-addressed store, hash-verified

432
433
434def generate_html_report(sources: list[AnnotatedSource]) -> str:
435 html = []
436 html.append("<html>\n<head>\n")
437 html.append(f"<style>\n{CSS}\n</style>")
438 html.append("</head>\n")
439 html.append("<body>\n")
440 for src in sources:
441 html.append(f"<h2><tt>{src.path}</tt></h2>\n")
442 html.append("<pre>")
443 src_anns = src.annotations
444 with open(src.path) as f:
445 lines = f.readlines()
446 for i, s in enumerate(lines):
447 s = escape(s)
448 line = i + 1
449 linenum = "%5d" % line
450 if line in src_anns:
451 anns = get_max_prio(src_anns[line])
452 ann_strs = [a.message for a in anns]
453 hint = " ".join(ann_strs)
454 s = colorize_line(linenum, s, hint_html=hint)
455 else:
456 s = linenum + " " + s
457 html.append(s)
458 html.append("</pre>")
459
460 html.append("<script>")
461 html.append(JS)
462 html.append("</script>")
463
464 html.append("</body></html>\n")
465 return "".join(html)
466
467
468def colorize_line(linenum: str, s: str, hint_html: str) -> str:

Callers 1

generate_annotated_htmlFunction · 0.85

Calls 6

enumerateFunction · 0.85
get_max_prioFunction · 0.85
colorize_lineFunction · 0.85
appendMethod · 0.80
readlinesMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…