Going down the plugins rabbit hole once again now ...
# plugins
h
Going down the plugins rabbit hole once again now trying to implement a custom linter that goes over all files (regardless if they're a target or not) I'm trying to mimick
regex-lint
so I've created this very simple example, but I keep getting
Copy code
Rule entry <generator object AbstractLintRequest.rules at 0x70d1edabc580> had an unexpected type: <class 'generator'>. Rules either extend Rule or UnionRule, or are static functions decorated with @rule.
What am I missing here? 🤔 (code in the comments)
Copy code
from pants.core.goals.lint import LintFilesRequest, LintResult
from pants.engine.rules import collect_rules, rule
from pants.option.subsystem import Subsystem
from pants.util.logging import LogLevel


class TestLintSubsystem(Subsystem):
    options_scope = 'test-lint'
    name = 'test-lint'
    help = 'test linting'


class TestLintRequest(LintFilesRequest):
    tool_subsystem = TestLintSubsystem


@rule(desc='test linter', level=LogLevel.DEBUG)
async def run_tester(
    request: TestLintRequest.Batch, lint_subsystem: TestLintSubsystem
) -> LintResult:
    return LintResult(
        exit_code=1,
        stdout='test stdout',
        stderr='',
        linter_name=TestLintSubsystem.options_scope,
    )


def rules():
    return [
        *collect_rules(),
        TestLintRequest.rules(),
    ]
b
I wonder if
TestLintRequest.rules()
is what is returning a generator, and so needs to be
*
in to the parent list too, like
collect_rules()
f
Agreed, otherwise the rules returned by it won't be flattened into the list.
h
Oh, right 🤦‍♂️ That's exactly the issue Thank you!