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

bitter-ability-32190

08/16/2022, 4:30 PM
🚲 🏠 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

happy-kitchen-89482

08/16/2022, 4:32 PM
Pretty sure I would expect
::
to format by BUILD files as well as my python code
b

bitter-ability-32190

08/16/2022, 4:34 PM
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

happy-kitchen-89482

08/16/2022, 4:35 PM
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

bitter-ability-32190

08/16/2022, 4:35 PM
(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

wide-midnight-78598

08/16/2022, 4:39 PM
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

bitter-ability-32190

08/16/2022, 4:40 PM
@wide-midnight-78598 That's this change 🙂
💥 3
w

witty-family-13337

08/16/2022, 4:40 PM
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

flat-zoo-31952

08/16/2022, 4:52 PM
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

bitter-ability-32190

08/16/2022, 4:54 PM
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

flat-zoo-31952

08/16/2022, 4:54 PM
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

bitter-ability-32190

08/16/2022, 4:55 PM
Yeah, sorry should've put that up top as well :)
f

flat-zoo-31952

08/16/2022, 4:55 PM
maybe it's a little confusing in that the same switch refers to two different backends
b

bitter-ability-32190

08/16/2022, 4:55 PM
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

flat-zoo-31952

08/16/2022, 4:56 PM
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

bitter-ability-32190

08/16/2022, 4:57 PM
That's the magic, there'll be no confict there 😉
f

flat-zoo-31952

08/16/2022, 4:58 PM
I think backend switches make it unlikely to break any workflows
b

bitter-ability-32190

08/16/2022, 4:59 PM
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

wide-midnight-78598

08/16/2022, 5:13 PM
It'll be an undocumented goal
As in,
update-build-files
docs would be removed?
b

bitter-ability-32190

08/16/2022, 5:14 PM
I would expect so, but subject for debate. All build file updating gets elided to
fmt
and
fix
w

wide-midnight-78598

08/16/2022, 5:16 PM
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

bitter-ability-32190

08/16/2022, 5:17 PM
Keep that in mind, and bright it up on PR if I forget 😛
👍 1
w

wide-midnight-78598

08/16/2022, 5:17 PM
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

bitter-ability-32190

08/16/2022, 5:22 PM
(link to blog?)
f

flat-zoo-31952

08/16/2022, 5:32 PM
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
3 Views