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] - feat: rewrite set_option style linter in lean #12928

Closed
wants to merge 7 commits into from

Conversation

grunweg
Copy link
Collaborator

@grunweg grunweg commented May 15, 2024

Unlike the Python version, this script also supports set_option tactics and terms, and we add a couple of tests.


Mentored by @digama0; thanks for all your help. Written at the HIM school on formalization of mathematics.

Open in Gitpod

@grunweg grunweg added awaiting-review CI Modifies the continuous integration / deployment setup tech debt Tracking cross-cutting technical debt, see e.g. the "Technical debt counters" stream on zulip labels May 15, 2024
Mathlib/Tactic.lean Outdated Show resolved Hide resolved
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) and removed blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels May 15, 2024
@grunweg
Copy link
Collaborator Author

grunweg commented May 22, 2024

Actually, this PR is blocked on #11807 (and adapting it accordingly).

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) and removed blocked-by-other-PR This PR depends on another PR to Mathlib (this label is automatically managed by a bot) labels May 22, 2024
Mathlib.lean Outdated Show resolved Hide resolved
Mathlib/Tactic.lean Outdated Show resolved Hide resolved
@grunweg
Copy link
Collaborator Author

grunweg commented May 22, 2024

The CI failure is interesting: I have no idea where this is coming from. Help on this detail is welcome.
After rebasing, CI passes. I guess it was something intermittent.

@grunweg grunweg added help-wanted The author needs attention to resolve issues t-linter Linter and removed CI Modifies the continuous integration / deployment setup labels May 22, 2024
@grunweg grunweg force-pushed the MR-rewrite-setOption branch 2 times, most recently from 0c2aeec to 5649950 Compare May 24, 2024 23:57
Unlike the Python version, this script also supports set_option tactics
and terms.
@grunweg grunweg removed the help-wanted The author needs attention to resolve issues label May 25, 2024
return
if (← MonadState.get).messages.hasErrors then
return
match stx.findStack? (fun _ ↦ true) is_set_option with
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like findStack? isn't an ideal API for this use case. I would think Syntax should provide a function like find? (root : Syntax) (needle : Syntax → Option β) : Option β or List β. This would avoid having to parse_set_option twice. Overall, probably not worth bothering with unless this pattern comes up a lot when linting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I've switched to Syntax.find? now - this is not quite the API you described, but closer (and more concise also). It still requires parsing the set_option call twice, but if there are no errors, this hopefully doesn't matter.

@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
@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 31, 2024
@robertylewis
Copy link
Member

I could see a case for generalizing this: the list of disallowed options should be customizable/extensible by downstream projects. But, future work. Thanks!

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Jun 19, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jun 19, 2024
Unlike the Python version, this script also supports set_option tactics and terms, and we add a couple of tests.
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jun 19, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: rewrite set_option style linter in lean [Merged by Bors] - feat: rewrite set_option style linter in lean Jun 19, 2024
@mathlib-bors mathlib-bors bot closed this Jun 19, 2024
@mathlib-bors mathlib-bors bot deleted the MR-rewrite-setOption branch June 19, 2024 09:36
@grunweg
Copy link
Collaborator Author

grunweg commented Jun 19, 2024

Thanks for the review!
I agree that making this list configurable could be useful - if somebody sees a specific use, I'm happy to look at PRs extending this!

AntoineChambert-Loir pushed a commit that referenced this pull request Jun 20, 2024
Unlike the Python version, this script also supports set_option tactics and terms, and we add a couple of tests.
grunweg added a commit that referenced this pull request Jun 20, 2024
Unlike the Python version, this script also supports set_option tactics and terms, and we add a couple of tests.
kbuzzard pushed a commit that referenced this pull request Jun 26, 2024
Unlike the Python version, this script also supports set_option tactics and terms, and we add a couple of tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors. t-linter Linter tech debt Tracking cross-cutting technical debt, see e.g. the "Technical debt counters" stream on zulip
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants