Skip to content

Commit

Permalink
owfeatureconstructor: Remove deperecated ast classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-erjavec committed Jul 12, 2024
1 parent 910d625 commit 38bfff8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 0 additions & 9 deletions Orange/widgets/data/owfeatureconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import builtins
import math
import random
import logging
import ast
import types
import unicodedata
Expand Down Expand Up @@ -448,8 +447,6 @@ def freevars(exp: ast.AST, env: List[str]):
elif etype == ast.Starred:
# a 'starred' call parameter (e.g. a and b in `f(x, *a, *b)`
return freevars(exp.value, env)
elif etype in [ast.Num, ast.Str, ast.Ellipsis, ast.Bytes, ast.NameConstant]:
return []
elif etype == ast.Constant:
return []
elif etype == ast.Attribute:
Expand All @@ -466,10 +463,6 @@ def freevars(exp: ast.AST, env: List[str]):
return sum((freevars(e, env)
for e in filter(None, [exp.lower, exp.upper, exp.step])),
[])
elif etype == ast.ExtSlice:
return sum((freevars(e, env) for e in exp.dims), [])
elif etype == ast.Index:
return freevars(exp.value, env)
elif etype == ast.keyword:
return freevars(exp.value, env)
else:
Expand Down Expand Up @@ -997,8 +990,6 @@ def validate_exp(exp):
return all(map(validate_exp, subexp))
elif etype == ast.Starred:
return validate_exp(exp.value)
elif etype in [ast.Num, ast.Str, ast.Bytes, ast.Ellipsis, ast.NameConstant]:
return True
elif etype == ast.Constant:
return True
elif etype == ast.Attribute:
Expand Down
8 changes: 5 additions & 3 deletions Orange/widgets/data/tests/test_owfeatureconstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,15 @@ def freevars_(source, env=None):
self.assertEqual(freevars_("a + b", ["a", "b"]), [])
self.assertEqual(freevars_("a[b]"), ["a", "b"])
self.assertEqual(freevars_("a[b]", ["a", "b"]), [])
self.assertEqual(freevars_("a[b:3]", ["a", "b"]), [])
self.assertEqual(freevars_("a[b:c:d]", ["a", "b", "c", "d"]), [])

self.assertEqual(freevars_("f(x, *a)", ["f"]), ["x", "a"])
self.assertEqual(freevars_("f(x, *a, y=1)", ["f"]), ["x", "a"])
self.assertEqual(freevars_("f(x, *a, y=1, **k)", ["f"]),
["x", "a", "k"])
if sys.version_info >= (3, 5):
self.assertEqual(freevars_("f(*a, *b, k=c, **d, **e)", ["f"]),
["a", "b", "c", "d", "e"])
self.assertEqual(freevars_("f(*a, *b, k=c, **d, **e)", ["f"]),
["a", "b", "c", "d", "e"])

self.assertEqual(freevars_("True"), [])
self.assertEqual(freevars_("'True'"), [])
Expand Down

0 comments on commit 38bfff8

Please sign in to comment.