Repository: iris-hep/qastle

Issue:
Require LINQ operator nodes to have at least one argument
[This line](https://github.com/iris-hep/qastle/blob/4617415f0e79846cac4860411353fcb2ff0fca83/qastle/linq_util.py#L88) will throw an `IndexError` if a LINQ operator node has zero arguments. This is okay, but it would be a bit better to throw a more specific and descriptive `SyntaxError` before getting there.

Discussion:

Patch:
diff --git a/qastle/linq_util.py b/qastle/linq_util.py
index 1435d94..c62410b 100644
--- a/qastle/linq_util.py
+++ b/qastle/linq_util.py
@@ -85,6 +85,8 @@ class InsertLINQNodesTransformer(ast.NodeTransformer):
             function_name = node.func.id
             if function_name not in linq_operator_names:
                 return self.generic_visit(node)
+            if len(node.args) == 0:
+                raise SyntaxError('LINQ operators must specify a data source to operate on')
             source = node.args[0]
             args = node.args[1:]
         else:


Test patch:
diff --git a/tests/test_linq_util.py b/tests/test_linq_util.py
index 4100824..e732989 100644
--- a/tests/test_linq_util.py
+++ b/tests/test_linq_util.py
@@ -35,6 +35,11 @@ def test_visit_call_name_linq_operator():
     assert_ast_nodes_are_equal(final_ast, expected_ast)
 
 
+def test_visit_call_name_linq_operator_no_source():
+    with pytest.raises(SyntaxError):
+        insert_linq_nodes(ast.parse("First()"))
+
+
 def test_visit_call_generic():
     initial_ast = ast.parse('None()')
     final_ast = insert_linq_nodes(initial_ast)