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

Update tree-sitter #73

Merged
merged 10 commits into from
Feb 17, 2025
2 changes: 1 addition & 1 deletion openhands_aci/linter/impl/treesitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from grep_ast import TreeContext, filename_to_lang
from grep_ast.parsers import PARSERS
from tree_sitter_languages import get_parser

from ..base import BaseLinter, LintResult
from .treesitter_compat import get_parser

# tree_sitter is throwing a FutureWarning
warnings.simplefilter('ignore', category=FutureWarning)
Expand Down
23 changes: 23 additions & 0 deletions openhands_aci/linter/impl/treesitter_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Compatibility layer for tree-sitter 0.24.0."""

import importlib
from tree_sitter import Language, Parser

# Cache of loaded languages
_language_cache = {}


def get_parser(language):
"""Get a Parser object for the given language name."""
if language not in _language_cache:
# Try to import the language module
module_name = f"tree_sitter_{language}"
try:
module = importlib.import_module(module_name)
_language_cache[language] = Language(module.language())
except ImportError:
raise ValueError(
f"Language {language} is not supported. Please install {module_name} package."
)

return Parser(_language_cache[language])
163 changes: 122 additions & 41 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openhands-aci"
version = "0.2.2"
version = "0.2.3"
description = "An Agent-Computer Interface (ACI) designed for software development agents OpenHands."
authors = ["OpenHands"]
license = "MIT"
Expand All @@ -17,7 +17,11 @@ scipy = "*"
networkx = "*"
litellm = "*"
gitpython = "*"
tree-sitter = "0.21.3"
tree-sitter = "^0.24.0"
tree-sitter-python = "^0.23.6"
tree-sitter-javascript = "^0.23.1"
tree-sitter-typescript = "^0.23.2"
tree-sitter-ruby = "^0.23.1"
grep-ast = "0.3.3"
diskcache = "^5.6.3"
flake8 = "*"
Expand Down