diff --git a/.isort.cfg b/.isort.cfg index 19f8e6469..41c83d714 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,3 +1,3 @@ [settings] -known_third_party = ConfigSpace,aif360,astunparse,autoai_libs,black,graphviz,h5py,hyperopt,imblearn,jsonschema,jsonsubschema,lightgbm,numpy,pandas,pytest,pytorch_pretrained_bert,scipy,setuptools,sklearn,smac,spacy,sphinx_rtd_theme,tensorflow,tensorflow_hub,torch,torchvision,xgboost +known_third_party = ConfigSpace,aif360,autoai_libs,black,graphviz,h5py,hyperopt,imblearn,jsonschema,jsonsubschema,lightgbm,numpy,pandas,pytest,pytorch_pretrained_bert,scipy,setuptools,sklearn,smac,spacy,sphinx_rtd_theme,tensorflow,tensorflow_hub,torch,torchvision,xgboost profile = black diff --git a/lale/expressions.py b/lale/expressions.py index 40e6a4917..12f39e349 100644 --- a/lale/expressions.py +++ b/lale/expressions.py @@ -24,8 +24,6 @@ from copy import deepcopy from typing import Any, Dict, Literal, Optional, Union, overload -import astunparse - AstLits = (ast.Num, ast.Str, ast.List, ast.Tuple, ast.Set, ast.Dict, ast.Constant) AstLit = Union[ast.Num, ast.Str, ast.List, ast.Tuple, ast.Set, ast.Dict, ast.Constant] AstExprs = ( @@ -229,7 +227,7 @@ def __ne__(self, other): return False def __str__(self) -> str: - result = astunparse.unparse(self._expr).strip() + result = ast.unparse(self._expr).strip() if isinstance(self._expr, (ast.UnaryOp, ast.BinOp, ast.Compare, ast.BoolOp)): if result.startswith("(") and result.endswith(")"): result = result[1:-1] @@ -585,7 +583,7 @@ def _it_column(expr): return expr.attr else: raise ValueError( - f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" + f"Illegal {ast.unparse(expr)}. Only the access to `it` is supported" ) elif isinstance(expr, ast.Subscript): if isinstance(expr.slice, ast.Constant) or ( @@ -600,15 +598,15 @@ def _it_column(expr): return v.s else: raise ValueError( - f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" + f"Illegal {ast.unparse(expr)}. Only the access to `it` is supported" ) else: raise ValueError( - f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" + f"Illegal {ast.unparse(expr)}. Only the access to `it` is supported" ) else: raise ValueError( - f"Illegal {astunparse.unparse(expr)}. Only the access to `it` is supported" + f"Illegal {ast.unparse(expr)}. Only the access to `it` is supported" ) diff --git a/setup.py b/setup.py index 50f08fa2a..463af50c3 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,6 @@ "pandas", "packaging", "decorator", - "astunparse", "typing-extensions", ] diff --git a/test/test_core_misc.py b/test/test_core_misc.py index 0de6bd12e..7bcd46ad0 100644 --- a/test/test_core_misc.py +++ b/test/test_core_misc.py @@ -76,12 +76,12 @@ def test_transformers(self): class TestUnparseExpr(unittest.TestCase): def test_unparse_const38(self): - import astunparse + import ast from lale.expressions import it test_expr = it.hello["hi"] - str(astunparse.unparse(test_expr._expr)) + str(ast.unparse(test_expr._expr)) class TestOperatorWithoutSchema(unittest.TestCase):