astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
1.14k stars 55 forks source link

--no-force-exclude is ignored #414

Open mounirmesselmeni opened 9 months ago

mounirmesselmeni commented 9 months ago

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.

dhruvmanila commented 8 months ago

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?

charliermarsh commented 8 months ago

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?

mounirmesselmeni commented 8 months ago

@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.

dhruvmanila commented 7 months ago

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)

jvacek commented 2 weeks ago

Coming here with this usecase:

I have a ruff config that I'd like to have enforced in CI/CD and with pre-commit, but I'd like to make sure that even files that I've marked as excluded are still within the scope of what the ruff extension in vscode can work with, so I can apply ruff "optionally" on these files.

dhruvmanila commented 2 weeks ago

@jvacek can you try the new native server by setting ruff.nativeServer: "on" (https://docs.astral.sh/ruff/editors/settings/#nativeserver) ? Does that resolve your use-case?

jvacek commented 2 weeks ago

Under native server, I don't see the intended behaviour either. It seems that the exclude is still being applied.

dhruvmanila commented 2 weeks ago

@jvacek Can you provide a way for us to reproduce (Ruff and VS Code settings, directory structure, etc.) ?