-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please consider changing configuration merging semantics #8751
Comments
Hi. Would you mind expanding your example a bit more to elucidate your point? I'm having a hard time following your problem. |
I'm using |
Configuration extension is not merely a merge of the Instead, the semantics are such that we treat each configuration source as a layer (starting with the root configuration file, then the file that As a concrete example, if your configuration file contains If you "just" merge the keys, you introduce some confusing problems. For example, if the configuration file that you extend has The problem here IMO is that in the issue as written, |
I'm okay with closing this in favor of #8737 |
I'm sorry but I have to reopen this because I would like to get others' feedback. I ran into another case of really unexpected behavior as follows. User config: extend = "C:\\Users\\ofek\\AppData\\Local\\hatch\\env\\.internal\\fmt\\eof-W-rA\\ruff_defaults.toml"
[lint]
preview = true
[format]
preview = true My config: [lint]
select = [
...
] Running Ruff without arguments does not enable preview mode even though that is enabled in the target config. I hear you when you say that this was partially a deliberate choice but please understand that I simply cannot comprehend how config is merged and I'm not exactly a new engineer. |
I just tested this locally and it does work for me. I have [lint]
select = ["PIE"] And then extend = "base.toml"
[lint]
preview = true
[format]
preview = true Given def func():
x = 1
pass
def func():
x = 1
... Running: ❯ ruff check foo.py -n
foo.py:6:5: PIE790 [*] Unnecessary `pass` statement
foo.py:11:5: PIE790 [*] Unnecessary `...` literal The latter violation is preview-only. And if I remove ❯ ruff check foo.py -n
foo.py:6:5: PIE790 [*] Unnecessary `pass` statement
Found 1 error.
[*] 1 fixable with the `--fix` option. I then did the same thing with def func():
import os Which triggers ❯ ruff check foo.py -n
foo.py:2:5: PLC0415 `import` should be at the top-level of a file
Found 1 error. And again, if I remove Can you provide more information on how you've determined that "Running Ruff without arguments does not enable preview mode even though that is enabled in the target config"? |
This was user error from passing the wrong config file path on the command line, sorry for the noise! |
I am trying to integrate with Ruff by having a default config that extends the user's config:
I want to provide the base selection and per-file ignored rules which the user can then modify by ignoring with
ignore
, selecting more rules withextend-select
, and adding additional per-file ignored rules withextend-per-file-ignores
.Currently, the
ignore
that they define in their file has absolutely no effect. I think this is extremely unexpected and I would argue wrong behavior. It would make more sense from a UX perspective to treat merging as simply a data structure-level operation that only acts upon keys, nothing else, no other logic.I don't know how I would integrate with this limitation.
The text was updated successfully, but these errors were encountered: