Open lilatomic opened 1 year ago
"including upstream rules" might not be necessary. The case I considered was lockfile rules for python tools, where every tool registered *lockfile.rules()
. I included that in the rule generators because of that. But it turns out these were already registered as part of the python backend! so that might be the correct strategy here
There are now several systems which generate rules. These rule-generators themselves have several common tasks. We have the opportunity to solve them in a consistent way.
Simple utils:
runtime_checkable
protocols, or we could do more introspection. Pants already does similar filtering logic, there might be something to leverage there. We could also decide whether mixins or class decorators would be a good way of doing this.More complicated:
radon
has multiple subcommands). This can be as simple as slapping an@cache
annotation on the generator function. It would be nice to have something more semantically meaningful (even if it is onlyrule_generator = functools.cache
)I think I have a path forward on the simple utils. I think the only unknown for a v1 on those is where to put them. The more complicated ones could use some discussion. I'm not sure if it'd be good to just have an increasingly large bag of helpers, and I think it might be better to work up to having a RuleGenerator parent class which can provide some of this machinery (possibly automatically)