as I reviewed <@U051221NF>’s tools PR.. I got the ...
# development
c
as I reviewed @happy-kitchen-89482’s tools PR.. I got the feeling that it was many many lines that are pretty similar and nothing really interesting going on. And most importantly. as there are changes, we want to apply them at all those places. 🧵
Which brings me to the idea of: generating PythonTool classes.. instead managing thousands of lines of boilerplate by hand, why not have a some simple input file/target from which we can generate the required python sources.
in cases there are some additionals needed, those could easily be addressed as “custom mixins” to be included in the generated class.
I wouldn’t mind making some POC of this, given there are no hard objections against..
b
Is this related to the fine work @careful-address-89803 is doing?
c
it’s in the same space at least.. 🙂
not sure if this was the direction they were going in..?
h
This is an interesting idea. But let's please not right now! I'm in the middle of a sequence of changes to how those classes interact with resolves. Once that is done and those classes are dramatically simpler, we can potentially get rid of them, or they will be trivial enough that there will be no need to.
b
One thing I want to keep as a direction is to keep the "magic" to a level where people could use it easily to extend things in their own plugins in their own repos. Doing something too magical might block that. Other than that, I love boilerplate reduction
h
A lot of the boilerplate is due to resolve/lockfiles stuff, which I hope to get rid of soon!
👍 1
c
My end goal was to have the UX be as simple as Tox. You should just say something like "my tool is 'radon' on pypi, it is a linter, you run it with `radon cc`" and have the rest either auto-generated or automatically provided.
👍 1
Fwiw it seems more idiomatic in python to have runtime/import time metaprogramming (decorators, metaclasses) to compile-time metaprogramming (templating, codegen)
💯 1
c
I’ll let you poke about.. see where the dust settles 😛
b
I agree with Daniels take on generative programming
h
Within reason, so do I
metaclasses can drive you mental when debugging, but generally they are boon
c
I tend to get carried away without (why doesn’t that feel like the opposite of within?!) reason.. so it’s good I have you to bring me back to earth 😛
w
i would also point out that anything having to do with `@union`s should now be much more flexible after @curved-television-6568’s change to allow for calling the methods of instances (assuming that this example works: https://github.com/pantsbuild/pants/issues/16763#issuecomment-1458627916) … meaning that defining an interface marked as a
@union
with abstract methods should now be possible.
c
on it 👀
(thanks for the reminder)
w
(thanks for implementing that feature!)
😇 2