Hey! How come `pants fmt` doesn't run format over ...
# general
f
Hey! How come
pants fmt
doesn't run format over
BUILD
-files, and rather requires you to run
pants update-build-files
? I know the latter does more, but how come the
fmt
doesn't at least run the formatter over them?
➕ 3
k
I run 'fix' instead of 'fmt'
f
I'm pretty sure
fix
won't format BUILD-files either
(or I am sure)
c
f
Re fix, see https://github.com/pantsbuild/pants/pull/17240
Sorry I might be missing something, but formatting is not covered. Or do you mean that it could also similarly like the "renamers" be moved over?
k
It at least does for me 🤷‍♂️ Do you have a fmt backend in pants.toml, f.ex: "pants.backend.build_files.fmt.black"
f
It at least does for me 🤷‍♂️ Do you have a fmt backend in pants.toml, f.ex:
"pants.backend.build_files.fmt.black"
Oh interesting! Does that backend provide fix goals, maybe even fmt goals to run fmt on build files?
That backend should be included by default, since
pants update-build-files --check
validates format, so you should not have to include a backend to have that formatting being done.
Ah it's also inconsistent. Will raise an issue
k
Maybe we are not talking about the same thing. If you want to auto format your build files when you run the fmt or fix command you need to added the backend for it to your pants.toml. Currently they have black, buildifier, ruff and yapf. I'm a black user. https://www.pantsbuild.org/dev/docs/using-pants/key-concepts/backends#available-stable-backends
f
Yes! I realized you needed the backend for it to format them with
fmt
, thanks! The confusion comes from them being formatted by update-build-files still even without the backend enabled, but then not by
fmt
unless enabling it 😅
👍 1