bitter-ability-32190
08/28/2022, 5:43 PMfmt
and lint
(and the soon to be fix
, and thinking about targetless formatters/fixers) . lint
is expected to run:
• Get(LintResults, LintTargetsRequest())
• Get(LintResults, LintFilesRequest())
• Get(FmtResult, FmtTargetsRequest())
• (future) Get(FmtResult, FmtFilesRequest())
◦ Assuming BUILD file formatters are just specific file-formatters
• (future) Get(FixResult, FixTargetsRequest())
• (future) Get(FixResult, FixFilesRequest())
Ideally this is just collapses into two: target-tool-runs and targetless-tool-runs. It's techincally doable today, but formatters and fixers have to register multiple `UnionRule`s for the parent types: ...
UnionRule(FmtTargetsRequest, BlackRequest),
UnionRule(LintTargetsRequest, BlackRequest),
Which isn't ideal.
Thoughts?bitter-ability-32190
08/28/2022, 5:52 PM@union
class LintRequest: ...
@union
class FixRequest(LintRequest): ...
# Implementation detail that Fmt classes inherit from Fix classes
@union
class FmtRequest(FixRequest): ...
then in lint
request_types = union_membership.get(LintRequest, include_subclass_members=True)
Plus also some plumbing to convert a FmtResult
to LintResult
@rule
def convert(r: FmtResult) -> LintResult:
...
Then magic lint
gets to be mostly generic.
(We'd still need to support only
and --skip-formatters
, etc..., but I think those can be done in other ways)bitter-ability-32190
08/28/2022, 7:09 PMbitter-ability-32190
08/29/2022, 3:19 PMInvalid Get. Because an input type for `...` was annotated with `@union`, the value for that type should be a member of that union.