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

cold-vr-15232

04/28/2023, 11:07 AM
I can do this with some scripting, but maybe there is already a way to list python files that are not used? I vendored in some old code that has a lot of things I don't need and that I don't want to update so that it lints and checks properly.
b

broad-processor-92400

04/28/2023, 11:20 AM
pants peek ::
includes dependency information, so one approach would be to do your own processing based on that, as it sounds like you're aware of. (I don't personally know of a built-in way to do it/prepackaged way to answer that)
c

cold-vr-15232

04/28/2023, 11:27 AM
Thanks, yes, that's what I can do, just hoping I might not need to 🙂
e

enough-analyst-54434

04/28/2023, 11:30 AM
This is basically impossible to do in Pants since Pants supports target less goals. In other words answering the question means looking at all the roots of a dependency graph and deciding which ones you personally consider unused. With that human provided input, you can then automate the calculation.
IOW you can
pants run any/file.py
c

cold-vr-15232

04/28/2023, 11:33 AM
yes, I meant unused from a target's point of view. I can list all dependencies and subtract that list from all the files.
e

enough-analyst-54434

04/28/2023, 11:33 AM
So you mean files no target globs?
Ok, gotcha.
Conceptually that's a dead man walking FWIW. Pants has no need for targets in most cases. The fact we have them still and use tailor to sweep them under the rug is legacy.
👍🏽 1
2 Views