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

Function generate_annotations

mypyc/annotate.py:166–179  ·  view source on GitHub ↗
(
    path: str, tree: MypyFile, ir: ModuleIR, type_map: dict[Expression, Type], mapper: Mapper
)

Source from the content-addressed store, hash-verified

164
165
166def generate_annotations(
167 path: str, tree: MypyFile, ir: ModuleIR, type_map: dict[Expression, Type], mapper: Mapper
168) -> AnnotatedSource:
169 anns = {}
170 for func_ir in ir.functions:
171 anns.update(function_annotations(func_ir, tree))
172 visitor = ASTAnnotateVisitor(type_map, mapper)
173 for defn in tree.defs:
174 defn.accept(visitor)
175 anns.update(visitor.anns)
176 for line in visitor.ignored_lines:
177 if line in anns:
178 del anns[line]
179 return AnnotatedSource(path, anns)
180
181
182def function_annotations(func_ir: FuncIR, tree: MypyFile) -> dict[int, list[Annotation]]:

Callers 2

run_caseMethod · 0.90
generate_annotated_htmlFunction · 0.85

Calls 5

function_annotationsFunction · 0.85
ASTAnnotateVisitorClass · 0.85
AnnotatedSourceClass · 0.85
updateMethod · 0.45
acceptMethod · 0.45

Tested by 1

run_caseMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…