-
Notifications
You must be signed in to change notification settings - Fork 167
Migrating alpha file import to lean + adding testing #1552
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
jstoobysmith
merged 11 commits into
leanprover-community:master
from
FergusMunro:migratingAlphaFileImportToLean
Aug 21, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c138503
created alphaFileImports.lean
b9d4cc9
updated lakefile and agents.md to include alphaFileImports as build t…
fe22c84
included alphaFileImports and noAlphaImports in lint_all.lean
a2388a6
changed alphaBuild workflow to use new lean script
5fbd936
modified lean checkers to allow for command line arguments
023eae0
created Meta/test directory, populated with dummy project violating l…
a9645bf
added testImportScript to lakefile
cf27671
added text for new checks in lint_all
ee1390e
temporarily removed Meta file
2671e17
Removed newlines and accidental test case.
953494f
removed a few extra newlines
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import Lean | ||
| import Physlib.Meta.AllFilePaths | ||
| import Std.Data.HashSet | ||
|
|
||
|
|
||
| /-! | ||
| Copyright (c) 2026 Fergus Munro. All rights reserved. | ||
| Released under Apache 2.0 license. | ||
| Authors: Fergus Munro | ||
| -/ | ||
|
|
||
| open Lean | ||
| open Std | ||
| open System | ||
|
|
||
| def extractModuleNameFromFilePath (path : FilePath) : String := | ||
| ".".intercalate ((path.withExtension "").components.drop 1) | ||
|
|
||
| def extractModuleNameFromImport (importString : String) : String := | ||
| let rec findAfterImport : List String → String | ||
| | "import" :: x :: _ => x | ||
| | _ :: xs => findAfterImport xs | ||
| | [] => "" | ||
|
|
||
| findAfterImport ((importString.split Char.isWhitespace).toList.map toString) | ||
|
|
||
| def checkAllFilesImported (directory : String) (mainFilePath : String) : (IO Bool) := do | ||
| let modules : HashSet String := HashSet.ofArray $ (← getFilePaths directory).map extractModuleNameFromFilePath | ||
| let importedModules := HashSet.ofArray $ ((← IO.FS.lines mainFilePath).filter | ||
| (·.contains "import")).map extractModuleNameFromImport | ||
| let diff := modules \ importedModules | ||
| if diff.size > 0 | ||
| then do | ||
| IO.println s!"Error: The following .lean files are not imported in {mainFilePath}:" | ||
| for module_name in diff do | ||
| IO.println s!" - public import {module_name}" | ||
| return False | ||
| else do | ||
| IO.println s!"✓ All {modules.size} .lean files in {directory} are imported in {mainFilePath}" | ||
| return True | ||
|
|
||
| unsafe def main (args : List String) : IO Unit := do | ||
| let (dir, file) := match args with | ||
| | d :: f :: [] => (d, f) | ||
| | _ => ("./PhyslibAlpha", "./PhyslibAlpha.lean") | ||
| let success ← checkAllFilesImported dir file | ||
| if !success then | ||
| IO.Process.exit 1 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.