Skip to content

chore: add newline between public and private imports - #42063

Closed
felixpernegger wants to merge 8 commits into
leanprover-community:masterfrom
felixpernegger:spacepublicprivate
Closed

felixpernegger wants to merge 8 commits into
leanprover-community:masterfrom
felixpernegger:spacepublicprivate

Conversation

@felixpernegger

@felixpernegger felixpernegger commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

It is (or at least seems to be) convention to make a new line between public imports and private import (and public imports should come first). This PR adds those missing newlines.

Sometimes public imports were (mistakenly?) added after private imports. This PR fixes this as well and orders the imports of affected lines alphabetically.

As a standalone PR, this is pretty unimportant, but ought to make the diffs (and thus reviewing) of later PRs sorting imports etc prettier


Open in Gitpod

@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

PR summary 933477989a

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Tactic.PNatToNat 612 613 +1 (+0.16%)
Import changes for all files
Files Import difference
Mathlib.Tactic.PNatToNat 1

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 9334779).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.
No changes to weak technical debt.

Current commit 933477989a
Reference commit bb1587137f

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@felixpernegger
felixpernegger marked this pull request as draft July 24, 2026 13:50
@mathlib-bors

mathlib-bors Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This pull request is now in draft mode. No active bors state needed cleanup.

While this PR remains draft, bors will ignore commands on this PR. Mark it ready for review before using commands like bors r+ or bors try.

@felixpernegger
felixpernegger marked this pull request as ready for review July 24, 2026 13:59
@felixpernegger

Copy link
Copy Markdown
Contributor Author

Please no slowdown
!bench

@leanprover-radar

leanprover-radar commented Jul 24, 2026 •

Copy link
Copy Markdown

Benchmark results for dd2637b against 0434c03 are in. No significant results found. @felixpernegger

  • ✅ build//instructions: -54.8G (-0.04%)

No significant changes detected.

@felixpernegger felixpernegger changed the title chore: make space between private and public imports chore: add newline between public and private imports Jul 24, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
Similar (motivation) to #42063. This PR removes all newlines between public imports. This is not important as standalone PR, but makes diffs of later PRs nicer and thus help reviewing.

This includes space between ordinary public and `public meta` imports (and imports from Lean core). Maybe there should be a convention on there to be a newline for those cases, but this is not currently done in the vast majority of cases and not the scope of this PR.

Also some import orders of affected files are not ordered alphabetically still, which I did not fix as this is again not the goal of this PR.

Co-authored-by: Batixx <s59fpern@uni-bonn.de>
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 25, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jul 25, 2026
@themathqueen

Copy link
Copy Markdown
Member

It is (or at least seems to be) convention to make a new line between public imports and private import (and public imports should come first).

I'm not sure having a new line between imports is a rule we have. But I'm for having public import before import.

@felixpernegger

felixpernegger commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor Author

It is (or at least seems to be) convention to make a new line between public imports and private import (and public imports should come first).

I'm not sure having a new line between imports is a rule we have. But I'm for having public import before import.

I think this has been mentioned on Zulip here and there, originally here #mathlib4 > Mathlib has moved to the new module system @ 💬.

It is also a bit more common to have an emptyline (Regex public import.+\n\nimport gives 198 occurences vs public import.+\nimport giving 138) and has recently been discussed here #mathlib4 > Technical Debt Counters @ 💬. (Though I cant find the PR Yael is refering to)

mpacholski pushed a commit to mpacholski/mathlib4 that referenced this pull request Jul 30, 2026
Similar (motivation) to leanprover-community#42063. This PR removes all newlines between public imports. This is not important as standalone PR, but makes diffs of later PRs nicer and thus help reviewing.

This includes space between ordinary public and `public meta` imports (and imports from Lean core). Maybe there should be a convention on there to be a newline for those cases, but this is not currently done in the vast majority of cases and not the scope of this PR.

Also some import orders of affected files are not ordered alphabetically still, which I did not fix as this is again not the goal of this PR.

Co-authored-by: Batixx <s59fpern@uni-bonn.de>
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 3, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 3, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 5, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

# Conflicts:
#	Mathlib/Control/Monad/Cont.lean
#	Mathlib/Data/Fintype/Parity.lean
#	Mathlib/Data/List/Lookmap.lean
#	Mathlib/Data/List/ModifyLast.lean
#	Mathlib/Data/List/Sort.lean
#	Mathlib/Lean/Meta/RefinedDiscrTree/Encode.lean
#	Mathlib/LinearAlgebra/QuadraticForm/Complex.lean
#	Mathlib/Tactic/FieldSimp/Discharger.lean
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 11, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 14, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 22, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 28, 2026
@kim-em

kim-em commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Superseded by #44512, which groups public and private imports in 2,076 Mathlib files and has passed a full local Mathlib build.

@kim-em kim-em closed this Oct 5, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Oct 5, 2026
Group public imports before private imports, with a blank line between the groups, in 2,076 Mathlib files. Preserve the order within each group, import modifiers, and comments. No imports are removed or have their visibility changed.

Generated using the formatter in #44503. This is a source-only cleanup and can merge independently of the linter implementation.

Supersedes #42063.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants