Repository navigation
Conversation
…ption.py` Previously the scripts assumed `set_option X false in` — fine for backward options that default to `true` (e.g. `backward.isDefEq.respectTransparency`). The new `backward.defeqAttrib.useBackward` option has the opposite shape (default `false`, set `true` to opt into legacy behavior), so the helpers need to parametrize the value they insert and match. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Restore `add_module_set_option.py` / `rm_module_set_option.py` / `fix_nonlocal_set_option.py` from the previous adaptation branch, with the `--value` flag threaded through so they work for options whose default is `false` (like `backward.defeqAttrib.useBackward`). These are needed for the subset of modules where the option must be set at file level (not `set_option ... in`), because `backward.defeqAttrib.useBackward` is now an eqn-affecting option — its value at a defining module's compile time is stored and replayed at equation realization time in downstream modules. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Allow `--value true` (matching add_set_option.py). Without this, the script hard-coded 'false' and was unusable for restoring legacy behavior.
Extracted from 45f3ee4 on the lean-pr-testing-13492 branch. Parses lake build warnings of the form 'This simp argument is unused: X' and rewrites the simp call to drop X. For '← X' arguments it rewrites to '- X' instead, because the '←' form has side effects on the simp set even when the rewrite itself is unused. Usage: lake build 2>&1 | scripts/fix_unused_simp_args.py Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Extracted from 4278b88 on the lean-pr-testing-13492 branch. Breaks too-long lines at the last comma before column 100 and indents the continuation. Takes path:line pairs as args; intended as a follow-up to scripts that rewrite simp lists (which occasionally leave lines over the 100-char limit). Usage: scripts/fix_long_lines.py path:line ... Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…_lines.py, *_module_set_option.py, fix_nonlocal_set_option.py)
PR summary 9ccb29abfaImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
Could you make sure these are usable to some extent by downstream projects? @kbuzzard was running |
Address Bryan's review on leanprover-community#38602. Drops the hardcoded `Mathlib/` filters from the new module-level helpers, threads `--directories` through them (mirroring `rm_set_option.py`), and skips `.lake/` in the shared DAG walk so the whole-project default doesn't touch vendored dependencies. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…users Cribbed from kbuzzard's hands-on Zulip diary of getting `rm_set_option.py` running on FLT — turning each thing he tripped on into a fix: - friendlier ImportError when sibling Python files are missing from the user's `scripts/` (the "this is a mathlib script, not a pip package" hint kbuzzard had to discover by trial) - detect `lakefile.toml` and print a one-liner reminding the user to remove option entries from `leanOptions` manually (we only edit `lakefile.lean`) - warn when `from_directories` finds no `.lean` files at all, suggesting `--directories <root>` rather than silently producing "0 modules parsed" - replace the prose portability paragraph in `scripts/README.md` with a numbered downstream recipe Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Good call. Done in 1992790 + d4b48cc, after reading @kbuzzard's saga getting
Caveats: |
|
Thanks! |
…ng-line fixers (#38602) This PR cherry-picks a set of adaptation-helper scripts that @nomeata developed on the `lean-pr-testing-13492` branch during the adaptation for leanprover/lean4#13492 (now merged). He flagged on Zulip ([thread](https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/lean.2313492.2C.20stricter.20.40.5Bdefeq.5D.20inference/near/591078800)) that he plans to delete them from the adaptation branch and offered them up for adoption. Changes: - `scripts/add_set_option.py`, `scripts/rm_set_option.py`: new `--value` flag, so the scripts work for options whose default is `false` (where you want to insert `set_option X true in`) as well as the existing `false` case. - `scripts/add_module_set_option.py` (new): file-level variant of `add_set_option.py` — inserts a module-scoped `set_option` after the imports (and module docstring, if present) rather than scoped to a declaration. Needed for eqn-affecting options. - `scripts/rm_module_set_option.py` (new): file-level variant of `rm_set_option.py`. Traverses the import DAG backward, with resume support keyed on toolchain. - `scripts/fix_nonlocal_set_option.py` (new): given failing modules, adds the option to all transitive deps then binary-search minimizes back to the smallest set whose modules need it. - `scripts/fix_unused_simp_args.py` (new): parses `This simp argument is unused: X` warnings from `lake build` and removes `X` from the corresponding `simp` / `simp only` call. For `← X` it rewrites to `- X` because the `←` has simp-set side effects. - `scripts/fix_long_lines.py` (new): breaks too-long lines at the last comma before column 100 and indents the continuation. Useful as a follow-up to scripts that rewrite simp lists. - `scripts/README.md`: documents all of the above. The defaults for `--option` in the new module-level scripts point at `backward.defeq.atInstanceTransparency` (the option from leanprover/lean4#13492); for current options pass `--option <name>` explicitly. Original commits from `lean-pr-testing-13492`: - `6f1a3512906` chore(scripts): add `--value` flag to add/rm_set_option.py (had a small conflict with #38532's `lakefile.lean` existence check; resolved by combining) - `36625b2a675` chore(scripts): bring back module-level / nonlocal scripts - `de2a59b5839` chore(scripts): thread `--value` through `fix_nonlocal_set_option.py` - `45f3ee41b94` (extracted) `fix_unused_simp_args.py` - `4278b885305` (extracted) `fix_long_lines.py` - `80852596213` doc(scripts): document new helpers I sanity-checked each script: all parse, all `--help`s render, and `fix_long_lines.py` / `fix_unused_simp_args.py` produce the expected output on synthetic inputs. 🤖 Prepared with Claude Code Co-authored-by: Joachim Breitner <[email protected]>
|
Pull request successfully merged into master. Build succeeded: |
…ng-line fixers (leanprover-community#38602) This PR cherry-picks a set of adaptation-helper scripts that @nomeata developed on the `lean-pr-testing-13492` branch during the adaptation for leanprover/lean4#13492 (now merged). He flagged on Zulip ([thread](https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/lean.2313492.2C.20stricter.20.40.5Bdefeq.5D.20inference/near/591078800)) that he plans to delete them from the adaptation branch and offered them up for adoption. Changes: - `scripts/add_set_option.py`, `scripts/rm_set_option.py`: new `--value` flag, so the scripts work for options whose default is `false` (where you want to insert `set_option X true in`) as well as the existing `false` case. - `scripts/add_module_set_option.py` (new): file-level variant of `add_set_option.py` — inserts a module-scoped `set_option` after the imports (and module docstring, if present) rather than scoped to a declaration. Needed for eqn-affecting options. - `scripts/rm_module_set_option.py` (new): file-level variant of `rm_set_option.py`. Traverses the import DAG backward, with resume support keyed on toolchain. - `scripts/fix_nonlocal_set_option.py` (new): given failing modules, adds the option to all transitive deps then binary-search minimizes back to the smallest set whose modules need it. - `scripts/fix_unused_simp_args.py` (new): parses `This simp argument is unused: X` warnings from `lake build` and removes `X` from the corresponding `simp` / `simp only` call. For `← X` it rewrites to `- X` because the `←` has simp-set side effects. - `scripts/fix_long_lines.py` (new): breaks too-long lines at the last comma before column 100 and indents the continuation. Useful as a follow-up to scripts that rewrite simp lists. - `scripts/README.md`: documents all of the above. The defaults for `--option` in the new module-level scripts point at `backward.defeq.atInstanceTransparency` (the option from leanprover/lean4#13492); for current options pass `--option <name>` explicitly. Original commits from `lean-pr-testing-13492`: - `6f1a3512906` chore(scripts): add `--value` flag to add/rm_set_option.py (had a small conflict with leanprover-community#38532's `lakefile.lean` existence check; resolved by combining) - `36625b2a675` chore(scripts): bring back module-level / nonlocal scripts - `de2a59b5839` chore(scripts): thread `--value` through `fix_nonlocal_set_option.py` - `45f3ee41b94` (extracted) `fix_unused_simp_args.py` - `4278b885305` (extracted) `fix_long_lines.py` - `80852596213` doc(scripts): document new helpers I sanity-checked each script: all parse, all `--help`s render, and `fix_long_lines.py` / `fix_unused_simp_args.py` produce the expected output on synthetic inputs. 🤖 Prepared with Claude Code Co-authored-by: Joachim Breitner <[email protected]>
…ng-line fixers (leanprover-community#38602) This PR cherry-picks a set of adaptation-helper scripts that @nomeata developed on the `lean-pr-testing-13492` branch during the adaptation for leanprover/lean4#13492 (now merged). He flagged on Zulip ([thread](https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/lean.2313492.2C.20stricter.20.40.5Bdefeq.5D.20inference/near/591078800)) that he plans to delete them from the adaptation branch and offered them up for adoption. Changes: - `scripts/add_set_option.py`, `scripts/rm_set_option.py`: new `--value` flag, so the scripts work for options whose default is `false` (where you want to insert `set_option X true in`) as well as the existing `false` case. - `scripts/add_module_set_option.py` (new): file-level variant of `add_set_option.py` — inserts a module-scoped `set_option` after the imports (and module docstring, if present) rather than scoped to a declaration. Needed for eqn-affecting options. - `scripts/rm_module_set_option.py` (new): file-level variant of `rm_set_option.py`. Traverses the import DAG backward, with resume support keyed on toolchain. - `scripts/fix_nonlocal_set_option.py` (new): given failing modules, adds the option to all transitive deps then binary-search minimizes back to the smallest set whose modules need it. - `scripts/fix_unused_simp_args.py` (new): parses `This simp argument is unused: X` warnings from `lake build` and removes `X` from the corresponding `simp` / `simp only` call. For `← X` it rewrites to `- X` because the `←` has simp-set side effects. - `scripts/fix_long_lines.py` (new): breaks too-long lines at the last comma before column 100 and indents the continuation. Useful as a follow-up to scripts that rewrite simp lists. - `scripts/README.md`: documents all of the above. The defaults for `--option` in the new module-level scripts point at `backward.defeq.atInstanceTransparency` (the option from leanprover/lean4#13492); for current options pass `--option <name>` explicitly. Original commits from `lean-pr-testing-13492`: - `6f1a3512906` chore(scripts): add `--value` flag to add/rm_set_option.py (had a small conflict with leanprover-community#38532's `lakefile.lean` existence check; resolved by combining) - `36625b2a675` chore(scripts): bring back module-level / nonlocal scripts - `de2a59b5839` chore(scripts): thread `--value` through `fix_nonlocal_set_option.py` - `45f3ee41b94` (extracted) `fix_unused_simp_args.py` - `4278b885305` (extracted) `fix_long_lines.py` - `80852596213` doc(scripts): document new helpers I sanity-checked each script: all parse, all `--help`s render, and `fix_long_lines.py` / `fix_unused_simp_args.py` produce the expected output on synthetic inputs. 🤖 Prepared with Claude Code Co-authored-by: Joachim Breitner <[email protected]>
…ng-line fixers (leanprover-community#38602) This PR cherry-picks a set of adaptation-helper scripts that @nomeata developed on the `lean-pr-testing-13492` branch during the adaptation for leanprover/lean4#13492 (now merged). He flagged on Zulip ([thread](https://leanprover.zulipchat.com/#narrow/channel/428973-nightly-testing/topic/lean.2313492.2C.20stricter.20.40.5Bdefeq.5D.20inference/near/591078800)) that he plans to delete them from the adaptation branch and offered them up for adoption. Changes: - `scripts/add_set_option.py`, `scripts/rm_set_option.py`: new `--value` flag, so the scripts work for options whose default is `false` (where you want to insert `set_option X true in`) as well as the existing `false` case. - `scripts/add_module_set_option.py` (new): file-level variant of `add_set_option.py` — inserts a module-scoped `set_option` after the imports (and module docstring, if present) rather than scoped to a declaration. Needed for eqn-affecting options. - `scripts/rm_module_set_option.py` (new): file-level variant of `rm_set_option.py`. Traverses the import DAG backward, with resume support keyed on toolchain. - `scripts/fix_nonlocal_set_option.py` (new): given failing modules, adds the option to all transitive deps then binary-search minimizes back to the smallest set whose modules need it. - `scripts/fix_unused_simp_args.py` (new): parses `This simp argument is unused: X` warnings from `lake build` and removes `X` from the corresponding `simp` / `simp only` call. For `← X` it rewrites to `- X` because the `←` has simp-set side effects. - `scripts/fix_long_lines.py` (new): breaks too-long lines at the last comma before column 100 and indents the continuation. Useful as a follow-up to scripts that rewrite simp lists. - `scripts/README.md`: documents all of the above. The defaults for `--option` in the new module-level scripts point at `backward.defeq.atInstanceTransparency` (the option from leanprover/lean4#13492); for current options pass `--option <name>` explicitly. Original commits from `lean-pr-testing-13492`: - `6f1a3512906` chore(scripts): add `--value` flag to add/rm_set_option.py (had a small conflict with leanprover-community#38532's `lakefile.lean` existence check; resolved by combining) - `36625b2a675` chore(scripts): bring back module-level / nonlocal scripts - `de2a59b5839` chore(scripts): thread `--value` through `fix_nonlocal_set_option.py` - `45f3ee41b94` (extracted) `fix_unused_simp_args.py` - `4278b885305` (extracted) `fix_long_lines.py` - `80852596213` doc(scripts): document new helpers I sanity-checked each script: all parse, all `--help`s render, and `fix_long_lines.py` / `fix_unused_simp_args.py` produce the expected output on synthetic inputs. 🤖 Prepared with Claude Code Co-authored-by: Joachim Breitner <[email protected]>
This PR cherry-picks a set of adaptation-helper scripts that @nomeata developed on the
lean-pr-testing-13492branch during the adaptation for leanprover/lean4#13492 (now merged). He flagged on Zulip (thread) that he plans to delete them from the adaptation branch and offered them up for adoption.Changes:
scripts/add_set_option.py,scripts/rm_set_option.py: new--valueflag, so the scripts work for options whose default isfalse(where you want to insertset_option X true in) as well as the existingfalsecase.scripts/add_module_set_option.py(new): file-level variant ofadd_set_option.py— inserts a module-scopedset_optionafter the imports (and module docstring, if present) rather than scoped to a declaration. Needed for eqn-affecting options.scripts/rm_module_set_option.py(new): file-level variant ofrm_set_option.py. Traverses the import DAG backward, with resume support keyed on toolchain.scripts/fix_nonlocal_set_option.py(new): given failing modules, adds the option to all transitive deps then binary-search minimizes back to the smallest set whose modules need it.scripts/fix_unused_simp_args.py(new): parsesThis simp argument is unused: Xwarnings fromlake buildand removesXfrom the correspondingsimp/simp onlycall. For← Xit rewrites to- Xbecause the←has simp-set side effects.scripts/fix_long_lines.py(new): breaks too-long lines at the last comma before column 100 and indents the continuation. Useful as a follow-up to scripts that rewrite simp lists.scripts/README.md: documents all of the above.The defaults for
--optionin the new module-level scripts point atbackward.defeq.atInstanceTransparency(the option from leanprover/lean4#13492); for current options pass--option <name>explicitly.Original commits from
lean-pr-testing-13492:6f1a3512906chore(scripts): add--valueflag to add/rm_set_option.py (had a small conflict with [Merged by Bors] - fix(scripts/rm_set_option.py): make more usable in downstream projects #38532'slakefile.leanexistence check; resolved by combining)36625b2a675chore(scripts): bring back module-level / nonlocal scriptsde2a59b5839chore(scripts): thread--valuethroughfix_nonlocal_set_option.py45f3ee41b94(extracted)fix_unused_simp_args.py4278b885305(extracted)fix_long_lines.py80852596213doc(scripts): document new helpersI sanity-checked each script: all parse, all
--helps render, andfix_long_lines.py/fix_unused_simp_args.pyproduce the expected output on synthetic inputs.🤖 Prepared with Claude Code