Allow user to specify version_info#27
Conversation
…atches the current Python version. This is useful if the user is using e.g. gast to get a different AST version from the Python version they are using.
|
Rebased with the latest commits. |
pfalcon
left a comment
There was a problem hiding this comment.
+1 for the feature. Ideally, would allow to specify it via command line flag to __main__.py too.
The code could use some cleanup.
| f(x) | ||
|
|
||
| class Unparser: | ||
| class Unparser(object): |
There was a problem hiding this comment.
This is apparently change unrelated to the functionality provided.
| self.write(": ") | ||
| self.dispatch(t.kwarg.annotation) | ||
| elif hasattr(t.kwarg, 'id'): | ||
| self.write("**"+t.kwarg.id) |
There was a problem hiding this comment.
While I agree that would be better style, it's better to remain consistent with the rest of the file.
Other commits can improve the style globally if it's desired.
There was a problem hiding this comment.
it's better to remain consistent with the rest of the file.
Absolutely! I actually went and check how unparser.py has it, and in immediate vicinity of your changes I saw this: https://github.com/simonpercivall/astunparse/blob/master/lib/astunparse/unparser.py#L763 , that's why I made a comment. Looking in more detail, I see cases like https://github.com/simonpercivall/astunparse/blob/master/lib/astunparse/unparser.py#L804 , https://github.com/simonpercivall/astunparse/blob/master/lib/astunparse/unparser.py#L809 - so yes, your change looks good wrt to them.
Other commits can improve the style globally if it's desired.
I'm sure that falls on maintainer's plate. (I'm just a random passer-by who spotted an issue with the lib: #39, and proceeded to check how active maintenance of this repo by looking at pending PRs, then figuring I could benefit from this PR too. Oh, btw, ping @simonpercivall ;-) ).
There was a problem hiding this comment.
Off-topic: I'm pretty bad at maintaining this repository :/
Re. style: The style (and code) line-by-line should be kept as near identical as possible to the different versions of Tools/parser/unparse.py in the official cpython source tree.
|
Resolved conflicts.
No worries :) |
Allow user to specify version_info rather than assuming AST version matches the current Python version. This is useful if the user is using e.g. gast to get a different AST version from the Python version they are using.