-
Notifications
You must be signed in to change notification settings - Fork 373
Remove the dependency on astor for Pythons ≥ 3.9 #1999
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
Conversation
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.
Aside from a few more small changes, lgtm
hy/_compat.py
Outdated
|
||
if PY3_9: | ||
|
||
import ast, math, cmath |
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.
The math
and cmath
imports appear irrelevant.
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.
Yep, they're leftovers.
|
||
import ast, math, cmath | ||
class Unparser(ast._Unparser): | ||
# Work around some limitations of Python's `ast.unparse`. |
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.
Add a reference to python/cpython#24897. Since it's going to be backported to 3.9, we can eventually remove this workaround once it lands.
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.
Done.
Python 3.9 added
ast.unparse
, which can do most of the work. It has some bugs that I fixed inastor
, which I've worked around here, but I've submitted a patch to CPython to fix them for real (python/cpython#24897).