Skip to content

Commit 65f7b6c

Browse files
Sort Python safe built-ins (#5781)
Co-authored-by: Jiajie Zhong <[email protected]> Co-authored-by: Jiajie Zhong <[email protected]>
1 parent 412c829 commit 65f7b6c

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

redash/query_runner/python.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,31 @@ class Python(BaseQueryRunner):
5353
should_annotate_query = False
5454

5555
safe_builtins = (
56-
"sorted",
57-
"reversed",
58-
"map",
59-
"any",
56+
"abs",
6057
"all",
61-
"slice",
58+
"any",
59+
"bool",
60+
"complex",
61+
"dict",
62+
"divmod",
63+
"enumerate",
6264
"filter",
65+
"float",
66+
"int",
6367
"len",
64-
"next",
65-
"enumerate",
66-
"sum",
67-
"abs",
68-
"min",
68+
"list",
69+
"map",
6970
"max",
71+
"min",
72+
"next",
73+
"reversed",
7074
"round",
71-
"divmod",
75+
"set",
76+
"slice",
77+
"sorted",
7278
"str",
73-
"int",
74-
"float",
75-
"complex",
79+
"sum",
7680
"tuple",
77-
"set",
78-
"list",
79-
"dict",
80-
"bool",
8181
)
8282

8383
@classmethod

tests/query_runner/test_python.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from unittest import TestCase
2+
3+
from redash.query_runner.python import Python
4+
5+
6+
class TestPython(TestCase):
7+
def test_sorted_safe_builtins(self):
8+
src = list(Python.safe_builtins)
9+
assert src == sorted(src), 'Python safe_builtins package not sorted.'

0 commit comments

Comments
 (0)