pylint/checkers/format.py
def _get_indent_hint_line(bar_positions, bad_position):
    """Return a line with |s for each of the positions in the given lists."""
    if not bar_positions:
        return ("", "")
    # TODO tabs should not be replaced by some random (8) number of spaces
    bar_positions = [_get_indent_length(indent) for indent in bar_positions]
    bad_position = _get_indent_length(bad_position)
    delta_message = ""
    markers = [(pos, "|") for pos in bar_positions]
    if len(markers) == 1:
        # if we have only one marker we'll provide an extra hint on how to fix
        expected_position = markers[0][0]
        delta = abs(expected_position - bad_position)
        direction = "add" if expected_position > bad_position else "remove"
        delta_message = _CONTINUATION_HINT_MESSAGE % (
            direction,
            delta,
            "s" if delta > 1 else "",
        )
    markers.append((bad_position, "^"))
    markers.sort()
    line = [" "] * (markers[-1][0] + 1)
    for position, marker in markers:
        line[position] = marker
    return ("".join(line), delta_message)
def _get_indent_hint_line(bar_positions, bad_position):
    if not bar_positions:
        return ("", "")
    # TODO tabs should not be replaced by some random (8) number of spaces
    bar_positions = [_get_indent_length(indent) for indent in bar_positions]
    bad_position = _get_indent_length(bad_position)
    delta_message = ""
    markers = [(pos, "|") for pos in bar_positions]
    if len(markers) == 1:
        # if we have only one marker we'll provide an extra hint on how to fix
        expected_position = markers[0][0]
        delta = abs(expected_position - bad_position)
        direction = "add" if expected_position > bad_position else "remove"
        delta_message = _CONTINUATION_HINT_MESSAGE % (
            direction,
            delta,
            "s" if delta > 1 else "",
        )
    markers.append((bad_position, "^"))
    markers.sort()
    line = [" "] * (markers[-1][0] + 1)
    for position, marker in markers:
        line[position] = marker
    return ("".join(line), delta_message)
def _get_indent_hint_line ( bar_positions , bad_position ) : if not bar_positions : return ( "" , "" ) # TODO tabs should not be replaced by some random (8) number of spaces bar_positions = [ _get_indent_length ( indent ) for indent in bar_positions ] bad_position = _get_indent_length ( bad_position ) delta_message = "" markers = [ ( pos , "|" ) for pos in bar_positions ] if len ( markers ) == 1 : # if we have only one marker we'll provide an extra hint on how to fix expected_position = markers [ 0 ] [ 0 ] delta = abs ( expected_position - bad_position ) direction = "add" if expected_position > bad_position else "remove" delta_message = _CONTINUATION_HINT_MESSAGE % ( direction , delta , "s" if delta > 1 else "" , ) markers . append ( ( bad_position , "^" ) ) markers . sort ( ) line = [ " " ] * ( markers [ - 1 ] [ 0 ] + 1 ) for position , marker in markers : line [ position ] = marker return ( "" . join ( line ) , delta_message )
Return a line with |s for each of the positions in the given lists.
Return a line with |s for each of the positions in the given lists .