Skip to content

[Merged by Bors] - chore: import enabled mathlib syntax linters in Mathlib.Init#15845

Closed
grunweg wants to merge 20 commits intomasterfrom
MR-move-linters-up
Closed

[Merged by Bors] - chore: import enabled mathlib syntax linters in Mathlib.Init#15845
grunweg wants to merge 20 commits intomasterfrom
MR-move-linters-up

Conversation

@grunweg
Copy link
Copy Markdown
Contributor

@grunweg grunweg commented Aug 15, 2024

These linters are meant to run on all of mathlib, but they need to be imported in order to run on a given file.
Hence, move them to Mathlib.Init, which has precisely this purpose.

All linters moved in this PR are syntax linters (which need to be imported to run) which are enabled by default.
Linters missing from this list include

  • Linter/Textbased (which is not syntax-based)
  • Linter/MinImports (which is off by default)
  • Linter/HaveLet (which is disabled right now)

All linters only have imports in Lean, except for Linter/Lint (which imports Batteries.Tactic.Lint to define an environment linter). This import could be avoided by splitting the environment linters into a different file; there is no need to import these syntax linters this early.


semorrison indicated that these linters are fine to import for now.

Follow-up clean-ups, out of scope of this PR

  • write a linter to ensure Mathlib.Init is actually imported in every file
  • remove the text-based line length linter (which is now duplicate)
  • adapt the in-flight PR for the file length linter

Open in Gitpod

@grunweg grunweg added RFC Request for comment t-linter Linter labels Aug 15, 2024
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 15, 2024

PR summary 7fb2b66537

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Util.SleepHeartbeats 2 12 +10 (+500.00%)
Mathlib.Tactic.Linter.HashCommandLinter 4 2 -2 (-50.00%)
Mathlib.Tactic.Linter.Lint 4 2 -2 (-50.00%)
Mathlib.Tactic.Linter.UnusedTactic 4 2 -2 (-50.00%)
Mathlib.Tactic.Linter.GlobalAttributeIn 3 2 -1 (-33.33%)
Mathlib.Tactic.Linter.OldObtain 3 2 -1 (-33.33%)
Mathlib.Tactic.Linter.RefineLinter 3 2 -1 (-33.33%)
Mathlib.Tactic.Linter.Style 3 2 -1 (-33.33%)
Mathlib.Tactic.Linter 15 19 +4 (+26.67%)
Mathlib.Tactic.Subsingleton 50 57 +7 (+14.00%)
Import changes for all files
Files Import difference
There are 4707 files with changed transitive imports taking up over 192447 characters: this is too many to display!
You can run scripts/import_trans_difference.sh all locally to see the whole output.

Declarations diff

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.

@grunweg grunweg changed the title Mr move linters up RFC/chore: import enabled mathlib syntax linters in Mathlib.Init Aug 15, 2024
@ghost ghost added blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) labels Aug 15, 2024
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 15, 2024
@grunweg grunweg force-pushed the MR-move-linters-up branch from e047aa9 to 4533aff Compare August 15, 2024 18:28
@grunweg grunweg removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 15, 2024
@grunweg grunweg force-pushed the MR-move-linters-up branch from 4533aff to ee33037 Compare August 15, 2024 19:03
@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Aug 15, 2024

I pushed a commit fixing almost all tests. tests/MinImports.lean needs more careful thought. @adomani Do you have a moment to take a look?

@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Aug 15, 2024

!bench

@adomani
Copy link
Copy Markdown
Contributor

adomani commented Aug 15, 2024

I'm not at a computer, but is the error just some whitespace noise? I'm only going by what I can see in the CI report, though.

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 3f6f538.
There were no significant changes against commit 5b6785c.

@adomani
Copy link
Copy Markdown
Contributor

adomani commented Aug 15, 2024

Michael, thank you very much for using the file already!

I took the liberty of fixing the failing MinImports test and, while I was at it, I also reduced the imports in the remaining linters.

I think that all transitive imports are acceptable now, but let's see what the others think about it!

@adomani
Copy link
Copy Markdown
Contributor

adomani commented Aug 15, 2024

By the way, I am not completely sure about what changed with MinImports, but it is something that I had observed before. I think that there are two paths to make the syntax typecheck and Lean genuinely uses one or the other depending on what is available. I do not know why Lean now prefers the "shorter" path, but I would not worry about it too much.

@adomani
Copy link
Copy Markdown
Contributor

adomani commented Aug 16, 2024

Oops, I merged master by mistake, sorry!

By the way, I think that back-porting all the linting changes would be welcome!

@grunweg grunweg force-pushed the MR-move-linters-up branch from ceb84d4 to 9df35cf Compare August 16, 2024 08:44
grunweg added a commit that referenced this pull request Aug 16, 2024
Fix mathlib for running the missingEnd linter everywhere.
Prerequiste to #15845.
@grunweg grunweg force-pushed the MR-move-linters-up branch from 9df35cf to d8a7d6c Compare August 16, 2024 08:51
@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Aug 16, 2024

Thanks for quickly fixing the test, and tweaking the linters. I just filed #15868 and (edit: changed) #15872 for backporting the linter fixes.

@ghost ghost added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Aug 16, 2024
@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Aug 16, 2024

I have added a comment inlining Mathlib.Tactic.Linter: it only contained a single import now, and was only meaningfully imported in Mathlib.Tactic.Common. (And, to be honest, I'm not convinced importing it in Tactic.Basic is not a better choice... but that's for another thread.)

