tree-sitter/py-tree-sitter

query failing in py-tree-sitter but compiling in tree-sitter playground

kiran-4444 opened this issue · 1 comments

I have this query:

(comparison_operator
  operators: "not" @not_op
  operators: "in" @in_op
 (#make-range! "not_in_op" @not_op @in_op))

When I try to generate a query from this using:

query = PY_LANGUAGE.query(
"""
(comparison_operator
  operators: "not" @not_op
  operators: "in" @in_op
 (#make-range? "not_in"))
"""
)

I get me this error:

Traceback (most recent call last):
  File "/Users/luna/Documents/core_stageflow/tmp/treesitter_test.py", line 29, in <module>
    query = PY_LANGUAGE.query(
            ^^^^^^^^^^^^^^^^^^
  File "/Users/luna/Library/Caches/pypoetry/virtualenvs/stageflow-8YdfEtib-py3.11/lib/python3.11/site-packages/tree_sitter/__init__.py", line 217, in query
    return _language_query(self.language_id, source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid syntax at offset 24

The exact same query is working in playground. Can someone help me why this isn't working? Thanks!

the playground was likely outdated at the time of your post. "not" and "in" was aliased to "not in"