Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when calling get_language('any_language') #64

Open
mohmehdi opened this issue May 16, 2024 · 7 comments · May be fixed by #65
Open

error when calling get_language('any_language') #64

mohmehdi opened this issue May 16, 2024 · 7 comments · May be fixed by #65

Comments

@mohmehdi
Copy link

tree-sitter has updated the Language class and how they initialize it so now it takes just one parameter. here: example usage

@scanny
Copy link

scanny commented May 17, 2024

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.

@samuela
Copy link

samuela commented Jun 26, 2024

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)

@mohmehdi
Copy link
Author

@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

shabani1 added a commit to lexy-ai/lexy that referenced this issue Jul 11, 2024
- Fix `examples/code_search.ipynb` which was failing on
`get_language()`.
- Caused by
[issue](grantjenks/py-tree-sitter-languages#64)
in `tree-sitter` and `tree-sitter-languages`.
- The `transform_document` endpoint now returns the error message and
traceback when a transformer task fails.
  - Was previously throwing a 500.
@aamiralidev
Copy link

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

@restlessronin
Copy link

restlessronin commented Sep 12, 2024

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

serpent213 added a commit to serpent213/langchain that referenced this issue Oct 6, 2024
…ree_sitter_language_pack

tree-sitter-languages appears [dormant](grantjenks/py-tree-sitter-languages#64),
while [tree-sitter-language-pack](https://pypi.org/project/tree-sitter-language-pack/)
supports tree-sitter 0.22 and many languages.
serpent213 added a commit to serpent213/langchain that referenced this issue Oct 6, 2024
tree-sitter-languages appears dormant while tree-sitter-language-pack
supports tree-sitter 0.22 and many languages.

See:
grantjenks/py-tree-sitter-languages#64
https://pypi.org/project/tree-sitter-language-pack
serpent213 added a commit to serpent213/langchain that referenced this issue Oct 6, 2024
tree-sitter-languages appears dormant while tree-sitter-language-pack
supports tree-sitter 0.22 and many languages.

See:
grantjenks/py-tree-sitter-languages#64
https://pypi.org/project/tree-sitter-language-pack
serpent213 added a commit to serpent213/langchain that referenced this issue Oct 6, 2024
tree-sitter-languages appears dormant while tree-sitter-language-pack
supports tree-sitter 0.22 and many languages. It should be pretty much
a drop-in replacement.

See:
grantjenks/py-tree-sitter-languages#64
https://pypi.org/project/tree-sitter-language-pack
@thorwhalen
Copy link

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)

@thorwhalen
Copy link

I brought this issue to the attention of tree-sitter authors in this issue:

Versions 0.22+ break tree_sitter_languages.get_language

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants