https://pantsbuild.org/ logo
#development
Title
# development
c

curved-television-6568

03/09/2023, 10:58 PM
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

bitter-ability-32190

03/09/2023, 11:05 PM
Is this related to the fine work @careful-address-89803 is doing?
c

curved-television-6568

03/09/2023, 11:09 PM
it’s in the same space at least.. 🙂
not sure if this was the direction they were going in..?
h

happy-kitchen-89482

03/09/2023, 11:13 PM
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

bitter-ability-32190

03/09/2023, 11:14 PM
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

happy-kitchen-89482

03/09/2023, 11:15 PM
A lot of the boilerplate is due to resolve/lockfiles stuff, which I hope to get rid of soon!
👍 1
c

careful-address-89803

03/09/2023, 11:17 PM
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

curved-television-6568

03/09/2023, 11:20 PM
I’ll let you poke about.. see where the dust settles 😛
b

bitter-ability-32190

03/09/2023, 11:23 PM
I agree with Daniels take on generative programming
h

happy-kitchen-89482

03/09/2023, 11:26 PM
Within reason, so do I
metaclasses can drive you mental when debugging, but generally they are boon
c

curved-television-6568

03/09/2023, 11:28 PM
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

witty-crayon-22786

03/09/2023, 11:30 PM
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

curved-television-6568

03/09/2023, 11:31 PM
on it 👀
(thanks for the reminder)
w

witty-crayon-22786

03/09/2023, 11:35 PM
(thanks for implementing that feature!)
😇 2
13 Views