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] - refactor(*): scrub imports #17568

Closed
wants to merge 9 commits into from
Closed

Conversation

semorrison
Copy link
Collaborator

For each file, we read each declaration and find the files containing each referenced declaration. This is the "needed" set. We then replace the imports with

  • imports which are needed
  • other needed files which would not otherwise be transitively imported

Thus we don't remove any imports merely because they are transitively redundant. Instead we remove imports only if they are genuinely unnecessary. We also have to add back in imports (because they have been removed from higher up the import hierarchy).

I've committed the Lean script (thanks Mario!) that generates the underlying data, but not the Mathematica notebook that does that import calculations and text replacement (because it's a mess, and I want this merged quickly before it rots).

  • We try not to reorder imports unnecessarily.
  • But we don't sort: anything new that needs to be added just comes after the existing imports.
  • This drops a few comments on import lines.
  • It replaces a few import X with import X.default. (I think this is not bad: we probably want to remove all the .default files anyway at some point.)

Open in Gitpod

@semorrison semorrison requested review from a team as code owners November 16, 2022 15:09
Comment on lines +50 to +52
fac' := by { rintros s (⟨⟩|⟨⟩); { ext x, simp only
[binary_fan.π_app_right, binary_fan.π_app_left, Module.coe_comp, function.comp_app,
linear_map.fst_apply, linear_map.snd_apply, linear_map.prod_apply, pi.prod], }, },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this an intended part of the diff?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this mysteriously slowed down. 🤷

@Vierkantor Vierkantor self-assigned this Nov 16, 2022
Copy link
Collaborator

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

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

I checked all the non-import changes with git diff c34a1aa4263bdf585dd705508c11d3b75836049e | grep '^[+-]' | grep -v '^[-+]import', and the imports should be fine as long as everything still builds. So let's get this merged quickly!

bors d+

@bors
Copy link

bors bot commented Nov 16, 2022

✌️ semorrison can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@leanprover-community-bot-assistant leanprover-community-bot-assistant added the delegated The PR author may merge after reviewing final suggestions. label Nov 16, 2022
@semorrison
Copy link
Collaborator Author

Thanks for the reviews. I have a local build success so I'm going to optimistically try this in bors. (I haven't yet built after merging the last master, so it may well fail.)

@semorrison
Copy link
Collaborator Author

bors merge p=10

@github-actions github-actions bot added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Nov 16, 2022
bors bot pushed a commit that referenced this pull request Nov 16, 2022
For each file, we read each declaration and find the files containing each referenced declaration. This is the "needed" set. We then replace the imports with
* imports which are needed
* other needed files which would not otherwise be transitively imported

Thus we don't remove any imports merely because they are transitively redundant. Instead we remove imports only if they are genuinely unnecessary. We also have to add back in imports (because they have been removed from higher up the import hierarchy).

I've committed the Lean script (thanks Mario!) that generates the underlying data, but not the Mathematica notebook that does that import calculations and text replacement (because it's a mess, and I want this merged quickly before it rots).

* We try not to reorder imports unnecessarily.
* But we don't sort: anything new that needs to be added just comes after the existing imports.
* This drops a few comments on `import` lines.
* It replaces a few `import X` with `import X.default`. (I think this is not bad: we probably want to remove all the .default files anyway at some point.)



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Nov 17, 2022

Build failed:

@semorrison
Copy link
Collaborator Author

bors merge p=10

bors bot pushed a commit that referenced this pull request Nov 17, 2022
For each file, we read each declaration and find the files containing each referenced declaration. This is the "needed" set. We then replace the imports with
* imports which are needed
* other needed files which would not otherwise be transitively imported

Thus we don't remove any imports merely because they are transitively redundant. Instead we remove imports only if they are genuinely unnecessary. We also have to add back in imports (because they have been removed from higher up the import hierarchy).

I've committed the Lean script (thanks Mario!) that generates the underlying data, but not the Mathematica notebook that does that import calculations and text replacement (because it's a mess, and I want this merged quickly before it rots).

* We try not to reorder imports unnecessarily.
* But we don't sort: anything new that needs to be added just comes after the existing imports.
* This drops a few comments on `import` lines.
* It replaces a few `import X` with `import X.default`. (I think this is not bad: we probably want to remove all the .default files anyway at some point.)



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Nov 17, 2022

Build failed:

@semorrison
Copy link
Collaborator Author

bors merge p=10

bors bot pushed a commit that referenced this pull request Nov 17, 2022
For each file, we read each declaration and find the files containing each referenced declaration. This is the "needed" set. We then replace the imports with
* imports which are needed
* other needed files which would not otherwise be transitively imported

Thus we don't remove any imports merely because they are transitively redundant. Instead we remove imports only if they are genuinely unnecessary. We also have to add back in imports (because they have been removed from higher up the import hierarchy).

I've committed the Lean script (thanks Mario!) that generates the underlying data, but not the Mathematica notebook that does that import calculations and text replacement (because it's a mess, and I want this merged quickly before it rots).

* We try not to reorder imports unnecessarily.
* But we don't sort: anything new that needs to be added just comes after the existing imports.
* This drops a few comments on `import` lines.
* It replaces a few `import X` with `import X.default`. (I think this is not bad: we probably want to remove all the .default files anyway at some point.)



Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@bors
Copy link

bors bot commented Nov 17, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title refactor(*): scrub imports [Merged by Bors] - refactor(*): scrub imports Nov 17, 2022
@bors bors bot closed this Nov 17, 2022
@bors bors bot deleted the imports branch November 17, 2022 07:53
bors bot pushed a commit that referenced this pull request May 3, 2023
This is another run of #17568, scrubbing unnecessary imports.

Like last time we only remove genuinely unneeded imports, and leave merely transitively redundant imports alone.

(I *still* disagree with the objectors to removing transitively redundant imports 

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
bors bot pushed a commit that referenced this pull request May 4, 2023
This is another run of #17568, scrubbing unnecessary imports.

Like last time we only remove genuinely unneeded imports, and leave merely transitively redundant imports alone.

(I *still* disagree with the objectors to removing transitively redundant imports 

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions. ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants