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

[Merged by Bors] - move: new Mathlib.Tactic.Linter dir #11807

Closed
wants to merge 10 commits into from

Conversation

adomani
Copy link
Collaborator

@adomani adomani commented Mar 31, 2024

Create a new Mathlib/Tactic/Linter dir and move there the linters. Currently the new dir contains only one file, but there are more linters in PRs.


This was brought up by @thorimur in the context of #11019. The suggestion there was to add a Mathlib.Command.Linters dir, but maybe the extra Command layer can be skipped -- at least for now.


Open in Gitpod

@adomani adomani marked this pull request as ready for review March 31, 2024 07:00
Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter might be better than Linters, to match how we have Tactic not Tactics.

@adomani
Copy link
Collaborator Author

adomani commented Apr 2, 2024

Eric, thanks! I made the change Linters → Linter.

@adomani adomani changed the title move: new Mathlib.Linters dir move: new Mathlib.Linter dir Apr 3, 2024
@@ -60,7 +60,7 @@ import Mathlib.Tactic.InferParam
import Mathlib.Tactic.Inhabit
import Mathlib.Tactic.IrreducibleDef
import Mathlib.Tactic.Lift
import Mathlib.Tactic.Lint
import Mathlib.Linter.Lint
Copy link
Collaborator

@thorimur thorimur Apr 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should put this in a section under ProofWidgets just to keep this file organized (since it's no longer in alphabetical order), so that it looks something roughly like

...
-- Hopefully `lake` will be able to handle tests later.
import ProofWidgets

-- Import Mathlib-specific linters.
import Mathlib.Linter.Lint

-- Now import all tactics defined in Mathlib that do not require theory files.
import Mathlib.Mathport.Rename
...

likely also with a change to the module doc

...
We include some commented out imports here, with an explanation of their theory requirements,
to save some time for anyone wondering why they are not here.

We also import theory-free linters, commands, and utilities which are useful to have low in the 
import hierarchy.
-/
...

(Sorry, the fact that github doesn't let me make suggestions on non-modified code is relevant once more... 😅)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! If I implemented your suggestions, assuming that I understood them correctly!

Mathlib/Tactic/Common.lean Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@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 7, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 9, 2024
@grunweg grunweg added the awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there label May 21, 2024
@grunweg
Copy link
Collaborator

grunweg commented May 21, 2024

This also seems blocked on zulip consensus.

@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 22, 2024
@grunweg
Copy link
Collaborator

grunweg commented May 22, 2024

Per zulip, it seems there is sufficient consensus to go ahead with this one (with an e.g. Mathlib/Tactic/Linter directory).
Can you fix the merge conflicts and change these? After these, this PR seems ready to go for me.

awaiting-author

@grunweg grunweg removed the awaiting-zulip There is a Zulip discussion; the author should await and report/implement the decision reached there label May 22, 2024
@github-actions github-actions bot added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review labels May 22, 2024
@adomani
Copy link
Collaborator Author

adomani commented May 22, 2024

@grunweg: I updated a little bit in auto-pilot mode. Is this what you had in mind? I wonder if, as a consequence of the Mathlib.Tactic.Linter dir, there is the need of a Linter.lean file, analogous to ``Mathlib.Tactic.lean`.

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label May 22, 2024
@grunweg grunweg changed the title move: new Mathlib.Linter dir move: new Mathlib.Tactic.Linter dir May 22, 2024
@grunweg
Copy link
Collaborator

grunweg commented May 22, 2024

@adomani Thanks; I think I meant something like this.
Your comment seems spot on; I think the current structure can be improve a bit.

  • Perhaps, Mathlib/Tactic/Linter.lean can move to Mathlib/Tactic/Linter/All.lean
  • the current Tactic/Linter/Lint.lean file can get a more descriptive name/be split up more descriptively. (For instance, dupNamespace feels like a style lint to me, but structureInType feels like a different kind... not sure how to name that.)

Long-term, I think separate files for style linters, text-based ones and environment linters, for example, could be a useful classification. At the moment, there a few landed linters, so splitting could also happen later imho.

@grunweg
Copy link
Collaborator

grunweg commented May 22, 2024

It could be useful to think where e.g. all your in-flight linters want to land in the end - if the structure can house them, I think it's good enough!

@adomani
Copy link
Collaborator Author

adomani commented May 22, 2024

Ok, I'll leave this as is for now and we can discuss how many "generic linter import" files we have later on.

I will probably have to update shake to "ignoreAll/..." the new path also.

@grunweg
Copy link
Collaborator

grunweg commented May 22, 2024

Fine with me - re-organising linters can also happen in a future PR.
As the zulip consensus seems to be about this PR (not #12899, oops), let me go ahead and propose to
maintainer merge

Copy link

🚀 Pull request has been placed on the maintainer queue by grunweg.

@grunweg
Copy link
Collaborator

grunweg commented May 22, 2024

Somehow, I've thought more about this --- here's a more detailed proposal how mathlib's linters could end up. (For a follow-up PR.) In the medium to long term, I see at least three useful categories of linters:

  • text-based linters: they are based on reading the source code only. In practice, only style linters will have this form.
    Currently, there are none of them; most lints in lint-style.py can (and imho should) be rewritten this way: for example, checking the copyright header, authors line, line length, isolated "where" or "by"

  • style linters: they are about coding style only; they do not affect code correctness (nor scalability of mathlib)
    This includes checking for broad imports (like "Mathlib.Tactic"), duplicate names, the "theorems without a docstring" or the multi-goal linters. They can be syntax-based; I suspect most of them will be (but this fact is not important).

  • "global linters": they are about global coherence properties of mathlib. (I imagine most if not all of these will be environment linters.) Code violating them may compile, but this comes at a cost for building a coherent library. This includes

  • the "structureInType" lint (currently in Lint.lean)

  • the Finite/Fintype and DecidableEq linter (by urkud in feat: add Decidable, Fintype, Encodable linters #10235), as well as fpvandoorn's dual linter (somewhere on zulip)

  • many still unported mathlib3 linters, e.g. for dangerous instances

Accordingly, I can imagine grouping Tactic/Linter as

  • All.lean: referencing all lints, perhaps giving an overview of the different categories and referring to the separate files
  • TextBased.lean: text-based linters (which are in practice all about style)
  • Style.lean: style linters (presumably all operating on syntax)
  • Global.lean: linters about global coherence properties; better name welcome

Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🎉

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added ready-to-merge This PR has been sent to bors. and removed awaiting-author A reviewer has asked the author a question or requested changes labels May 22, 2024
mathlib-bors bot pushed a commit that referenced this pull request May 22, 2024
Create a new `Mathlib/Tactic/Linter` dir and move there the linters.  Currently the new dir contains only one file, but there are more linters in PRs.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented May 22, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title move: new Mathlib.Tactic.Linter dir [Merged by Bors] - move: new Mathlib.Tactic.Linter dir May 22, 2024
@mathlib-bors mathlib-bors bot closed this May 22, 2024
@mathlib-bors mathlib-bors bot deleted the adomani/create_linters branch May 22, 2024 15:10
callesonne pushed a commit that referenced this pull request Jun 4, 2024
Create a new `Mathlib/Tactic/Linter` dir and move there the linters.  Currently the new dir contains only one file, but there are more linters in PRs.
js2357 pushed a commit that referenced this pull request Jun 18, 2024
Create a new `Mathlib/Tactic/Linter` dir and move there the linters.  Currently the new dir contains only one file, but there are more linters in PRs.
Comment on lines +14 to +17
-- Currently we don't need to import all of ProofWidgets,
-- but without this, if you don't run `lake build ProofWidgets` then `make test` will fail.
-- Hopefully `lake` will be able to handle tests later.
import ProofWidgets
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this come back?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this comment made me add it. I suspect that it was there at the time that this PR was opened, then the other PR was merged, the import possibly removed, but when this PR was looked at again, no one noticed that it was still here.

eric-wieser added a commit that referenced this pull request Aug 5, 2024
A bad merge in #11807 causes the change from #11877 to be reverted.
mathlib-bors bot pushed a commit that referenced this pull request Aug 6, 2024
A bad merge in #11807 causes the change from #11877 (removing `import ProofWidgets`) to be reverted.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
A bad merge in #11807 causes the change from #11877 (removing `import ProofWidgets`) to be reverted.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 9, 2024
A bad merge in #11807 causes the change from #11877 (removing `import ProofWidgets`) to be reverted.
bjoernkjoshanssen pushed a commit that referenced this pull request Sep 12, 2024
A bad merge in #11807 causes the change from #11877 (removing `import ProofWidgets`) to be reverted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer-merge ready-to-merge This PR has been sent to bors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants