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

[Merged by Bors] - feat: add by how many modules imports grew #18303

Closed
wants to merge 7 commits into from

Conversation

adomani
Copy link
Collaborator

@adomani adomani commented Oct 27, 2024

This PR makes the minImports linter report more information:

  • the number of increase imports,
  • which previously minimal imports became redundant,
  • which new minimal imports should be added.

Prompted by this Zulip thread.


Open in Gitpod

Copy link

github-actions bot commented Oct 27, 2024

PR summary 894f7a8ec9

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ ImportState
+ importsBelow

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.

@github-actions github-actions bot added the t-linter Linter label Oct 27, 2024
test/MinImports.lean Outdated Show resolved Hide resolved
test/MinImports.lean Outdated Show resolved Hide resolved
Comment on lines 73 to 74
def importsBelow (ig : NameMap (Array Name)) (ms : NameSet) : NameSet :=
(ig.upstreamOf ms).fold (σ := NameSet) (fun _ ↦ ·.insert ·) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could avoid recalculating here, too. Rather than stashing env.importGraph in the state, stash (← env.importGraph).transitiveClosure.

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 sure that I understand here: importGraph is a NameMap (Array Name), while transitiveClosure returns a NameMap NameSet. I do not really know how to then use upstreamOf, since that function wants an importGraph as an input.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wouldn't even need upstreamOf. You'd just take the union over ms of the values from the transitiveClosure map.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I understand now, thanks! I updated the PR.

Copy link
Collaborator Author

@adomani adomani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kim, thank you for your comments! I accepted the ones that I understood and left a question for the one that I did not follow.

Mathlib/Tactic/Linter/MinImports.lean Outdated Show resolved Hide resolved
test/MinImports.lean Outdated Show resolved Hide resolved
test/MinImports.lean Outdated Show resolved Hide resolved
Comment on lines 73 to 74
def importsBelow (ig : NameMap (Array Name)) (ms : NameSet) : NameSet :=
(ig.upstreamOf ms).fold (σ := NameSet) (fun _ ↦ ·.insert ·) {}
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 sure that I understand here: importGraph is a NameMap (Array Name), while transitiveClosure returns a NameMap NameSet. I do not really know how to then use upstreamOf, since that function wants an importGraph as an input.

Mathlib/Tactic/Linter/MinImports.lean Show resolved Hide resolved
@kim-em
Copy link
Contributor

kim-em commented Oct 28, 2024

bors merge

@github-actions github-actions bot added the ready-to-merge This PR has been sent to bors. label Oct 28, 2024
mathlib-bors bot pushed a commit that referenced this pull request Oct 28, 2024
This PR makes the `minImports` linter report more information:
* the number of increase imports,
* which previously minimal imports became redundant,
* which new minimal imports should be added.

Prompted by [this Zulip thread](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/minImports.20linter.20request).
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Oct 28, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: add by how many modules imports grew [Merged by Bors] - feat: add by how many modules imports grew Oct 28, 2024
@mathlib-bors mathlib-bors bot closed this Oct 28, 2024
@mathlib-bors mathlib-bors bot deleted the adomani/minImport_increase_by branch October 28, 2024 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors. t-linter Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants