astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

is --line-length argument working?

BartolomeSintes opened this issue · comments

I am using VSCode 1.85 with Ruff extension updated (0.1.5).
I am trying to set the limit-length argument, but the E501 is not showing.
I think some screenshots will be useful in order to explain the issue:
My program is just two lines: one with an f-string without placeholders (line 2) and another one with a long line (line 3, 135 characters long). The F541 warning is shown as expected:
2023-12-12-1
If I ignore the F541 warning in settings.json, the warning is not shown anymore:
2023-12-12-2
So ruff seems to be working as expected, but the E501 is not shown.
I understand that line length must be set in ruff.lint.args, as explained in astral-sh/ruff#8363
Am I doing something wrong or is it a ruff extension bug?
Thanking you in advance,
Bartolomé Sintes

Sorry for the confusion -- we no longer include E501 in the default rule set, so you need to add --select=E501 or --select=E to your ruff.lint.args.

You can see the default configuration at the top here: https://docs.astral.sh/ruff/configuration/

Thank you for your fast answer. You are completely right.
When I read the pull 8363, "Add --line-length option to format command" I did not realize it was a pull in the ruff repository, not in the ruff-vscode one. I supposed that line-length should be added to the ruff.format.args section, not to the ruff.lint.args as it should. My mistake, sorry.
Keep your very good work!

What's even more confusing to me is running ruff check --line-length 10 my.py doesn't return any errors.

@jmakov -- Per the above, you need to enable the line-length rule -- it's not included by default, since it often conflicts with using a formatter. Can you try adding --extend-select=E to your command and configuration?

@jmakov -- Per the above, you need to enable the line-length rule -- it's not included by default, since it often conflicts with using a formatter. Can you try adding --extend-select=E to your command and configuration?

Thank you for the quick response. Yes, that works. Would expect a flag to overwrite everything when the user uses it. Anyhow, my probl is solved, thanks.