Skip to content

[Merged by Bors] - feat: rewrite set_option style linter in lean#12928

Closed
grunweg wants to merge 7 commits intomasterfrom
MR-rewrite-setOption
Closed

[Merged by Bors] - feat: rewrite set_option style linter in lean#12928
grunweg wants to merge 7 commits intomasterfrom
MR-rewrite-setOption

Conversation

@grunweg
Copy link
Copy Markdown
Contributor

@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 setup or other automation tech debt Tracking cross-cutting technical debt, see e.g. the "Technical debt counters" stream on zulip labels May 15, 2024
@ghost ghost added blocked-by-other-PR This PR depends on another PR (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 (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
Copy Markdown
Contributor Author

grunweg commented May 22, 2024

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

@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 May 22, 2024
@grunweg grunweg force-pushed the MR-rewrite-setOption branch from 78843a8 to 0829a34 Compare May 22, 2024 15:36
@grunweg grunweg force-pushed the MR-rewrite-setOption branch from b9f8379 to b683b75 Compare May 22, 2024 15:50
@grunweg
Copy link
Copy Markdown
Contributor 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 setup or other automation 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
grunweg added 3 commits May 25, 2024 01:58
Unlike the Python version, this script also supports set_option tactics
and terms.
@grunweg grunweg force-pushed the MR-rewrite-setOption branch from 5649950 to 5017c0c Compare May 24, 2024 23:58
@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
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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.

@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 May 31, 2024
@ghost ghost 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor 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.

3 participants