Messed around with dependency inference yesterday....
# development
c
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
You can! Pants 2.8 adds it to ./pants peek output
🙏 1
h
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
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
inferred = dependencies - dependencies_raw
c
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
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
I think if you explicitly set a dep that would have been inferred that should cause a CI failure.
h
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
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
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
Sure - will do