Zulip Chat Archive
Stream: mathlib4
Topic: run linters locally
Newell Jensen (Nov 09 2023 at 21:36):
Is there a way to run (all?) the linters locally? All I currently run locally is ./scripts/lint-style.py <filename>
and wondering if there is something else I can run to better test against linting errors before pushing to github?
David Renshaw (Nov 09 2023 at 21:37):
lake exe runMathlibLinter
David Renshaw (Nov 09 2023 at 21:38):
you can run it on individual files
lake exe runMathlibLinter Mathlib.Algebra.Order.SMul
Newell Jensen (Nov 09 2023 at 21:39):
David Renshaw said:
you can run it on individual files
lake exe runMathlibLinter Mathlib.Algebra.Order.SMul
Perfect thanks!
Newell Jensen (Nov 09 2023 at 21:42):
Hmmm, this doesn't catch the linting error I get from the CI build.
Alex J. Best (Nov 09 2023 at 23:05):
Which error?
Newell Jensen (Nov 09 2023 at 23:33):
Alex J. Best said:
Which error?
https://github.com/leanprover-community/mathlib4/actions/runs/6817820957/job/18542139285?pr=8223
Alex J. Best (Nov 10 2023 at 00:24):
Hmm, that should definitely show up when the linter runs locally on that file, weird
Newell Jensen (Nov 10 2023 at 21:11):
Okay, the issue was I needed to run lake build
before running the linter to get it to work properly.
Jineon Baek (Jul 22 2024 at 04:27):
I wish this info on how to run CI locally is included in how-to documents on contributing to mathlib4. Or does it? I never seen one until I searched this thread
Michael Rothgang (Jul 22 2024 at 09:38):
I agree it would be useful - and a PR adding it would be welcome!
Michael Rothgang (Jul 22 2024 at 09:39):
That said: right now, running all mathlib linters is kind of slow (10 minutes on CI, easily 20 on my computer): there is a linter about all lemmas marked with the @[simp]
attribute having the right shape - and this linter is necessarily global, and takes a while.
Michael Rothgang (Jul 22 2024 at 09:40):
I never run these linters locally, but rely on CI to catch these. There is no expectation that you do so.
Michael Rothgang (Jul 22 2024 at 09:40):
Another option: you can put #lint
at the end of your file, and it will tell you about all linters for the file you're editing. That's usually good enough!
Michael Rothgang (Jul 22 2024 at 09:42):
Let me also add: after a small change (which I intend to PR soon), you will be able to run lake lint filename
instead, and can also select individual linters. No need to memorise runLinter
.
Last updated: May 02 2025 at 03:31 UTC