https://pantsbuild.org/ logo
#development
Title
# development
c

clean-city-64472

10/07/2021, 2:45 PM
Messed around with dependency inference yesterday. I'm wondering if there is anyway you could print off a list of inferred deps and compare it to what is written in the BUILD file. It's kind of odd that you can't actually look at a BUILD file and say authoritatively whether it is fully leveraging inference or if it has overlaps with explicit requirements.
1
👍 2
h

hundreds-father-404

10/07/2021, 3:24 PM
You can! Pants 2.8 adds it to ./pants peek output
🙏 1
h

happy-kitchen-89482

10/07/2021, 3:42 PM
I recall that you liked having explicit BUILD file deps because it helped enforce dependency hygiene? You could instead write a custom goal that uses this peek data to enforce your dependency rules, so that you get the hygiene without the boilerplate.
👀 1
1
c

clean-city-64472

11/10/2021, 6:46 PM
Just coming back to this. I might be missing something but I don't see how this allows you to test if a dep would have been inferred had you not explicitly included it. When I add an explicit dep it shows up in both
dependencies
and
dependencies_raw
h

hundreds-father-404

11/10/2021, 6:47 PM
inferred = dependencies - dependencies_raw
c

clean-city-64472

11/10/2021, 6:50 PM
that doesn't seem to be true...
oh
if I put something that owuld have been inferred -it shows up in raw
^ this is true
The meta problem is just how to move from explicit dependencies to inferred dependencies in a sane way with some sort of CI enforcing a standard.
1
h

hundreds-father-404

11/10/2021, 7:03 PM
Oh, I see now what you mean. So yeah, I only think this query will be helpful as a migration step. You can do something like save the ouptut of
./pants peek ::
before you remove explicit deps, then after you remove explicit deps, Compare the two
👍 1
What are you hoping to do with CI?
c

clean-city-64472

11/10/2021, 7:04 PM
I think if you explicitly set a dep that would have been inferred that should cause a CI failure.
h

hundreds-father-404

11/10/2021, 7:05 PM
Ohh that's interesting. So the idea there is you really want to lean in to dep inference? For example, to avoid the issue of forgetting to update BUILD files when you change imports, whereby you are depending on something unnecessarily?
c

clean-city-64472

11/10/2021, 7:06 PM
Essentially. If you are migrating off of dep inference on a large codebase with many contributors you want to be able to lock in your gains as you go by adding CI coverage on BUILD files that no longer have explicit deps (other than those that aren't being inferred correctly).
1
h

hundreds-father-404

11/10/2021, 7:08 PM
That makes sense! Would you want to open a feature request? https://github.com/pantsbuild/pants/issues/new/choose I'm thinking about whether this should be global vs. per-language. Right now we have the
[python-infer]
subsystem for example, which could have the option live there
c

clean-city-64472

11/10/2021, 7:08 PM
Sure - will do