astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.41k stars 1.08k forks source link

Missing config option for `extend_external` #11921

Open jvacek opened 4 months ago

jvacek commented 4 months ago

I have two configs, base.toml that is shared for multiple projects, and my in-project pyproject.toml that extends the one above.

It would be nice if the external could also be extended, much like select and ignore.

MichaReiser commented 4 months ago

I can see how this is useful. I'm personally hesitant to add new extend- settings because we ultimately would need to add a extend variant for any list setting. An alternative solution would be to make external a table.

[ruff.lint.external]
V = "Explanation where the rule comes from"
jvacek commented 4 months ago

Going for a table would be quite a deviation from the way the other "rule-selector" options behave in my opinion.

IF the greater issue is that adding extends would be hard to apply across the board, An alternative might be to go for sections like [ruff.extends] and [ruff.lint.extend] etc., which would then just contain select = [] etc. Might be easier to see what is being set/overwritten, and what is being extended.

I'm sure this opens up a whole other can of worms for making sure that all sections can extend and how to deal with non-list values, which might just mean that adding the variant to all list settings might make more sense.

charliermarsh commented 4 months ago

I'm personally fine with supporting it, but somewhat low priority (PR welcome).