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

Method on_file

mypy/report.py:420–441  ·  view source on GitHub ↗
(
        self,
        tree: MypyFile,
        modules: dict[str, MypyFile],
        type_map: dict[Expression, Type],
        options: Options,
    )

Source from the content-addressed store, hash-verified

418 self.lines_covered: dict[str, list[int]] = {}
419
420 def on_file(
421 self,
422 tree: MypyFile,
423 modules: dict[str, MypyFile],
424 type_map: dict[Expression, Type],
425 options: Options,
426 ) -> None:
427 if os.path.isdir(tree.path): # can happen with namespace packages
428 return
429
430 with open(tree.path) as f:
431 tree_source = f.readlines()
432
433 coverage_visitor = LineCoverageVisitor(tree_source)
434 tree.accept(coverage_visitor)
435
436 covered_lines = []
437 for line_number, (_, typed) in enumerate(coverage_visitor.lines_covered):
438 if typed:
439 covered_lines.append(line_number + 1)
440
441 self.lines_covered[os.path.abspath(tree.path)] = covered_lines
442
443 def on_finish(self) -> None:
444 with open(os.path.join(self.output_dir, "coverage.json"), "w") as f:

Callers

nothing calls this directly

Calls 6

LineCoverageVisitorClass · 0.85
enumerateFunction · 0.85
readlinesMethod · 0.80
appendMethod · 0.80
isdirMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected