astral-sh/ruff-vscode

Modifying the `Ruff: Exclude` settings overrides any exclusions in ruff.toml

hjhicks opened this issue · 3 comments

Environment:
OS: Windows 10
Python version: 3.11.6
Ruff version: 0.5.5
Extension version: v2024.36.0

It appears that when I try to exclude a file or directory through the extension (using Ruff:Exclude), Ruff forgets about anything that was excluded in ruff.toml. See below:

Contents of ruff.toml:

exclude = ["excluded_in_config.py"]

line-length = 10

[lint]
select = ["E"]
ignore = []

[format]
quote-style = "single"

indent-style = "space"

Contents of both excluded_in_config.py and excluded_in_extension.py:

def this_will_be_too_long():
    pass

Steps to reproduce:

  1. Create ruff.toml, excluded_in_config.py, and excluded_in_extension.py using the above code snippets
  2. In extension settings, set Ruff:Configuration to use ruff.toml. Notice that excluded_in_config.py has been properly excluded while Ruff notes a problem in excluded_in_extension.py.
  3. Add excluded_in_extension.py to Ruff:Exclude. Notice that now, excluded_in_extension.py has properly been excluded but excluded_in_config.py now has errors according to Ruff, despite it being excluded in ruff.toml. This occurs with anything that is excluded in ruff.toml.

Is the Ruff:Exclude setting intended to override any excludes in ruff.toml?

Hey, thanks for providing all the details.

Is the Ruff:Exclude setting intended to override any excludes in ruff.toml?

Yes, that's the semantics of the exclude setting. If you'd like to extend it, you need to use extend-exclude in your ruff.toml file.

Oh, I see. I didn't know about extend-exclude. Using that in my ruff.toml file has solved the issue. Sorry for the trouble and thanks for the help!

No worries, happy to help :)