MCPcopy Create free account
hub / github.com/python/mypy / on_file

Method on_file

mypy/report.py:224–246  ·  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

222 self.any_types_counter: dict[str, collections.Counter[int]] = {}
223
224 def on_file(
225 self,
226 tree: MypyFile,
227 modules: dict[str, MypyFile],
228 type_map: dict[Expression, Type],
229 options: Options,
230 ) -> None:
231 visitor = stats.StatisticsVisitor(
232 inferred=True,
233 filename=tree.fullname,
234 modules=modules,
235 typemap=type_map,
236 all_nodes=True,
237 visit_untyped_defs=False,
238 )
239 tree.accept(visitor)
240 self.any_types_counter[tree.fullname] = visitor.type_of_any_counter
241 num_unanalyzed_lines = list(visitor.line_map.values()).count(stats.TYPE_UNANALYZED)
242 # count each line of dead code as one expression of type "Any"
243 num_any = visitor.num_any_exprs + num_unanalyzed_lines
244 num_total = visitor.num_imprecise_exprs + visitor.num_precise_exprs + num_any
245 if num_total > 0:
246 self.counts[tree.fullname] = (num_any, num_total)
247
248 def on_finish(self) -> None:
249 self._report_any_exprs()

Callers

nothing calls this directly

Calls 4

listClass · 0.85
valuesMethod · 0.80
acceptMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected