From fc83af0319abbbd1d178d18af931dc9a9cb7f450 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Duquesnoy Date: Tue, 29 Sep 2026 15:42:34 +0200 Subject: [PATCH] fix(python): require tree-sitter>=0.25 for the ABI 15 grammars The `core` extra pinned `tree-sitter~=0.23`, which admits 0.23.x and 0.24.x. All five generated parsers declare LANGUAGE_VERSION 15, and py-tree-sitter only accepts ABI 15 from 0.25: on 0.23.2 and 0.24.0 the Language object constructs but `Parser(language)` raises "ValueError: Incompatible Language version 15. Must be between 13 and 14". - pyproject: core = ["tree-sitter>=0.25,<1"] - README: install line pins "tree-sitter>=0.25" - bindings/python/tests: assert every grammar reports abi_version == 15 (the attribute itself only exists from 0.25, so the test also guards the floor) Fixes #56 Co-Authored-By: Claude Fable 5.1 --- README.md | 2 +- bindings/python/tests/test_binding.py | 12 ++++++++++++ pyproject.toml | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f3bfb267..5bbacaf6 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ npm ci cargo test --lib --package tree-sitter-objectscript python3 -m venv .venv source .venv/bin/activate -python3 -m pip install -U pip setuptools wheel pytest tree-sitter +python3 -m pip install -U pip setuptools wheel pytest "tree-sitter>=0.25" python3 setup.py build_ext --inplace PYTHONPATH=$PWD/bindings/python python3 -m pytest -q bindings/python/tests/test_binding.py npm test diff --git a/bindings/python/tests/test_binding.py b/bindings/python/tests/test_binding.py index 5c5cc1a2..6a4e04bd 100644 --- a/bindings/python/tests/test_binding.py +++ b/bindings/python/tests/test_binding.py @@ -50,3 +50,15 @@ def test_objectscript_routine_loads_and_has_queries(self): tree_sitter.Query(lang, tree_sitter_objectscript_routine.INDENTS_QUERY) except Exception: self.fail("Error loading objectscript routine query files") + + def test_grammars_are_abi_15_and_load_under_the_declared_floor(self): + # The generated parsers declare LANGUAGE_VERSION 15, which py-tree-sitter + # only supports from 0.25 (the `abi_version` attribute itself only exists + # from 0.25). Older releases fail to load them with "Incompatible Language + # version 15", so the `core` extra pins tree-sitter>=0.25. + for loader in ( + tree_sitter_objectscript.language_objectscript, + tree_sitter_objectscript_udl.language_objectscript_udl, + tree_sitter_objectscript_routine.language_objectscript_routine, + ): + self.assertEqual(tree_sitter.Language(loader()).abi_version, 15) diff --git a/pyproject.toml b/pyproject.toml index 63ecd63b..82aaa12c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ readme = "README.md" Homepage = "https://github.com/intersystems/tree-sitter-objectscript" [project.optional-dependencies] -core = ["tree-sitter~=0.23"] +core = ["tree-sitter>=0.25,<1"] [tool.cibuildwheel] build = "cp39-*"