Zulip Chat Archive
Stream: mathlib4
Topic: lint-style for downstream libraries
Yaël Dillies (Feb 04 2025 at 19:25):
I would like to enforce mathlib style in a downstream library. I tried using lake exe lint-style
, but it fails because it hardcodes the name of the sublibraries Archive
and Counterexamples
. Furthermore, it does extra stuff like checking that the files in scripts
are documented and checks that Mathlib.Init
is imported in all files.
Yaël Dillies (Feb 04 2025 at 19:27):
Could we
- move those two extra steps to another executable
- modularise
lint-style
so that it runs on a specific sublibrary?
Yaël Dillies (Feb 04 2025 at 19:48):
Actually, I can't see what lint-style
does apart from those two extra steps?
Michael Rothgang (Feb 04 2025 at 21:20):
lint-style
currently does three things, which are all mentioned in lintStyleCli
:
- run the text-based linters on all
.lean
files (that's thelintModules
) step - check that every file in
scripts
is documented - check that
Mathlib.Init
is imported in all files
Michael Rothgang (Feb 04 2025 at 21:21):
Your request ("give me a way to run lint-style on downstream projects") is a very reasonable one. I agree with making the libraries configurable.
Michael Rothgang (Feb 04 2025 at 21:23):
I'm not sure about moving the extra steps to another executable. I'd prefer one executable lake lint
(which could include runLinter
, the current lint-style
and possibly others, such as shake
) over five different executables.
Michael Rothgang (Feb 04 2025 at 21:25):
I could, however, imagine
- moving those extra checks behind a flag (perhaps
lake exe lint-style --mathlib
enables them --- orlake exe lint-style --downstream
disables them) - actually, perhaps it's nicer to couple that to subdirectories being passed in: if a library is specified which is not mathlib, don't run these checks?
Yaël Dillies (Feb 04 2025 at 21:39):
What bothers me is that nothing in lint-style
says it's coming from mathlib. In fact, I thought for a second it was a core thing
Yaël Dillies (Feb 04 2025 at 21:40):
I am of the opinion that, if a generically-named executable is doing mathlib-specific logic, this logic should be hidden behind a mathlib-named flag. Does that sound reasonable?
Yaël Dillies (Feb 04 2025 at 21:41):
(I doubt lake exe cache get
is currently exactly following this rule, but at least it doesn't seem disastrously so from the user side)
Michael Rothgang (Feb 05 2025 at 15:54):
I had a quick moment on the TGV, and produced #21476. Does that address your use-case/would you like to test on a downstream project?
Michael Rothgang (Feb 05 2025 at 15:55):
TL;DR Run lake exe lint-style Mathlib
or lake exe lint-style
inside mathlib for the usual operations; run lake exe lint-style Carleson
in a project Carleson
depending on mathlib.
Yaël Dillies (Feb 05 2025 at 22:05):
Thanks Michael for the quick ( :high_speed_train:) turnaround! I will have a look tomorrow
Last updated: May 02 2025 at 03:31 UTC