def format_comment(comment_data):
    """Formats the data returned by the linters.

    Given a dictionary with the fields: line, column, severity, message_id,
    message, will generate a message like:

    'line {line}, col {column}: {severity}: [{message_id}]: {message}'

    Any of the fields may nbe absent.

    Args:
      comment_data: dictionary with the linter data.

    Returns:
      a string with the formatted message.
    """
    format_pieces = []
    # Line and column information
    if 'line' in comment_data:
        format_pieces.append('line {line}')
    if 'column' in comment_data:
        if format_pieces:
            format_pieces.append(', ')
        format_pieces.append('col {column}')
    if format_pieces:
        format_pieces.append(': ')

    # Severity and Id information
    if 'severity' in comment_data:
        format_pieces.append('{severity}: ')

    if 'message_id' in comment_data:
        format_pieces.append('[{message_id}]: ')

    # The message
    if 'message' in comment_data:
        format_pieces.append('{message}')

    return ''.join(format_pieces).format(**comment_data)