What are the Pants' devs (and others) opinions on ...
# general
b
What are the Pants' devs (and others) opinions on the double-running of formatters (formatting vs. verifying) when running command like
./pants fmt lint
?
yapf
certainly isn't the fastest formatter in the west, and paying for format tools to run twice certainly isn't ideal. Of course, using
--changed-since
minimizes the files being run, so the timing overhead might be "annoying" at best. But this also bleeds into the issue of
lint
-ing dependees with formatters, which is wasteful as well 😬
h
Right now
yapf-when-run-as-a-linter
is treated as a separate tool than
yapf-when-run-as-a-formatter
Trying to think how we could do otherwise
Interesting idea to chew on
b
Yeah, I certainly understand the technical limitations and potential headache of trying to mesh the two. As far as Pants knows
fmt
and
lint
aren't even related. It's just the plugins that mix the two.
1
Saying nothing of it's difficulty or technical feasibility, but if Pants could query the cache and then make decisions from that, and/or produce synthetic cache results... the engine would have unlimited power (two examples:
lint
not running on files where the
fmt
cache is hot, or
lint
running on the subset of files where the
lint
cache isn't hot)
crack theories aside, I wonder if running
./pants fmt lint
could have an option to imply not running the formatters under
lint
Tangentially related to https://github.com/pantsbuild/pants/issues/10542 (in that Pants could be smarter about multiple-goals-in-one-command)
h
I think it would be neat to pull off
h
It would be
Well, one way to do this would be to proactively cache the fact that the linter passes if the formatter passes
There are several use cases under discussion where we might want to cache "fake" processes that we didn't actually run
Or more generally cache "facts" that don't necessarily correspond directly to a process
So this is another such use case
But there are complications: If you run
fmt
first, and you have multiple formatters, then formatter B might stomp on the output of formatter A, so that when subsequently formatter A is run as a linter, it will fail!
1
Obviously that is not a healthy or sustainable formatter setup, but it can happen
in which case not running formatter A the second time is actually incorrect
b
@happy-kitchen-89482 if this was opt-in that could be a "known thorn"
h
Yeah, I am fine with known thorns
👍 1
b
I'd say that's pretty much a non-starter though, as you'd never have a working CI validation, because you'd always be formatting
h
people can make an informed choice to trade off a little bit of correctness for a lot of performance
🙌 1
b
🙏