https://pantsbuild.org/ logo
#general
Title
# general
a

ambitious-actor-36781

09/26/2022, 8:46 PM
It’d be neat if generated code was run through formatters (selectively?) for you. We’re currently running our codegen output through BlackRequest->FmtResult and while it works it’s pretty janky due to how the rule(s) are cached and output is controlled. But short of copying the rule, it’s doesn’t seem that easy to do it in a cache-friendly way.
b

bitter-ability-32190

09/26/2022, 9:26 PM
Formatting codegen files isn't something the engine is prepped for, and I'm not sure how we'd accomplish that. Not to say we never will, but it'd take thought
a

ambitious-actor-36781

09/26/2022, 9:29 PM
Even if there was a reusable rule that could optionally be cached. So the fmt rule can use it like a verbose goal rule And the codegen rule can use it like a silent post-output step. How you would you encourage that, idk. But I’m probably in a niche use case.
b

bitter-ability-32190

09/26/2022, 9:30 PM
So, if you don't mind me asking. Why do you want them formatted?
a

ambitious-actor-36781

09/26/2022, 9:32 PM
We generate our code using AST.unparse, and then upload our code to a “lambda-like” environment. And it’s just impossible to read, navigate and debug without it. And our yaml->python outputted code is also used as a reference a fair bit.
But maybe I’m not that much of an edge case? Reading and debugging badly formatted code is the worst, it doesn’t matter if it comes from codegen or a developer.
b

bitter-ability-32190

09/26/2022, 9:48 PM
File an issue, I'll think about it (the solution)
👍 1
❤️ 1
3 Views