MCPcopy
hub / github.com/psf/black / dump_to_file

Function dump_to_file

src/black/output.py:113–122  ·  src/black/output.py::dump_to_file

Dump `output` to a temporary file. Return path to the file.

(*output: str, ensure_final_newline: bool = True)

Source from the content-addressed store, hash-verified

111
112@mypyc_attr(patchable=True)
113def dump_to_file(*output: str, ensure_final_newline: bool = True) -> str:
114 class="st">""class="st">"Dump `output` to a temporary file. Return path to the file."class="st">""
115 with tempfile.NamedTemporaryFile(
116 mode=class="st">"w", prefix=class="st">"blk_", suffix=class="st">".log", delete=False, encoding=class="st">"utf8"
117 ) as f:
118 for lines in output:
119 f.write(lines)
120 if ensure_final_newline and lines and lines[-1] != class="st">"\n":
121 f.write(class="st">"\n")
122 return f.name

Callers 2

assert_equivalentFunction · 0.90
assert_stableFunction · 0.90

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected