You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty class body should pretty print as "pass" #31
On the one hand I can see the convenience, but on the other hand the pretty printer assumes that it is given a valid AST.
I think the bigger problem is that we don't have a convenient way to construct ASTs programmatically. Therefore we are currently forced to build the AST values directly, but the AST data type has too much slack in it. It is easy to create ASTs which do not correspond to valid Python parses.
We could patch the pretty printer to allow conveniences, like the one described in this issue. However, that is a bit of a slippery slope, given that there are probably lots of places where such conveniences could be introduced in the pretty printer.
I think a better solution is to add functionality for conveniently building valid ASTs programmatically, and leave the pretty printer to assume that it is given a valid AST.
Activity
bjpop commentedon Aug 3, 2016
Thanks @puffnfresh.
I'm not sure how I feel about this.
On the one hand I can see the convenience, but on the other hand the pretty printer assumes that it is given a valid AST.
I think the bigger problem is that we don't have a convenient way to construct ASTs programmatically. Therefore we are currently forced to build the AST values directly, but the AST data type has too much slack in it. It is easy to create ASTs which do not correspond to valid Python parses.
We could patch the pretty printer to allow conveniences, like the one described in this issue. However, that is a bit of a slippery slope, given that there are probably lots of places where such conveniences could be introduced in the pretty printer.
I think a better solution is to add functionality for conveniently building valid ASTs programmatically, and leave the pretty printer to assume that it is given a valid AST.
Cheers,
Bernie
puffnfresh commentedon Aug 4, 2016
@bjpop I agree:
bjpop commentedon Aug 10, 2016
I'm thinking of a library of "smart" constructor functions. Perhaps also quasi quotation, as mentioned in #13.