MCPcopy Create free account
hub / github.com/catboost/catboost / process_file

Function process_file

tools/black_linter/wrapper.py:44–65  ·  view source on GitHub ↗
(black_bin, filename, config)

Source from the content-addressed store, hash-verified

42
43
44def process_file(black_bin, filename, config):
45 logger.debug("Check %s", filename)
46 args = ['--quiet', '--check', '--config', config]
47
48 # Fast path for runs with fix_style option or without errors.
49 rc, out = run_black_safe(black_bin, filename, args)
50 if rc == 1:
51 # black runs 15x+ slower if diff is requested, even for files w/o actual diff.
52 # Rerun black in case of found error.
53 rc, out = run_black_safe(black_bin, filename, args + ['--diff'])
54
55 if out:
56 sys.stdout.write(out)
57 lines = out.splitlines(keepends=True)
58 # strip diff header with "+++" "---" lines
59 lines = lines[2:]
60 if len(lines) > SNIPPET_LINES_LIMIT:
61 lines = lines[:SNIPPET_LINES_LIMIT]
62 lines += ["[[rst]]..[truncated].. see full diff in the stdout file in the logsdir"]
63 out = ''.join(lines)
64
65 return out
66
67
68def main():

Callers 1

mainFunction · 0.70

Calls 5

run_black_safeFunction · 0.85
lenFunction · 0.85
debugMethod · 0.45
writeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected