MCPcopy
hub / github.com/django/django / run_formatters

Function run_formatters

django/core/management/utils.py:166–181  ·  view source on GitHub ↗

Run the black formatter on the specified files.

(written_files, black_path=(sentinel := object()), stderr=sys.stderr)

Source from the content-addressed store, hash-verified

164
165
166def run_formatters(written_files, black_path=(sentinel := object()), stderr=sys.stderr):
167 """
168 Run the black formatter on the specified files.
169 """
170 # Use a sentinel rather than None, as which() returns None when not found.
171 if black_path is sentinel:
172 black_path = shutil.which("black")
173 if black_path:
174 try:
175 subprocess.run(
176 [black_path, "--fast", "--", *written_files],
177 capture_output=True,
178 )
179 except OSError:
180 stderr.write("Formatters failed to launch:")
181 traceback.print_exc(file=stderr)

Callers 6

handleMethod · 0.90
handleMethod · 0.90
write_migration_filesMethod · 0.90
handle_mergeMethod · 0.90
handleMethod · 0.90

Calls 2

runMethod · 0.45
writeMethod · 0.45