diff --git a/harmonizer/refactorer.py b/harmonizer/refactorer.py index 28eaa66..098333b 100644 --- a/harmonizer/refactorer.py +++ b/harmonizer/refactorer.py @@ -15,6 +15,11 @@ import black +try: + from ast import unparse +except ImportError: + from astunparse import unparse as unparse + class Refactorer: """ @@ -85,7 +90,7 @@ def suggest_dimensional_split(self) -> str: # Fix missing location info and unparse the entire module ast.fix_missing_locations(new_module) - unformatted_code = ast.unparse(new_module) + unformatted_code = unparse(new_module) # Format the generated code using black try: diff --git a/requirements.txt b/requirements.txt index 869cdd5..09187b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ pytest black==24.4.2 +astunparse==1.6.3 +astunparse==1.6.3 flake8 isort pre-commit