bitter-ability-32190
03/09/2022, 4:42 PMwitty-crayon-22786
03/09/2022, 5:12 PMbitter-ability-32190
03/20/2022, 2:59 PM(LHS unique, RHS unique, exists-in-both-but-different)
as that is generic enough to be useful elsewhere, solves this case, and isn't tooooo hard to writebitter-ability-32190
03/21/2022, 2:31 PMbitter-ability-32190
03/21/2022, 7:25 PM@rule(level=LogLevel.DEBUG)
async def get_docformatter_process(request: DocformatterProcessRequest, docformatter: Docformatter) -> Process:
docformatter_pex = await Get(VenvPex, PexRequest, docformatter.to_pex_request())
process = await Get(
Process,
VenvPexProcess(
docformatter_pex,
argv=[
"--in-place",
*docformatter.args,
*request.snapshot.files,
],
input_digest=request.snapshot.digest,
output_files=request.snapshot.files,
description=(
f"Run Docformatter on {pluralize(len(request.field_sets), 'file')}."
),
level=LogLevel.DEBUG,
),
)
return process
witty-crayon-22786
03/21/2022, 7:30 PMDigestTrie
?bitter-ability-32190
03/21/2022, 7:37 PMDigestTrie
bitter-ability-32190
03/21/2022, 7:38 PMscalafmt
which formats in partitions 🤯 This might throw a wrench in my approachwitty-crayon-22786
03/21/2022, 7:40 PMI haven’t seen that issue 👀 I did implement if onyea, cool… otherwise it would have been recursive database access, heh.DigestTrie
witty-crayon-22786
03/21/2022, 7:40 PMAlthough I just bumped intoit does, yea… but it should still emit something that can be merged into a single Digest at the end to be committed (or not)which formats in partitionsscalafmt
bitter-ability-32190
03/21/2022, 7:41 PMfmt
request and a Process
.bitter-ability-32190
03/21/2022, 7:43 PMbitter-ability-32190
03/21/2022, 7:51 PMmessage
on FmtResult
to print the changed files and not stdout/stderr (those get logged)
• To do that we need to (maybe) diff snapshots, but a ProcessResult
has a Digest
, so we need to request a Snapshot
but the helper method(s) can't do async/await
• So I went the route of refactor so the formatters rules just return the process, then fmt.py
can do whatever it wantsbitter-ability-32190
03/21/2022, 7:53 PMbitter-ability-32190
03/21/2022, 7:57 PMbitter-ability-32190
03/21/2022, 7:58 PMwitty-crayon-22786
03/21/2022, 8:07 PMwitty-crayon-22786
03/21/2022, 8:09 PMbitter-ability-32190
03/21/2022, 8:09 PMlint
bitter-ability-32190
03/21/2022, 8:11 PMBut also, FmtResult holding Snapshots rather than Digests should be a relatively minor change if necessaryYeah that's the escape lever I'm going to use for now. Unfortunately it forces callers to
await
a Snapshot
from the process output.
It's no performance overhead because fmt
does this anyways.
The only downside is the boilerplate. Which could very well be cleaned up later
Yeah thats the shortcut way of getting this working. Because we can'twitty-crayon-22786
03/21/2022, 8:11 PMbitter-ability-32190
03/21/2022, 8:13 PMStyleRequest
into it's 2 children, and removes prior_formatter_result
in favor of just giving the formatter rules a snapshot
. I think it'd be one less await
per formatter.bitter-ability-32190
03/21/2022, 8:13 PMwitty-crayon-22786
03/21/2022, 8:24 PMYeah, unfortunately my refactor naively assumed there was a 1:1 between ait might still be possible to go this approach with a wrapper for a list of `Process`es to execute… i expect that the bigger question is just whether there are other post-processing steps that a tool might want to take which would require other manipulation of outputs before giving it to the next formatter / linterrequest and afmt
.Process
bitter-ability-32190
03/21/2022, 8:25 PMbitter-ability-32190
03/21/2022, 8:26 PMbitter-ability-32190
03/22/2022, 2:30 PM