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.
Last updated: Dec 20 2023 at 11:08 UTC