happy-psychiatrist-90774
08/14/2024, 8:07 PMBUILD
, etc..)
My main issue is that using LintFilesRequest
I only get the list of files that the target provided, but I don't have any way of knowing whether I'm at the root or on any branch
I'm looking for a way to get the root path of the target, but I'm also open for any other suggestions for implementation or reference that might be useful 🙂happy-psychiatrist-90774
08/14/2024, 8:09 PMif 'pants.toml' not in request.elements:
exit_code = 1
But there must be a better way...fast-nail-55400
08/14/2024, 9:37 PMfast-nail-55400
08/14/2024, 9:37 PMfast-nail-55400
08/14/2024, 9:38 PMPathGlobs -> Digest
conversion to look at files in the repository. That bypasses logic in the core fmt/lint rules but maybe that is okay?fast-nail-55400
08/14/2024, 9:40 PMsrc/python/pants/backend/project_info/regex_lint.py
)fast-nail-55400
08/14/2024, 9:40 PMhappy-kitchen-89482
08/14/2024, 10:34 PMpants mylinter path/to/dir1
behave differently than pants mylinter path/to/dir1
, or does it always act on the entire source tree?happy-psychiatrist-90774
08/15/2024, 7:37 AMsrc/python
) I cannot know where I'm in the tree, hence I decided to always require running from root where pants.toml
is
2. I am using a single partition for all files, although I'm not sure that I see the benefit of creating a digest since all I care about is the file tree and it's already right there in request.elements
3. I was also asking myself if building a linter is the right way to do this... The reason I decided to go for it was because it'd make it so much easier to use instead of running a custom goal each timehappy-kitchen-89482
08/15/2024, 3:17 PMSpecs
product, which is a representation of the target specs the user entered on the cmd linehappy-kitchen-89482
08/15/2024, 3:17 PMhappy-psychiatrist-90774
08/15/2024, 4:16 PMfast-nail-55400
08/15/2024, 5:09 PMcheck
goal.fast-nail-55400
08/15/2024, 5:11 PMmy_global_lint_checks
, and the user would put an instance of that target somewhere in there repository. For now, let's assume the root BUILD
file. You can then have your plugin register to be invoked for the check
goal for that target and it would trigger whenever someone does pants check ::
for example.fast-nail-55400
08/15/2024, 5:12 PMfast-nail-55400
08/15/2024, 5:12 PMfast-nail-55400
08/15/2024, 5:14 PMmy_global_lint_checks(name="global_linter")
) then your plugin can generate a "synthetic" target into the BUILD tree via the applicable Pants API (SyntheticTargetsRequest
)happy-psychiatrist-90774
08/15/2024, 5:18 PMcheck
target is better than lint
Is there anything different between them, or is it just because my plugin sounds more fitting for this goal type?fast-nail-55400
08/15/2024, 5:23 PMlint
goal, then integrating with the check
goal might be easier since it just requires a FieldSet
subclass which can apply to your target.happy-psychiatrist-90774
08/15/2024, 5:24 PMfast-nail-55400
08/15/2024, 5:25 PMCheckRequest
with LintTargetsRequest
fast-nail-55400
08/15/2024, 5:25 PMcheck
and lint
)fast-nail-55400
08/15/2024, 5:27 PMlint
might make more sense, but sort of a judgment call.