code: def process_file(filename, config):
      logger.debug("Check %s", filename)
  
      report = black.report.Report(
          check=True,
          quiet=True,
      )
      mode = black.Mode(
          line_length=config.get("line_length"),
          string_normalization=not config.get(
              "skip_string_normalization"
          ),
      )
      wr_back_without_diff = black.WriteBack.from_configuration(
          check=True, diff=False
      )
      # Fast path for runs with fix_style option or without errors.
      error_msg = run_black_safe(
          filename, wr_back_without_diff, mode, report
      )
      if report.change_count:
          # black runs 15x+ slower if diff is requested, even for files w/o actual diff.
          # Rerun black in case of found error.
          wr_back_with_diff = black.WriteBack.from_configuration(
              check=True, diff=True
          )
          error_msg = run_black_safe(
              filename, wr_back_with_diff, mode, report
          )
  
      if error_msg:
          sys.stdout.write(console.strip_ansi_codes(error_msg))
          lines = error_msg.split(os.linesep)
          # strip diff header with "+++" "---" lines
          lines = lines[2:]
          if len(lines) > SNIPPET_LINES_LIMIT:
              lines = lines[:SNIPPET_LINES_LIMIT]
              lines += [
                  "[[rst]]..[truncated].. see full diff in the stdout file in the logsdir"
              ]
          error_msg = os.linesep.join(lines)
      return error_msg
  
file_path: catboost/tools/black_linter/bin/__main__.py
imports: import contextlib
  import io
  import logging
  import os
  import sys
  import time
  from pathlib import Path
  import yalibrary.term.console
  from library.python.testing.custom_linter_util import linter_params, reporter
  import black
  import black.files
  import black.report
  import black.mode
label_desc: Use image node_id 4 for calling a global function with example usage: process_file(filename, config) and returns: error_msg