ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Lint when line characters are higher than maximum

Open DataHearth opened this issue 2 years ago • 3 comments

Hey!

I'm now fully using ruff in my python projects as linter and try to integrate it everywhere in my client's projects. Works like a charm and it's fast!

I'm still using black as linter sometime because I need to format a line which exceeds the maximum line length. Unfortunately ruff doesn't not have this type of linting outside of the warning.

Is this a planned feature ? I can land a hand to implement this feature if it's interesting for the ruff project 👍.

Thanks for you awesome work!

DataHearth avatar Dec 22 '22 14:12 DataHearth

Hey, thank you! Are you referring to the ability to reformat lines, in the event that they exceed the maximum line length?

charliermarsh avatar Dec 23 '22 03:12 charliermarsh

exactly, here's an example with black formatting long lines:

def func():
    print("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")

then

def func():
    print(
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
    )

The text itself has a linebreak after the first parenthesis and before the last one after linting. It is not the best example, I don't have a clean project rn to demonstrate it :). To resume, when line_length > max_line_length => format the line to be shorter (multiple lines, etc).

DataHearth avatar Dec 23 '22 08:12 DataHearth

+1 on this.

nefrob avatar Dec 30 '22 16:12 nefrob

I do want to support this! But it requires expanding Ruff into a full autoformatter. Which is in-scope, but larger than a single Issue.

charliermarsh avatar Dec 30 '22 18:12 charliermarsh

@charliermarsh is there already an epic issue for this topic ? If you need help on this, I can land a hand 🙂

DataHearth avatar Dec 30 '22 22:12 DataHearth

Closing for now in favor of #1904!

charliermarsh avatar Jan 16 '23 19:01 charliermarsh