Skip to content

Commit

Permalink
Merge pull request biolab#6851 from ales-erjavec/fixes/ast-deprecations
Browse files Browse the repository at this point in the history
[MNT] Remove use of deprecated ast classes
  • Loading branch information
janezd authored Jul 12, 2024
2 parents 910d625 + 4466f94 commit 70ebf27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 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
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from distutils.command import config, build
from distutils.core import Extension

if sys.version_info < (3, 4):
sys.exit('Orange requires Python >= 3.4')

try:
import numpy
Expand Down Expand Up @@ -81,6 +79,9 @@
'Intended Audience :: Developers',
]

PYTHON_REQUIRES = ">=3.9"


requirements = ['requirements-core.txt', 'requirements-gui.txt']


Expand Down Expand Up @@ -512,6 +513,7 @@ def setup_package():
data_files=DATA_FILES,
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
python_requires=PYTHON_REQUIRES,
entry_points=ENTRY_POINTS,
zip_safe=False,
test_suite='Orange.tests.suite',
Expand Down

0 comments on commit 70ebf27

Please sign in to comment.