Open mohmehdi opened 6 months ago
Quick-fix is to downgrade to treesitter==0.21.3
:
$ pip install -U tree-sitter==0.21.3
In my particular case that results in an unwelcome warning being emitted to the console at runtime:
.../python3.11/site-packages/tree_sitter/__init__.py:36: FutureWarning: Language(path, name) is deprecated. Use Language(ptr, name) instead.
but that is easily avoided in my case using the python -Wignore ...
command-line flag.
FWIW an example traceback:
Traceback (most recent call last):
File "/Users/samuelainsworth/dev/SWE-agent/poop.py", line 5, in <module>
language = get_language("python")
^^^^^^^^^^^^^^^^^^^^^^
File "tree_sitter_languages/core.pyx", line 14, in tree_sitter_languages.core.get_language
TypeError: __init__() takes exactly 1 argument (2 given)
@samuela I don't think they are going to update this repo.
The main tree-sitter project had a rewrite.
For python do this(from py-tree-sitter repo):
pip install tree-sitter-python
import tree_sitter_python as tspython
from tree_sitter import Language, Parser
PY_LANGUAGE = Language(tspython.language())
For any other languages, you have to wait until someone makes the PyPI package for it
I faced the same issue. I downgraded my version but not sure which one. Here are my versions of both tree-sitter & tree-sitter-languages Name: tree-sitter Version: 0.20.4 Name: tree-sitter-languages Version: 1.10.2
I'm facing this issue. I downgraded to 0.21.3 as suggested in the first response
tree-sitter: 0.21.3 tree-sitter-languages: 1.10.2
seems to be working so far
Same here for:
from tree_sitter_languages import get_language
TS_LANGUAGE = get_language('typescript')
Works for:
tree-sitter: 0.21.3
tree-sitter-languages: 1.10.2
but not for
tree-sitter: 0.22 (or higher)
where I get
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[2], [line 3](vscode-notebook-cell:?execution_count=2&line=3)
[1](vscode-notebook-cell:?execution_count=2&line=1) from tree_sitter_languages import get_language
----> [3](vscode-notebook-cell:?execution_count=2&line=3) TS_LANGUAGE = get_language('typescript')
File tree_sitter_languages/core.pyx:14, in tree_sitter_languages.core.get_language()
TypeError: __init__() takes exactly 1 argument (2 given)
I brought this issue to the attention of tree-sitter
authors in this issue:
How to load customized languages (compiled to a .so file) now?
tree-sitter has updated the Language class and how they initialize it so now it takes just one parameter. here: example usage