jwmatthews / treesitter_example

Example of playing with TreeSitter for Java parsing
Apache License 2.0
0 stars 0 forks source link

Using tree-sitter-languages get_languages("java") seeing: "TypeError: __init__() takes exactly 1 argument (2 given)" #1

Open jwmatthews opened 2 months ago

jwmatthews commented 2 months ago

I am testing out usage of https://pypi.org/project/tree-sitter-languages/ to avoid building the language parser. As I'm running a simple test I can't invoke def get_language(language)

Example

$ python3 java_scope_finder.py ./data/Example.java 7
Traceback (most recent call last):
  File "/Users/jmatthews/git/jwmatthews/treesitter_example/java_scope_finder.py", line 263, in <module>
    main()
  File "/Users/jmatthews/git/jwmatthews/treesitter_example/java_scope_finder.py", line 250, in main
    language = get_language('java')
               ^^^^^^^^^^^^^^^^^^^^
  File "tree_sitter_languages/core.pyx", line 14, in tree_sitter_languages.core.get_language
TypeError: __init__() takes exactly 1 argument (2 given)

Looks like tree-sitter-languages last release '1.10.2' is not compatible with a newer 'tree-sitter'.

Workaround I ended up with is to downgrade tree-sitter.

$ cat requirements.txt 
tree-sitter==0.21.3
tree-sitter-languages==1.10.2
jwmatthews commented 2 months ago

Related to https://github.com/grantjenks/py-tree-sitter-languages/issues/71