-
Notifications
You must be signed in to change notification settings - Fork 889
feat: privateModule linter
#31820
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
base: master
Are you sure you want to change the base?
feat: privateModule linter
#31820
Conversation
ad9fc26 to
b0e8728
Compare
PR summary 6ff93aa9daImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
By the way, another standard request would be to add a test of this linter! 😄 |
I would love to do this, but the module system is not enabled in MathlibTest, so I can't activate the linter (hence the TODO)! 😅 (I had to test locally in a file in regular Mathlib.) I'm experimenting with turning on the module system in MathlibTest in #31823, so if that's easy (🤞, not sure if it has been attempted yet, though), maybe let's merge that first and write some tests! |
| /-- The `privateModule` linter lints against nonempty modules that have only private declarations, | ||
| and suggests adding `@[expose] public section` to the top. -/ | ||
| register_option linter.privateModule : Bool := { | ||
| defValue := true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Medium-term, we would like to add this to Mathlib.Init, right? Then this linter should be disabled by default, enabled in the lakefile, and this register_option should be public...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, makes sense. I'll do the latter three things here, right? I could also add it to Mathlib.Init here if you think so, or we can battle-test it first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the latter three can be done here - adding to Mathlib.Init can also happen once this linter is tested properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#31823 builds just fine, so I've made this a dependent PR and added a couple of basic tests. :) Should I go ahead and add it to Mathlib.Init, or should we see if we see any edge cases first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0729c34 adds the linter to Mathlib.Init, but I can cherry pick this to another branch if I've misunderstood. :)
🤦 Sorry for not realising that there was a TODO about this in the PR already! |
…-community#31608) This PR fixes `isUserFriendly`, in `unfold?`, for two reasons: - We should only worry about bad constants in the expression if they appear in the visible part of the expression. They should be allowed in e.g. instance implicit arguments. - We don't want to get raw projections, because these are generally not what we want to work with.
…nprover-community#31814) The workflow is being skipped on PR edits at the moment and being triggered on edits to the title by bors. This PR fixes both of those issues and some others found during testing.
5072232 to
7b70c89
Compare
Haha, no problem—better to err on the side of tests than otherwise, after all! 😁 |
grunweg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! The tests look good to me (I haven't looked at the linter's implementation so far).
|
This PR/issue depends on:
|
Co-authored-by: Michael Rothgang <[email protected]>
Co-authored-by: Michael Rothgang <[email protected]>
Co-authored-by: Michael Rothgang <[email protected]>
Co-authored-by: Michael Rothgang <[email protected]>
This linter lints against nonempty modules that have only private declarations, and suggests adding
@[expose] public sectionto the top.This linter found 1 violation in Mathlib, which was fixed in #31822.