Skip to content
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

[Tracking PR] feat: rewrite most style linters in Lean #13199

Draft
wants to merge 64 commits into
base: master
Choose a base branch
from

Conversation

grunweg
Copy link
Collaborator

@grunweg grunweg commented May 25, 2024

This is tracking PR for rewriting most linters in lint-style.py in Lean.


Steps for landing this:

Open in Gitpod

grunweg added 19 commits May 25, 2024 09:53
Unlike the Python version, this script also supports set_option tactics
and terms.
…r imports work; copyright header in progress.

Missing: printing right errors, because of monadology.
Also: need to register as linters somewhere... or figure out how to disable?
…eels clearer to me. Open to golfing that down :-)
Untested, as of now: will come next.
Isolated by's are still missing, and testing all of them!
@grunweg grunweg added t-linter Linter tech debt Tracking cross-cutting technical debt, see e.g. the "Technical debt counters" stream on zulip labels May 25, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) label May 25, 2024
Careful: Lean's FS.lines methods yields lines without trailing newline;
I am not sure what this does to windows line endings. Need to check carefully!
@grunweg grunweg force-pushed the MR-rewrite-more-style-linters branch from d61b18a to 18e9c21 Compare May 25, 2024 11:45
@grunweg
Copy link
Collaborator Author

grunweg commented May 26, 2024

I filed #13240 for rewriting the copyright check.

avoiding some array-to-list conversion.
The current implementation is too slow, though --- is this the process spawning?
…enough.

I'm passing all files as command line arguments: this is not how you're
supposed to do it, but as a stop-gap measure, this is fine.
@grunweg
Copy link
Collaborator Author

grunweg commented May 26, 2024

As a way to roll this out, I have rewritten update_style_exceptions.sh as a Lean executable: this allows both linters to co-exist.

Running all linters so far on all of mathlib runs in 1-2 seconds.
(The Python script took 10, for the linters ported so far.)
@grunweg
Copy link
Collaborator Author

grunweg commented May 26, 2024

Compiling the linter to an executable makes it much faster: now it's an order of magnitude faster than the Python linter.

@grunweg grunweg changed the title wip: rewrite most style linters in Lean [Tracking PR] feat: rewrite most style linters in Lean May 29, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 31, 2024
callesonne pushed a commit that referenced this pull request Jun 4, 2024
Discovered when tweaking the rewritten style linter in #13199.
callesonne pushed a commit that referenced this pull request Jun 4, 2024
Re-implementing the copyright header linter in #13199, I made the checker stricter in a few places. This was not intentional, but happened since I wasn't aiming at bug-for-bug compatibility: the old algorithm feels somewhat complicated for me.

This led me to perform a few normalisations on the existing copyright headers: let me know if these are desired or not
- normalise the copyright symbol in the first line (a few files had a different one)
- add a dot in before the "All rights reserved" (again, only a few different ones)
- three manual tweaks
js2357 pushed a commit that referenced this pull request Jun 18, 2024
Discovered when tweaking the rewritten style linter in #13199.
js2357 pushed a commit that referenced this pull request Jun 18, 2024
Re-implementing the copyright header linter in #13199, I made the checker stricter in a few places. This was not intentional, but happened since I wasn't aiming at bug-for-bug compatibility: the old algorithm feels somewhat complicated for me.

This led me to perform a few normalisations on the existing copyright headers: let me know if these are desired or not
- normalise the copyright symbol in the first line (a few files had a different one)
- add a dot in before the "All rights reserved" (again, only a few different ones)
- three manual tweaks
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) label Jun 30, 2024
@joneugster joneugster added the WIP Work in progress label Sep 12, 2024
@joneugster joneugster marked this pull request as draft September 12, 2024 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-linter Linter tech debt Tracking cross-cutting technical debt, see e.g. the "Technical debt counters" stream on zulip WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants