careful-address-89803
08/01/2022, 5:04 AM[testenv:radon]
deps = radon
commands =
radon cc -s --total-average --no-assert -nb src/
I thought it would be great if it were that easy to create a linter in Pants. So I hacked together a prototype here, and it looks like it "works" and all you need for a linter is:
def rules():
radoncc = make_linter(
"radoncc",
"radon",
"radon==5.1.0",
["cc", "-s", "--total-average", "--no-assert", "-n"],
)
return radoncc.rules()
2 questions:
1. is this a horrible hack that will explode? (I know it's a horrible hack that needs a lot of cleanup)
2. is this (or these sorts of helpers) something we'd like to include in Pants?wide-midnight-78598
08/01/2022, 12:37 PMcheck
goals.
Maybe it's worth eye-balling some of the existing linters/formatters, to see whether this would be a reasonable replacement?
Specifically I'm thinking about things like config files, ensuring help still works, could they be lockfile'd, export'ed, how would unit testing of the "made" linter work, etc?wide-midnight-78598
08/01/2022, 12:39 PMbitter-ability-32190
08/01/2022, 2:32 PMbitter-ability-32190
08/01/2022, 2:38 PMhundreds-father-404
08/01/2022, 3:10 PM@rule_helper
thing helps, that you can factor out rule logic now, even if they need to do await Get
inside the functionbitter-ability-32190
08/01/2022, 3:16 PMcareful-address-89803
08/01/2022, 3:19 PMbitter-ability-32190
08/01/2022, 3:22 PMhundreds-father-404
08/01/2022, 3:26 PMalways provide maintenance hatches.I like that principle. We try to do this, but haven't used the same phrasing
careful-address-89803
08/01/2022, 3:34 PMbitter-ability-32190
08/01/2022, 3:55 PMwide-midnight-78598
08/01/2022, 5:06 PMrule_helpers
, I wonder if we can create some composable rule_helpers for common workflows, to reduce even more cruft. It doesn't go as far as Daniel or Josh are suggesting (yet), but I like the idea of a lot of the common tools/workflows for linters/formatters are basically just Subsystems
, and any bootstrapping/custom tweaks can be in the subsystem file as a bootstrapper rule.
THAT would be excellent - as today a pretty simple lint plugin can be 6-8 files and 600-700 lines of code (including tests), about 30-40 of which are legitimately "novel".
If this could get closer to 3-4 files and 100-200 lines of targeted code, that would be amazingcareful-address-89803
08/01/2022, 5:35 PMexport
to a PythonToolBase. Things like that for other features would be neatcareful-address-89803
08/02/2022, 2:18 AMbitter-ability-32190
08/02/2022, 1:07 PMbitter-ability-32190
08/02/2022, 1:08 PMcareful-address-89803
08/02/2022, 1:25 PMsrc/python/pants/backend/python/
?bitter-ability-32190
08/02/2022, 3:49 PMcareful-address-89803
08/02/2022, 3:50 PMcareful-address-89803
08/04/2022, 4:11 AMwide-midnight-78598
08/15/2022, 12:23 PMbitter-ability-32190
08/15/2022, 1:00 PMwide-midnight-78598
08/15/2022, 1:02 PMbitter-ability-32190
08/15/2022, 2:39 PM*ClangFormat.lockfile_rules()
in the module's rules
function I suspectcareful-address-89803
08/15/2022, 3:25 PMcareful-address-89803
08/18/2022, 4:24 AM