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

--no-force-exclude is ignored

mounirmesselmeni opened this issue · comments

I was trying to pass --no-force-exclude to Ruff format but it seems to be ignored.

image

Output from the extension:

Running Ruff with: /home/app/venv/bin/ruff ['format', '--force-exclude', '--quiet', '--stdin-filename', '/app/core/migrations/0011_populate_something.py']

Use case:
I wanted to be able (while generally ignored migrations files), when adding Django migrations by hand, to be able to format them using Ruff.
That was the case with Black and black extension before switching to Ruff, I believe the black extension was ignoring the ignore list.

Hey, this is because it's one of the arguments which isn't supported for the format.args field: https://github.com/astral-sh/ruff-lsp/blob/187d7790be0783b9ac41ce025a724cf389bf575c/ruff_lsp/server.py#L199-L213

Are you not seeing any warnings for it?

I think we could allow --no-force-exclude? It would just mean that all files are formatted regardless of whether they're marked for exclusion (so even, e.g., files in the standard library would get formatted, if you opened them up). Is that what you wanted to achieve?

@dhruvmanila No warnings, only info logs.

@charliermarsh correct, on the other hand, if I open a standard library of third party library in VSCode, modify and save it it might still be okay to have it formatted, that is mainly done for debugging purposes and would be anyway reverted afterwards.

As a user, I would find it annoying to always revert back the change which an extension made. But, I could see us providing an option to do so. (cc @snowsignal something to think on for the config proposal)