Zulip Chat Archive

Stream: general

Topic: Mathlib linters in downstream projects


Damiano Testa (Apr 26 2025 at 16:54):

Mathlib defines several linters and tries to be mindful of which ones are on both in mathlib and downstream, and which ones are on in mathlib and off downstream.

Damiano Testa (Apr 26 2025 at 16:54):

However, some projects may want to align with mathlib's choices by default, without having to track closely changes to mathlib and updating their lakefiles continuously.

Damiano Testa (Apr 26 2025 at 16:54):

Should there be an option like Mathlib.linter.all which, when true, means that all the linters that are on in mathlib are automatically on downstream? This would mean adding a single (weak) option to the lakefile of downstream projects and then all the mathlib linters are active.

Kevin Buzzard (Apr 26 2025 at 16:56):

That would suit me fine! I find myself adding mathlib linters bit by bit. Presumably I'd be able to do "all mathlib linters apart from these two"?

Damiano Testa (Apr 26 2025 at 16:57):

I would have to think about how overriding works, but of course it is something desirable.

Damiano Testa (Apr 26 2025 at 16:57):

(And it is your FLT stream where this has come up most recently!)

Damiano Testa (Apr 26 2025 at 16:59):

So, basically there should be mechanism that allows to say "all linters except...". Right now you can only do "no linters, except...".

Damiano Testa (Apr 26 2025 at 17:02):

Having such a mechanism would be useful for all repositories that are developing material with the idea of upstreaming to mathlib.

Anne Baanen (Apr 28 2025 at 14:22):

Damiano Testa said:

Should there be an option like Mathlib.linter.all which, when true, means that all the linters that are on in mathlib are automatically on downstream? This would mean adding a single (weak) option to the lakefile of downstream projects and then all the mathlib linters are active.

Good news! lean4#8106 is intended to make exactly this possible!

Anne Baanen (Apr 28 2025 at 14:26):

The way linters are checked currently, explicitly set individual linter options have highest priority, then linter.all, then the option default value. So you can enable or disable all linters at once using set_option linter.all false, then dis/enable specific ones with set_option linter.myFavouriteLinter true.

Michael Rothgang (Apr 28 2025 at 14:30):

This is great; the code looks basically good to me. (See github for my detailed comments.)


Last updated: May 02 2025 at 03:31 UTC