Re:Black – Uncompromising Python code formatter
by mintcoffee on Friday May 17, 2019 @02:12PM
(#19942111)
JetBrains' MPS does exactly that - it stores the code as an AST, then renders it based on your own preferences:
Re:Black – Uncompromising Python code formatter
by SomeOldThrow on Friday May 17, 2019 @03:26PM
(#19942674)
Seems like the underlying format is unrelated to editing with customizable AST—in fact, that seems like it'd make things like code review pretty miserable. You'd have to upgrade all tooling to be ast-aware.
That said, once upgraded, that would be far, far, far superior to text. Our tooling hit the limits of text a long time ago: consider how terrible diffs are at communicating simple operations like indentation changes, or how basic our refactoring is even in the best case scenarios.
Re:Black – Uncompromising Python code formatter
by gen220 on Friday May 17, 2019 @03:16PM
(#19942577)
Wow this is a killer feature. If you're really zealous about how things "ought to be", now you can just write your preferences out once and be done with it. Stinks that it locks you into JetBrains, presumably: unless, is this part open-sourced?
Re:Black – Uncompromising Python code formatter
by thaumasiotes on Friday May 17, 2019 @08:49PM
(#19944903)
> What wheel did I point towards and suggest be reinvented?
Pretty printing.
Re:Black – Uncompromising Python code formatter
by wwright on Friday May 17, 2019 @05:28PM
(#19943736)
One term for this, I believe, is “structural editors.”
It always strikes me as strange that we spend our own effort and time on systems that mandate code style when my unambiguously correct style and my coworkers obviously incorrect style both end up converted to the same AST for any useful work. Why isn't style an entirely local choice, with a higher-level representation of the code stored canonically?
Better question: What wheel did I point towards and suggest be reinvented?