Repository navigation
Conversation
PR summary 9834785757Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
grunweg
left a comment
There was a problem hiding this comment.
Wow; I would have probably gone with something much simpler/a quick shell script. And you just wrote a proper Lean command. Great to see more infrastructure being written in Lean!
I have my usual share of pernickety comments, otherwise this looks good to me. Let's merge this and try it out!
| import Mathlib.Tactic.Linter.DeprecatedModule | ||
| -/ | ||
| #guard_msgs in | ||
| run_cmd |
There was a problem hiding this comment.
I wonder if there's a way to test the actual deprecation output; that seems harder to arrange, though. I'm fine with just these tests!
There was a problem hiding this comment.
I could extract lots of small functions that perform each part of the deprecation and test them separately, but I am not sure that it would improve the script.
Right now, the script is pretty verbose in saying what it is doing and what the outcome is, so testing "live" should be straightforward.
Co-authored-by: grunweg <[email protected]>
adomani
left a comment
There was a problem hiding this comment.
Michael, thank you very much for your comments!
| import Mathlib.Tactic.Linter.DeprecatedModule | ||
| -/ | ||
| #guard_msgs in | ||
| run_cmd |
There was a problem hiding this comment.
I could extract lots of small functions that perform each part of the deprecation and test them separately, but I am not sure that it would improve the script.
Right now, the script is pretty verbose in saying what it is doing and what the outcome is, so testing "live" should be straightforward.
grunweg
left a comment
There was a problem hiding this comment.
Thanks for the fast response. Let me add "writing in Lean means everything is documented well and there are no hidden pitfalls" (don't remember if that syntax was specific to bash? you don't need to) to the list of good reasons. Plus, actually parsing a file header is more robust than whatever shell hack I would have come up with.
One last question and then let's ship this!
maintainer delegate
|
🚀 Pull request has been placed on the maintainer queue by grunweg. |
Co-authored-by: grunweg <[email protected]>
…nprover-community/mathlib4 into adomani/deprecated_module_automation
This was discovered while developing #24861. Without this change, ```lean deprecated_module "hello" (since := "YYYY-MM-DD") ``` gets pretty-printed as ```lean deprecated_module "hello"(since := "YYYY-MM-DD") ``` Note the missing space between `"hello"` and `(since...)`!
Sorry, I'm not completely sure what the description means for this PR: do you want to continue with this one simultaneously? Or should the PR description be updated? |
|
Anne, sorry for the confusion: I opened this PR first, then I tried something out in the other one and commented on this one. Now, I think that the other PR is definitely better, but I forgot to update the comment on this one. I now changed this one to |
|
Got it, thank you! |
…rover-community#24864) This was discovered while developing leanprover-community#24861. Without this change, ```lean deprecated_module "hello" (since := "YYYY-MM-DD") ``` gets pretty-printed as ```lean deprecated_module "hello"(since := "YYYY-MM-DD") ``` Note the missing space between `"hello"` and `(since...)`!
…nity#24871) Automatically created by leanprover-community#24861. These files were removed in the toolchain bump in #leanprover-community#24561.
This PR is a revised version of #24861. It splits the `#create_deprecated_modules` into two commands: * `#create_deprecated_module path/to/file.lean` that guides you through generating a deprecated file for a file that has been *erased* (so that the deprecated file will import the same files as the erased one); * `#create_deprecated_module path/to/old/file.lean rename_to path/to/renamed/file.lean` that guides you through generating a deprecated file for a file that has been *renamed* (so that the deprecated file will import just the renamed one); * `#find_deleted_files n` that looks at the repository `n` commits ago and returns a `#create_deprecated_module` for each file that existed then and does not exist now. This is integrated with `Try these:` suggestions and is intended as a first step in making this process completely automatic. Each regenerated file consists of either the imports of the deleted file or just imports the renamed file, followed by `deprecated_module (since := "YYYY-MM-DD")`. Co-authored-by: Michael Rothgang <[email protected]>
This PR is a revised version of leanprover-community#24861. It splits the `#create_deprecated_modules` into two commands: * `#create_deprecated_module path/to/file.lean` that guides you through generating a deprecated file for a file that has been *erased* (so that the deprecated file will import the same files as the erased one); * `#create_deprecated_module path/to/old/file.lean rename_to path/to/renamed/file.lean` that guides you through generating a deprecated file for a file that has been *renamed* (so that the deprecated file will import just the renamed one); * `#find_deleted_files n` that looks at the repository `n` commits ago and returns a `#create_deprecated_module` for each file that existed then and does not exist now. This is integrated with `Try these:` suggestions and is intended as a first step in making this process completely automatic. Each regenerated file consists of either the imports of the deleted file or just imports the renamed file, followed by `deprecated_module (since := "YYYY-MM-DD")`. Co-authored-by: Michael Rothgang <[email protected]>
This PR is a revised version of leanprover-community#24861. It splits the `#create_deprecated_modules` into two commands: * `#create_deprecated_module path/to/file.lean` that guides you through generating a deprecated file for a file that has been *erased* (so that the deprecated file will import the same files as the erased one); * `#create_deprecated_module path/to/old/file.lean rename_to path/to/renamed/file.lean` that guides you through generating a deprecated file for a file that has been *renamed* (so that the deprecated file will import just the renamed one); * `#find_deleted_files n` that looks at the repository `n` commits ago and returns a `#create_deprecated_module` for each file that existed then and does not exist now. This is integrated with `Try these:` suggestions and is intended as a first step in making this process completely automatic. Each regenerated file consists of either the imports of the deleted file or just imports the renamed file, followed by `deprecated_module (since := "YYYY-MM-DD")`. Co-authored-by: Michael Rothgang <[email protected]>
This PR is a revised version of leanprover-community#24861. It splits the `#create_deprecated_modules` into two commands: * `#create_deprecated_module path/to/file.lean` that guides you through generating a deprecated file for a file that has been *erased* (so that the deprecated file will import the same files as the erased one); * `#create_deprecated_module path/to/old/file.lean rename_to path/to/renamed/file.lean` that guides you through generating a deprecated file for a file that has been *renamed* (so that the deprecated file will import just the renamed one); * `#find_deleted_files n` that looks at the repository `n` commits ago and returns a `#create_deprecated_module` for each file that existed then and does not exist now. This is integrated with `Try these:` suggestions and is intended as a first step in making this process completely automatic. Each regenerated file consists of either the imports of the deleted file or just imports the renamed file, followed by `deprecated_module (since := "YYYY-MM-DD")`. Co-authored-by: Michael Rothgang <[email protected]>
There is a competing PR at #24917: I personally like the other one better! 😄
I will likely close this PR soon, since the other one seems better than this one.
This PR takes a step further in automating deprecated modules.
The command
#create_deprecated_modules (n)? (comment)? (write)?generates deprecated modules.Writing
looks at the
leanfiles inMathlibthat existed4commits ago(i.e. the commit that you see with
git log -5) and that are no longer present.It shows how the corresponding deprecated modules should look like, using
"These files are no longer relevant"as the (optional) comment.If the number of commits is not explicitly used,
#create_deprecated_modulesdefaults to2,namely, the commit just prior to the current one.
If the message is not explicitly used,
#create_deprecated_modulesdefaults to"Auto-generated deprecation".If you wish there to be no comment, use
#create_deprecated_modules 5 "".Note that the command applies the same comment to all the files that it generates.
Finally, if everything looks correct, adding a final
writeactually generates the files: