Skip to content

Commit

Permalink
Support gast.unparse
Browse files Browse the repository at this point in the history
This allows to remove the test dependency on astunparse, while adapting
CPython's astunparse to gast AST

Fix #64
  • Loading branch information
serge-sans-paille committed Oct 19, 2021
1 parent 6861e48 commit c9d91d2
Show file tree
Hide file tree
Showing 7 changed files with 1,115 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install astunparse pytest
pip install pytest
- name: Setup
run: |
python setup.py install
Expand Down
5 changes: 5 additions & 0 deletions gast/gast.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ def parse(*args, **kwargs):
return ast_to_gast(_ast.parse(*args, **kwargs))


def unparse(gast_obj):
from gast.unparser import unparse
return unparse(gast_obj)


def literal_eval(node_or_string):
if isinstance(node_or_string, AST):
node_or_string = gast_to_ast(node_or_string)
Expand Down
Loading

0 comments on commit c9d91d2

Please sign in to comment.