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

feat: rewrite update-style-exceptions.sh as a Lean executable #13245

Closed
wants to merge 5 commits into from

Conversation

grunweg
Copy link
Collaborator

@grunweg grunweg commented May 26, 2024

This allows running both the Python and Lean style linters.
As a user, replace ./scripts/update-style-exceptions.sh by lake exe update_style_exceptions.

The Lean version is slightly slower (1s vs 0.5), presumably due to some overhead of spawning processes/using xargs the way I do. I'm not inclined to worry.


… scripts/

It is needed in other scripts: the easiest way to depend on this is to move this to mathlib. Better places are welcome!
I'm passing all files as command line arguments: this is not how you're
supposed to do it, but as a stop-gap measure, this is fine.
@grunweg grunweg force-pushed the MR-rewrite-update-style-exceptions branch from 93a117c to 00109e5 Compare May 31, 2024 15:32
mathlib-bors bot pushed a commit that referenced this pull request Jun 1, 2024
… `scripts` (#13339)

With #13245, two scripts in `scripts` would like to use very similar information:
move it to a central place instead (a file in `Mathlib/Util`). Suggestions for better locations are welcome!

Also, split the `getAll` function in two pieces, getting the file names and transforming this into module names.
While #11853 only requires the latter, #13245 needs the former (which is computed anyway).
Only accessible the converted module names and converting them back to files would be absurd.

- [x] depends on: #11853 which adds these utility functions
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added 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) labels Jun 1, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

@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 Jun 1, 2024
println! "error {out.exitCode} on updating style exceptions : {out.stderr}"
return out.exitCode
let lines := out.stdout.splitOn "\n"
let final := "\n".intercalate (lines.toArray.qsort (· < ·)).toList
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'm not too happy about the list->array->list conversion: this is because

  • splitOn returns a List String
  • qsort requires an Array to sort
  • intercalate requires a List String again

Suggestions for avoiding this as welcome. It seems this difference isn't important for speed; this is purely an aesthetic thing.

callesonne pushed a commit that referenced this pull request Jun 4, 2024
… `scripts` (#13339)

With #13245, two scripts in `scripts` would like to use very similar information:
move it to a central place instead (a file in `Mathlib/Util`). Suggestions for better locations are welcome!

Also, split the `getAll` function in two pieces, getting the file names and transforming this into module names.
While #11853 only requires the latter, #13245 needs the former (which is computed anyway).
Only accessible the converted module names and converting them back to files would be absurd.

- [x] depends on: #11853 which adds these utility functions
grunweg added a commit that referenced this pull request Jun 7, 2024
… `scripts` (#13339)

With #13245, two scripts in `scripts` would like to use very similar information:
move it to a central place instead (a file in `Mathlib/Util`). Suggestions for better locations are welcome!

Also, split the `getAll` function in two pieces, getting the file names and transforming this into module names.
While #11853 only requires the latter, #13245 needs the former (which is computed anyway).
Only accessible the converted module names and converting them back to files would be absurd.

- [x] depends on: #11853 which adds these utility functions
@grunweg
Copy link
Collaborator Author

grunweg commented Jun 7, 2024

Just as an update: I have an even better than rewriting just this file in Lean. Instead, I propose merging lint-style.py and update-style-exceptions.py. PR will come once I find a moment to write it - probably later this month.

AntoineChambert-Loir pushed a commit that referenced this pull request Jun 20, 2024
… `scripts` (#13339)

With #13245, two scripts in `scripts` would like to use very similar information:
move it to a central place instead (a file in `Mathlib/Util`). Suggestions for better locations are welcome!

Also, split the `getAll` function in two pieces, getting the file names and transforming this into module names.
While #11853 only requires the latter, #13245 needs the former (which is computed anyway).
Only accessible the converted module names and converting them back to files would be absurd.

- [x] depends on: #11853 which adds these utility functions
@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 Jun 21, 2024
@grunweg
Copy link
Collaborator Author

grunweg commented Jun 30, 2024

Let me close this in favour of #14273.

@grunweg grunweg closed this Jun 30, 2024
@grunweg grunweg deleted the MR-rewrite-update-style-exceptions branch June 30, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Modifies the continuous integration / deployment setup merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants