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

loud-laptop-17949

05/19/2022, 10:24 PM
We run linters and formatters via pants as part of our git pre-commit hooks and I have found a behavior I don't understand. When the only file changes is a BUILD file, pants will try a bunch of other files (maybe ones owned by that file?). Is that expected?
w

witty-crayon-22786

05/19/2022, 10:48 PM
yea, that’s expected. change detection is file level, rather than target level currently.
we can’t know whether some, all, or none of the target definitions in the BUILD file changed
l

loud-laptop-17949

05/19/2022, 10:49 PM
hmm ok. I think we will have to try to filter these out then
w

witty-crayon-22786

05/19/2022, 10:49 PM
do you use 111, or larger BUILD files?
l

loud-laptop-17949

05/19/2022, 10:50 PM
not sure what you mean by 111?
w

witty-crayon-22786

05/19/2022, 10:52 PM
hm, challenging to link to it apparently, but: the “Tip: one BUILD file per directory” callout in https://www.pantsbuild.org/docs/targets
l

loud-laptop-17949

05/19/2022, 10:52 PM
yeah we mostly do that
w

witty-crayon-22786

05/19/2022, 10:55 PM
PXL_20211111_204202651_2.jpg
(i had always assumed that the name came from google, so it was funny to see Pants cited as the origin in a book about Google)
l

loud-laptop-17949

05/19/2022, 11:00 PM
ha that's funny
yeah we are mostly 111 but there are some variances there
w

witty-crayon-22786

05/19/2022, 11:01 PM
anywho. i wouldn’t recommend skipping BUILD file changes in `lint`… would break adding/removing of
skip_*
flags, for example
l

loud-laptop-17949

05/19/2022, 11:02 PM
yeah but lint and fmt don't update or lint BUILD files, right?
you have to run update-build-files for that?
w

witty-crayon-22786

05/19/2022, 11:02 PM
no. but if you have edited a BUILD file, you might need to re-lint the files it owns (see above re: skip flags, or other settings like interpreter constraints)
l

loud-laptop-17949

05/19/2022, 11:03 PM
ah yes
w

witty-crayon-22786

05/19/2022, 11:03 PM
i.e. if you’ve edited the BUILD file and changed which version of python to lint with
4 Views