-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-38870: Implement Simple Preceding to AST Unparser #17377
bpo-38870: Implement Simple Preceding to AST Unparser #17377
Conversation
Do we need news entry for this fix? |
5919a2c
to
7d8648f
Compare
I am not sure why this exists and what it does but it seems wrong to me, at least with checking everything in ast. Lines 326 to 331 in ded8888
It was failing because of both _Levels and IntEnum . I first thinked an extra condition about if name not starts with underscore but it doesnt worked because of IntEnum . So I moved instance of AST check upper.
|
b2bdbcc
to
f5188b1
Compare
@pablogsal is it worth to mention there will be an extra field in certain nodes called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still didn't have time to go to the full PR but some general comments:
-
I find the diff very difficult to read. You rearranged many functions and change signatures so the diff is bigger than it should be and that makes it complicated to read the changes and how the feature is implemented. Please, try to change only the relevant things for this issue in particular.
-
The class should not modify the ast object that you pass into or mutate it in any way, so please, do not attach attributes to the nodes (like
_precedence_level
) or do any mutation over the tree. -
Bringing enum into the
ast
module will likely introduce another performance regression (please, measure).
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
d517b14
to
9a81efb
Compare
I have made the requested changes; please review again |
Thanks for making the requested changes! @pablogsal: please review the changes made to this pull request. |
I'm currently handling some urgent regressions on buildbots, so it will take me some time to come back to this :( |
Thanks for reviews @vstinner, can I get an |
You can add [WIP] to the PR title. |
@pablogsal @vstinner #17612 is merged and I rewrote this preceding patch with basing that delimiting changes. The diff is much more minimal right now. This patch tries to implement the preceding system that was also used in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me with the latest corrections!
Great job, @isidentical! 🎉
Well done @isidentical. I'm happy to see that the merged change now uses the enum module :-) |
Implement a simple precedence algorithm for ast.unparse in order to avoid redundant parenthesis for nested structures in the final output.
cc: @pablogsal
https://bugs.python.org/issue38870