Closed ibdafna closed 3 years ago
Seems to be happening using the py2vega tests in this repo:
test/test_py2vega.py ...........F...................... [100%]
======================================================= FAILURES =======================================================
____________________________________________________ test_subscript ____________________________________________________
def test_subscript():
code = 'value[0]'
> assert py2vega(code, whitelist) == 'value[0]'
test/test_py2vega.py:137:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
py2vega/main.py:340: in py2vega
return VegaExpressionVisitor(whitelist).visit(parsed.body)
../../miniconda3/envs/py2vega/lib/python3.9/ast.py:407: in visit
return visitor(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <py2vega.main.VegaExpressionVisitor object at 0x7f0c22048880>, node = <ast.Subscript object at 0x7f0c22048a30>
def visit_Subscript(self, node):
"""Turn a Python Subscript node into a Vega-expression."""
value = self.visit(node.value)
if isinstance(node.slice, ast.Index):
return '{value}[{index}]'.format(
value=value,
index=self.visit(node.slice.value)
)
if isinstance(node.slice, ast.Slice):
if node.slice.step is not None:
raise Py2VegaSyntaxError('Unsupported step for {} node'.format(node.slice.__class__.__name__))
args = [value, '0' if node.slice.lower is None else self.visit(node.slice.lower)]
if node.slice.upper is not None:
args += self.visit(node.slice.upper)
return 'slice({args})'.format(args=', '.join(args))
> raise Py2VegaSyntaxError('Unsupported {} node'.format(node.slice.__class__.__name__))
E File "<string>", line None
E py2vega.main.Py2VegaSyntaxError: Unsupported Constant node, note that only a subset of Python is supported
py2vega/main.py:323: Py2VegaSyntaxError
=================================================== warnings summary ===================================================
test/test_py2vega.py::test_nameconstant
test/test_py2vega.py::test_nameconstant
test/test_py2vega.py::test_nameconstant
test/test_py2vega.py::test_tuple
test/test_py2vega.py::test_tuple
test/test_py2vega.py::test_list
/home/idafna/miniconda3/envs/py2vega/lib/python3.9/ast.py:407: DeprecationWarning: visit_NameConstant is deprecated; add visit_Constant
return visitor(node)
test/test_py2vega.py: 38 warnings
/home/idafna/miniconda3/envs/py2vega/lib/python3.9/ast.py:407: DeprecationWarning: visit_Num is deprecated; add visit_Constant
return visitor(node)
test/test_py2vega.py: 32 warnings
/home/idafna/miniconda3/envs/py2vega/lib/python3.9/ast.py:407: DeprecationWarning: visit_Str is deprecated; add visit_Constant
return visitor(node)
-- Docs: https://docs.pytest.org/en/stable/warnings.html
=============================================== short test summary info ================================================
FAILED test/test_py2vega.py::test_subscript - File "<string>", line None
====================================== 1 failed, 33 passed, 76 warnings in 0.18s =======================================
Thanks. I will look at it on Tuesday 😊
We're seeing issues on test suites in the
ipydatagrid
repo when using Python 3.9.The error seems to originate in
py2vega
: "Unsupported Constant node, note that only a subset of Python is supported".Trace available below:
https://github.com/bloomberg/ipydatagrid/pull/191/checks?check_run_id=1991433011
@martinRenou perhaps you could point me in the right direction? Thanks :)