code: def format_file(filename, args, standard_out):
      
      encoding = detect_encoding(filename)
      with open_with_encoding(filename, encoding=encoding) as input_file:
          source = input_file.read()
          formatted_source = format_code(
              source,
              preferred_quote=args.quote)
  
      if source != formatted_source:
          if args.in_place:
              with open_with_encoding(filename, mode='w',
                                      encoding=encoding) as output_file:
                  output_file.write(formatted_source)
          else:
              import difflib
              diff = difflib.unified_diff(
                  source.splitlines(),
                  formatted_source.splitlines(),
                  'before/' + filename,
                  'after/' + filename,
                  lineterm='')
              standard_out.write('\n'.join(list(diff) + ['']))
  
              return True
docs: Run format_code() on a file.
  
      Returns `True` if any changes are needed and they are not being done
      in-place.