-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Merged by Bors] - feat(Tactic/Linter/DirectoryDependency): add an allow-list for directories with few imports #24109
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
Closed
Closed
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
dec0a87
chore: use line continuation for shorter lines
grunweg 1b6f6d6
chore: two helper functions
grunweg adaab49
feat(Tactic/Linter/DirectoryDependency): POC of using an allow-list f…
grunweg 425fa89
Add special exception
grunweg dda425c
refactor: return an array of error messages instead
grunweg 89e3771
fix: allow transitive imports of Mathlib.Init
grunweg 3498abe
wip: add exceptions for Mathlib/Lean
grunweg e54f561
refactor: try to avoid duplicate warnings
grunweg 12c71c0
chore: extract the blocklist part into a separate function
grunweg cb0f563
Ensure we either check the allow-list or the blocklist
grunweg 9cadbdc
fix: handle overlapping prefixes
grunweg 67b2f83
fix: importing Mathlib.Lean.Dir.Foo should be allowed in Mathlib.Lean…
grunweg 4ff9045
tweak: better error message; put the bad module name first
grunweg 465840c
Move exceptions around
grunweg 942795e
fixup tweak
grunweg 821637a
chore: migrate Mathlib.Tactic.Linter to the allowlist
grunweg 6d1d8a1
Fix
grunweg 0b77a96
Docs
grunweg f72ae66
Fix for Mathlib/Tactic/Linter.lean
grunweg 3bfbbd3
test update: TODO fix that regression
grunweg 4b47c9f
Does this fix it?
grunweg fdbb143
chore: always exclude Lean and Qq imports also
grunweg 16ce966
Update test
grunweg 2a8b436
Tweak TODO comments
grunweg d584e07
Fixup
grunweg c995448
Review comments (except tests)
grunweg e89d51d
Move unit tests, add basic test
grunweg ec911f8
chore: fix MathlibTest/Header
grunweg c05c216
Apply suggestions from code review
grunweg 1d786c7
Adjust test message: the blocklist error is gone now... more fine-gra…
grunweg 3e81e7f
Only add warning messages on imports that are not themselves transiti…
Vierkantor b00cb81
Merge remote-tracking branch 'origin/master' into MR-dirdep-allowlist
Vierkantor 05d0a12
Typo fix
Vierkantor 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| /- | ||
| Copyright (c) 2025 Michael Rothgang. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Michael Rothgang | ||
| -/ | ||
| import Mathlib.Init | ||
| import Qq | ||
| import Mathlib.Util.AssertExists | ||
|
|
||
| /-- | ||
| warning: Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.Lint.Basic, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.Lint.Basic is imported by Batteries.Tactic.Lint.Misc, | ||
| which is imported by Batteries.Tactic.Lint, | ||
| which is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.Lint.Misc, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.Lint.Misc is imported by Batteries.Tactic.Lint, | ||
| which is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.OpenPrivate, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.OpenPrivate is imported by Batteries.Tactic.Lint.Simp, | ||
| which is imported by Batteries.Tactic.Lint, | ||
| which is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Util.LibraryNote, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Util.LibraryNote is imported by Batteries.Tactic.Lint.Simp, | ||
| which is imported by Batteries.Tactic.Lint, | ||
| which is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.Lint.Simp, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.Lint.Simp is imported by Batteries.Tactic.Lint, | ||
| which is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.Lint.TypeClass, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.Lint.TypeClass is imported by Batteries.Tactic.Lint, | ||
| which is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.Lint.Frontend, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.Lint.Frontend is imported by Batteries.Tactic.Lint, | ||
| which is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.Lint, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.Lint is imported by Mathlib.Tactic.Linter.Lint, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Batteries.Tactic.Unreachable, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Batteries.Tactic.Unreachable is imported by Mathlib.Tactic.Linter.UnusedTactic, | ||
| which is imported by Mathlib.Init, | ||
| which is imported by Mathlib.Util.AssertExistsExt, | ||
| which is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Mathlib.Util.AssertExistsExt, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Mathlib.Util.AssertExistsExt is imported by Mathlib.Util.AssertExists, | ||
| which is imported by this module. | ||
|
|
||
| Module MathlibTest.DirectoryDependencyLinter.Test depends on Mathlib.Util.AssertExists, | ||
| but is only allowed to import modules starting with one of [Mathlib.Lean]. | ||
| Note: module Mathlib.Util.AssertExists is directly imported by this module | ||
| note: this linter can be disabled with `set_option linter.directoryDependency false` | ||
| --- | ||
| warning: The module doc-string for a file should be the first command after the imports. | ||
| Please, add a module doc-string before `/-!# Tests for the `directoryDependency` linter | ||
| -/ | ||
| `. | ||
| note: this linter can be disabled with `set_option linter.style.header false` | ||
| -/ | ||
| #guard_msgs in | ||
| set_option linter.style.header true in | ||
|
|
||
| /-! | ||
| # Tests for the `directoryDependency` linter | ||
| -/ | ||
|
|
||
| -- Some unit-tests for internal functions. | ||
| #guard Lean.Name.isPrefixOf `Mathlib.Util `Mathlib.Util.Basic == true | ||
| #guard Lean.Name.isPrefixOf `Mathlib.Util `Mathlib.Util.Nested.Basic == true | ||
| #guard Lean.Name.isPrefixOf `Mathlib.Util `Mathlib.Utils.Basic == false | ||
| #guard Lean.Name.isPrefixOf `Mathlib.Foo `Mathlib.Util.Foo == false | ||
| #guard Lean.Name.isPrefixOf `Mathlib.Util `Mathlib.Utils == false |
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.