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

prehistoric-afternoon-67621

03/25/2022, 4:27 PM
Hopefully a quick "quality of life" question but can anyone explain to me how to get
./pants fmt ::
with
black
to run on my BUILD files? I've seen reference to that ability but not sure how to wire it up. πŸ˜‡
βœ… 1
c

curved-television-6568

03/25/2022, 4:30 PM
Hi! It’s
./pants update-build-files
that does that for you.
πŸ™Œ 1
πŸ‘ 1
r

rhythmic-battery-45198

03/25/2022, 4:30 PM
AFAIK, formatting the BUILD files is part of the
update-build-files
goal
🎯 1
πŸ‘ 1
Any way to format
pants.toml
?
c

curved-television-6568

03/25/2022, 4:32 PM
No, that would require a 3rdparty tool..
βœ… 1
r

rhythmic-battery-45198

03/25/2022, 4:32 PM
OK
p

prehistoric-afternoon-67621

03/25/2022, 4:36 PM
Awesome thanks!!
πŸ‘ 1
I'm (just) now understanding why that command uses a different interpreter constraints than the
[python.interpreter_constraints]
option. πŸ‘
h

hundreds-father-404

03/25/2022, 5:25 PM
ah yeah you can force it to use certain interpreter constraints with
[black].interpreter_constraints
btw there's been much discussion to merge
tailor
with
update-build-files
, and then possiblyyyy to merge some of that with
fmt
p

prehistoric-afternoon-67621

03/25/2022, 5:26 PM
Fwiw I don't mind formatting the BUILD files with a separate command. But thanks for the context!
❀️ 1
My situation was that I had tool lockfile for black that reflected my
[python].interpreter_constraints
but when I would try to run
./pants update-build-files
it would fail because the lockfile didn't match
[black].interpreter_constraints
. Minor edge case but was confusing to me until now
πŸ‘ 1
πŸ‘€ 1
h

hundreds-father-404

03/25/2022, 5:28 PM
Would you mind opening a ticket explaining that edge case please? That's definitely confusing. https://github.com/pantsbuild/pants/issues/new/choose
p

polite-garden-50641

03/25/2022, 5:28 PM
I did:
find . -name BUILD | xargs black
locally and
find . -name "BUILD" | xargs python -m black --check
in ci (you have to have black installed locally or in CI somehow). I didn't try to move the new update build files goal....
p

prehistoric-afternoon-67621

03/25/2022, 5:29 PM
@hundreds-father-404 will do!
πŸ™Œ 1
Alright, I did my best to capture what's going on here. https://github.com/pantsbuild/pants/issues/14912
❀️ 1
3 Views