MCPcopy
hub / github.com/python/mypy / format_func

Function format_func

mypyc/ir/pprint.py:448–464  ·  view source on GitHub ↗
(fn: FuncIR, errors: Sequence[tuple[ErrorSource, str]] = ())

Source from the content-addressed store, hash-verified

446
447
448def format_func(fn: FuncIR, errors: Sequence[tuple[ErrorSource, str]] = ()) -> list[str]:
449 lines = []
450 cls_prefix = fn.class_name + "." if fn.class_name else ""
451 lines.append(
452 "def {}{}({}):".format(cls_prefix, fn.name, ", ".join(arg.name for arg in fn.args))
453 )
454 names = generate_names_for_ir(fn.arg_regs, fn.blocks)
455 for line in format_registers(fn, names):
456 lines.append(" " + line)
457
458 source_to_error = defaultdict(list)
459 for source, error in errors:
460 source_to_error[source].append(error)
461
462 code = format_blocks(fn.blocks, names, source_to_error)
463 lines.extend(code)
464 return lines
465
466
467def format_modules(modules: ModuleIRs) -> list[str]:

Callers 10

run_caseMethod · 0.90
test_pprintMethod · 0.90
run_caseMethod · 0.90
run_caseMethod · 0.90
run_caseMethod · 0.90
run_caseMethod · 0.90
run_caseMethod · 0.90
run_caseMethod · 0.90
assert_func_ir_validFunction · 0.90
format_modulesFunction · 0.85

Calls 7

generate_names_for_irFunction · 0.85
format_registersFunction · 0.85
format_blocksFunction · 0.85
appendMethod · 0.80
extendMethod · 0.80
formatMethod · 0.45
joinMethod · 0.45

Tested by 8

run_caseMethod · 0.72
test_pprintMethod · 0.72
run_caseMethod · 0.72
run_caseMethod · 0.72
run_caseMethod · 0.72
run_caseMethod · 0.72
run_caseMethod · 0.72
run_caseMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…