grunweg added a commit that referenced this pull request Aug 16, 2024
Fix long lines, remove unused tactics and add missing end.
The remaining changes are silencing linters, which cannot be backported.
Split out from #15845.
@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Aug 28, 2024
@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Aug 28, 2024

CI passes now 🎉

@kim-em
Copy link
Copy Markdown
Contributor

kim-em commented Aug 29, 2024

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Aug 29, 2024
mathlib-bors bot pushed a commit that referenced this pull request Aug 29, 2024
These linters are meant to run on all of mathlib, but they need to be imported in order to run on a given file.
Hence, move them to `Mathlib.Init`, which has precisely this purpose.

All linters moved in this PR are syntax linters (which need to be imported to run) which are enabled by default.
Linters missing from this list include
- Linter/Textbased (which is not syntax-based)
- Linter/MinImports (which is off by default)
- Linter/HaveLet (which is disabled right now)

All linters only have imports in `Lean`, except for `Linter/Lint` (which imports `Batteries.Tactic.Lint` to define an environment linter). This import could be avoided by splitting the environment linters into a different file; there is no need to import these syntax linters this early.



Co-authored-by: adomani <adomani@gmail.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 29, 2024

Build failed:

  • Build

@bryangingechen bryangingechen removed the ready-to-merge This PR has been sent to bors. label Aug 29, 2024
@bryangingechen
Copy link
Copy Markdown
Contributor

Looks like it needs another merge with master
bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 29, 2024

✌️ grunweg can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Aug 29, 2024
@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Aug 29, 2024

All CI steps pass (except linting, which passed in the previous commit). Thanks for the review!
bors merge

mathlib-bors bot pushed a commit that referenced this pull request Aug 29, 2024
These linters are meant to run on all of mathlib, but they need to be imported in order to run on a given file.
Hence, move them to `Mathlib.Init`, which has precisely this purpose.

All linters moved in this PR are syntax linters (which need to be imported to run) which are enabled by default.
Linters missing from this list include
- Linter/Textbased (which is not syntax-based)
- Linter/MinImports (which is off by default)
- Linter/HaveLet (which is disabled right now)

All linters only have imports in `Lean`, except for `Linter/Lint` (which imports `Batteries.Tactic.Lint` to define an environment linter). This import could be avoided by splitting the environment linters into a different file; there is no need to import these syntax linters this early.



Co-authored-by: adomani <adomani@gmail.com>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Aug 29, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title chore: import enabled mathlib syntax linters in Mathlib.Init [Merged by Bors] - chore: import enabled mathlib syntax linters in Mathlib.Init Aug 29, 2024
@mathlib-bors mathlib-bors bot closed this Aug 29, 2024
@mathlib-bors mathlib-bors bot deleted the MR-move-linters-up branch August 29, 2024 16:16
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
Fix mathlib for running the missingEnd linter everywhere. Prerequiste to #15845.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
Fix long lines, remove unused tactics and add missing end commands.
The remaining changes are silencing linters in `tests`, which cannot be backported. Split out from #15845.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
These linters are meant to run on all of mathlib, but they need to be imported in order to run on a given file.
Hence, move them to `Mathlib.Init`, which has precisely this purpose.

All linters moved in this PR are syntax linters (which need to be imported to run) which are enabled by default.
Linters missing from this list include
- Linter/Textbased (which is not syntax-based)
- Linter/MinImports (which is off by default)
- Linter/HaveLet (which is disabled right now)

All linters only have imports in `Lean`, except for `Linter/Lint` (which imports `Batteries.Tactic.Lint` to define an environment linter). This import could be avoided by splitting the environment linters into a different file; there is no need to import these syntax linters this early.



Co-authored-by: adomani <adomani@gmail.com>
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
Fix mathlib for running the missingEnd linter everywhere. Prerequiste to #15845.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
Fix long lines, remove unused tactics and add missing end commands.
The remaining changes are silencing linters in `tests`, which cannot be backported. Split out from #15845.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
These linters are meant to run on all of mathlib, but they need to be imported in order to run on a given file.
Hence, move them to `Mathlib.Init`, which has precisely this purpose.

All linters moved in this PR are syntax linters (which need to be imported to run) which are enabled by default.
Linters missing from this list include
- Linter/Textbased (which is not syntax-based)
- Linter/MinImports (which is off by default)
- Linter/HaveLet (which is disabled right now)

All linters only have imports in `Lean`, except for `Linter/Lint` (which imports `Batteries.Tactic.Lint` to define an environment linter). This import could be avoided by splitting the environment linters into a different file; there is no need to import these syntax linters this early.



Co-authored-by: adomani <adomani@gmail.com>
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 12, 2024
Fix mathlib for running the missingEnd linter everywhere. Prerequiste to #15845.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 12, 2024
Fix long lines, remove unused tactics and add missing end commands.
The remaining changes are silencing linters in `tests`, which cannot be backported. Split out from #15845.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 12, 2024
These linters are meant to run on all of mathlib, but they need to be imported in order to run on a given file.
Hence, move them to `Mathlib.Init`, which has precisely this purpose.

All linters moved in this PR are syntax linters (which need to be imported to run) which are enabled by default.
Linters missing from this list include
- Linter/Textbased (which is not syntax-based)
- Linter/MinImports (which is off by default)
- Linter/HaveLet (which is disabled right now)

All linters only have imports in `Lean`, except for `Linter/Lint` (which imports `Batteries.Tactic.Lint` to define an environment linter). This import could be avoided by splitting the environment linters into a different file; there is no need to import these syntax linters this early.



Co-authored-by: adomani <adomani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. t-linter Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants