Has anyone found or built a tool for automated edi...
# general
l
Has anyone found or built a tool for automated editing of pants BUILD files? I have tried bazel's buildozer but it can't seem to work for me.
h
I configured vscode to do it for me
I told vscode to treat
BUILD.pants
code as python (starlark, but good enough) and then it is subject to the same rules as the rest of our repo.
b
Buildozer works surprisingly well for editing them
l
@high-yak-85899 i am mostly trying to build some automation for larger-scale refactoring, so I don't know if that would help me
h
There are commands within pants goals to do large scale formatting already
l
@bitter-ability-32190 I haven't gotten it to work because we use a non-standard build file name (BUILD.pants) and buildozer can't seem to handle that
I am not doing formatting, i am trying to edit files
h
Gotcha
e
@loud-laptop-17949 have you rejected the obvious rename dance scripted up as a sandwich around buildozer?
b
There's buildifier and buildozer. One formats and one edits the editing one works well. I don't remember having a naming issue and we use BUILD.panta
f
I have tried bazel's buildozer but it can't seem to work for me.
I used
buildozer
only for a simple refactoring (like setting certain fields on and off), but it looks to be very powerful based on the docs and sample usage calls. Maybe you could share what you are trying to edit and we could experiment?
Copy code
$ buildozer 'set skip_yapf True' 'set skip_mypy True' ///...:%python_sources
$ buildozer 'set skip_yapf False' projectdir/subdir:%python_sources
l
@fresh-cat-90827 have you gotten that to work if your BUILD files have a different name/extension?
f
oh, let me give it a try. I've used the standard BUILD file name
l
@enough-analyst-54434 yeah I thought about renaming all the files and may end up there, but would prefer to avoid it. also though about dealing with the issues that forced us to use
.pants
in the first place (we have a bunch of random shell scripts called
build
)
f
yes, I remember those funny times with the conda related build files named
build
!
e
Blaming the wrong thing! build is fine, macOS is not.
💯 1
l
ha yeah that's part of the problem
f
case-insensitive funny times 😄
so no, I cannot run
buildozer
on anything else than BUILD, I am afraid. Folks complained about not being able to configure it, but they have only fixed it for BUCK 🙂 https://github.com/bazelbuild/buildtools/pull/58/files
can't pass via stdin either - was thinking about a Bash for loop or something and piping
e
That looks extremely easy to fork and go install then.
f
FWIW v
l
looks like I am going to have to fork buildozer to get what I want
f
it would be awesome to have it configurable, but this may take a while...
i.e. contribute upstream