Zulip Chat Archive
Stream: general
Topic: import analysis
Scott Morrison (May 15 2019 at 00:37):
@Simon Hudon, is there a way to ask olean-rs to show me the chain of imports that results in Y being a dependency of X?
Scott Morrison (May 15 2019 at 00:37):
I have a few cases in mind where I think X really shouldn't depend on Y, but I'm having trouble manually locating the chain of imports.
Scott Morrison (May 15 2019 at 00:38):
Relatedly, I wonder if we could propose a new linting rule: "all imports go on separate lines". This would really help with import analysis, because you can then search/grep for import X and be sure of finding all the locations X is imported.
Scott Morrison (May 15 2019 at 00:41):
As an example, I'm interested in why src/category_theory/instances/Top/presheaf.lean depends on src/data/finset.lean.
Floris van Doorn (May 15 2019 at 02:09):
after a little bit of manual search: data.finset <- data.fintype <- data.set.finite <- data.set.countable <- topology.bases <- topology.opens <- category.instances.Top.opens <- category.instances.Top.presheaf
Floris van Doorn (May 15 2019 at 02:10):
but yeah, a tool for that would be useful :)
Reid Barton (May 15 2019 at 02:23):
About the separate lines--you could grep for ^import.* X or something similar
Floris van Doorn (May 15 2019 at 02:26):
That doesn't work for the following, right?
import data.nat.basic
data.set.basic
I used to write that if my first line of imports was too long.
Mario Carneiro (May 15 2019 at 02:28):
I would suggest looking for indented later lines
Mario Carneiro (May 15 2019 at 02:33):
I think ^import (\w+(\n )?.*)*?X should work, but it seems to crash vscode
Mario Carneiro (May 15 2019 at 02:34):
but actually, I think searching for data.finset should be sufficient, since it's very unlikely to show up in a lean file unless it's an import
Mario Carneiro (May 15 2019 at 02:35):
I suppose there are a few names that do double duty like tactic but most file names are not also constants
Simon Hudon (May 15 2019 at 15:34):
About the linting rule: we could get olean-rs to find all the places where a specific module is imported.
Yaël Dillies (Aug 08 2025 at 06:53):
@Paul Lezeau and I have been holding up #22503 for several months out of trying to reduce the import bump to a reasonable level. After several attempts, we got the original +89 bump down to... +72, but it's still far from satisfactory, and personally it's the first time I do not understand where the new imports come from.
Yaël Dillies (Aug 08 2025 at 06:55):
I think we've reached the point where more automated import analysis needs to be done. Does anyone have a good way of comparing the overall transitive dependencies before and after the PR? Paul has got import-graph#73 which would definitely help, but it hasn't been merged yet
Ruben Van de Velde (Aug 08 2025 at 07:26):
I'll send you the difference at some point today
Ruben Van de Velde (Aug 08 2025 at 07:40):
Commented on the PR
Last updated: Dec 20 2025 at 21:32 UTC