:bike: :house: On some an aspect of eliding `upda...
# general
b
🚲 🏠 On some an aspect of eliding
update-build-files
into `fmt`/`fix`. • Let's say you're formatting your build files with
black
. Running
./pants fmt --only=black ::
with `black`en your Python code AND your
BUILD
files. How does that feel, as a user? The alternative is to make some "special" key (like
build-files-black
or similar), which feels worse to me. • Do we need/want options for "only BUILD files"/"everything but build files"? Those are possible, but tricky to find a good name for IMO.
h
Pretty sure I would expect
::
to format by BUILD files as well as my python code
b
The question is specifically about the
--only
part, not the specs part. Even though using black to format BUILD files will be opted in, is the user ready for
--only=black
to format non-Python files?
h
I think so?
Since BUILD files are python syntax
Or rather black applies to them, which is the real crux here
Imagine if black started also formatting json files or something, we’d expect that to work here
1
b
(I'm hoping that's the answer we settle on, but polling so I don't speak for users)
@flat-zoo-31952 the bikeshed enlistee
w
I think I'm generally more surprised that we have a special command to format build files. For better or worse, BUILD files are code - just not released to production. Just like I expect test code to get formatted, I would want BUILD files in the mix too, under the same umbrella command
b
@wide-midnight-78598 That's this change 🙂
💥 3
w
to me, the act of choosing a formatter is indicative of a somewhat power user, so noticing how choosing black as a formatter should not result in a big surprise when seeing
BUILD
files affected by it
1
f
It's hard to say what "makes sense" here, .BUILD files are python, sure, but for non-python users i assume it's possible that they wouldn't even know to enable the black backend
b
The dirty detail I guess I should've mentioned is users (really repo admins) will now be opting into build file formatters just like any other ones:
Copy code
...
backend_packages = [
    ...
    "build_files.fmt.black",
    ....
]
👍 1
f
I mean, .BUILD is python in a syntactic and technical sense, but I could make the argument that it's semantically not Python within the context of pants because using it doesn't require any python backend to be enabled
I think
fmt --only=black
formatting build files makes sense if you have that backend enabled
2
b
Yeah, sorry should've put that up top as well :)
f
maybe it's a little confusing in that the same switch refers to two different backends
b
Technically the switch refers to "any formatter whose
name
is 'black'"
👍🏻 1
👍 1
And that name is on the union type (unrelated ot the backend naming scheme)
(I want more conventions though, and stronger ones. Conventions is the hill I die on)
f
the real bikeshedding will come around
update-build-files
since it's a different autofixer than what you would use to
fix
python stuff
b
That's the magic, there'll be no confict there 😉
f
I think backend switches make it unlikely to break any workflows
b
And while we're talking workflows and switching, you'll be pleased to know my plan here is not to remove
update-build-files
. It'll be an undocumented goal, which just calls into the new code. We can discuss deprecation/removal separately 🙂
👍🏻 1
w
It'll be an undocumented goal
As in,
update-build-files
docs would be removed?
b
I would expect so, but subject for debate. All build file updating gets elided to
fmt
and
fix
w
I was thinking about the documentation, and then it reminded me about how I hate reading old blog posts/tutorials which use commands that just no-longer exist. I think it should probably exist in the API reference section - pointing at the new command, but no mention in the primary docs
👍🏻 1
b
Keep that in mind, and bright it up on PR if I forget 😛
👍 1
w
I say that mostly because I don't want to have to update my blog 🙂 Edit: This section https://sureshjoshi.com/development/pants-plugin-code-quality#build-files
👍 1
b
(link to blog?)
f
yeah, i'll clarify this in the design doc when I get around to it, but these things shouldn't be "undocumented" but rather "buried"
👍 3