plain-carpet-73994
04/29/2021, 11:02 PMcheck
that runs lint
, typecheck
, etc. I know with a macro you can create multiple targets but it doesn't look like macros let you combine goals. I can create a custom rule but (1) is that necessary and (2) if so, I think I need to do some await Get(LintResult, Target, target)
like calls, once for each target, but I'm not sure what the right types to await
are for the other goals -- how do I find those?hundreds-father-404
04/29/2021, 11:08 PMtypecheck
and lint
, or anything else too?
You would basically copy and paste this: https://github.com/pantsbuild/pants/blob/860908b2828031f2cb0a03e05cc252df8d3aaf1a/src/python/pants/core/goals/typecheck.py#L134-L187
Except add in an equivalent block for LintRequest
and EnrichedLintResults
. Note that lint.py
has a lot of extra things going on to support an option --per-file-caching
and lint reports - you can ignore that codehappy-kitchen-89482
04/29/2021, 11:13 PMhundreds-father-404
04/29/2021, 11:14 PMplain-carpet-73994
04/29/2021, 11:14 PMalias
method that could go in BUILD
files or pants.toml
to define these kinds of things.happy-kitchen-89482
04/29/2021, 11:16 PMhundreds-father-404
04/29/2021, 11:24 PMall_typecheck_results = await MultiGet(
Get(EnrichedTypecheckResults, TypecheckRequest, request) for request in valid_typecheck_requests
)
all_lint_results = await MultiGet(
Get(EnrichedLintResults, LintRequest, request) for request in valid_lint_requests
)
Those evaluate sequentially. Instead, you can create a dedicated rule like this:
class AllLintResults(Collection[EnrichedLintResults]):
pass
class AllLintRequests(Collection[LintRequest]):
pass
@rule
def all_lint_results(requests: AllLintRequests) -> AllLintResults:
return await MultiGet(
Get(EnrichedLintResults, LintRequest, request) for request in requests
)
Ditto for typecheck. Then, you can now do in your `@goal_rule`:
all_lint_results, all_typecheck_results = await MultiGet(
Get(AllLintResults, AllLintRequests(valid_lint_requests)),
Get(AllTypecheckResults, AllTypecheckRequests(valid_lint_requests)),
)