Skip to content

Commit 7045bd9

Browse files
committed
chore: drop astor and use ast.unparse
Signed-off-by: lafirm <136463254+lafirm@users.noreply.github.com>
1 parent 444c50d commit 7045bd9

3 files changed

Lines changed: 2 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ authors = [{ name = "SQLMesh Contributors" }]
77
license = { file = "LICENSE" }
88
requires-python = ">= 3.9"
99
dependencies = [
10-
"astor",
1110
"click",
1211
"croniter",
1312
"duckdb>=0.10.0,!=0.10.3",
@@ -198,7 +197,6 @@ disable_error_code = "annotation-unchecked"
198197
[[tool.mypy.overrides]]
199198
module = [
200199
"api.*",
201-
"astor.*",
202200
"IPython.*",
203201
"hyperscript.*",
204202
"py.*",

sqlmesh/core/model/common.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import typing as t
55
from pathlib import Path
66

7-
from astor import to_source
87
from difflib import get_close_matches
98
from sqlglot import exp
109
from sqlglot.helper import ensure_list
@@ -387,7 +386,7 @@ def get_first_arg(keyword_arg_name: str) -> t.Any:
387386
)
388387

389388
try:
390-
expression = to_source(first_arg)
389+
expression = ast.unparse(t.cast(ast.expr, first_arg))
391390
return eval(expression, env, local_env)
392391
except Exception:
393392
if strict_resolution:

sqlmesh/utils/metaprogramming.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
from numbers import Number
1818
from pathlib import Path
1919

20-
from astor import to_source
21-
2220
from sqlmesh.core import constants as c
2321
from sqlmesh.utils import format_exception, unique
2422
from sqlmesh.utils.errors import SQLMeshError
@@ -274,7 +272,7 @@ def normalize_source(obj: t.Any) -> str:
274272
if isinstance(node, ast.FunctionDef):
275273
node.returns = None
276274

277-
return to_source(root_node).strip()
275+
return ast.unparse(root_node).strip()
278276

279277

280278
def build_env(

0 commit comments

Comments
 (0)