From 412db40a0bcb35d2a631ea5e74eb910b1f89feb3 Mon Sep 17 00:00:00 2001 From: TUTU244 Date: Thu, 16 Jul 2026 05:54:25 +0900 Subject: [PATCH] fix(code): pin tree-sitter-language-pack <1.0.0 in [code] extra (#1219) ## Description Closes # ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Performance improvement - [ ] Code refactoring (no functional changes) ## Changes Made - ## Testing - [ ] Unit tests pass (`pytest`) - [ ] Linting passes (`ruff check .`) - [ ] Type checking passes (`mypy headroom`) - [ ] New tests added for new functionality - [ ] Manual testing performed ### Test Output ```text # Paste relevant command output or artifact links here ``` ## Real Behavior Proof - Environment: - Exact command / steps: - Observed result: - Not tested: ## Review Readiness - [ ] I have performed a self-review - [ ] This PR is ready for human review ## Checklist - [ ] My code follows the project's style guidelines - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] I have updated the CHANGELOG.md if applicable ## Screenshots (if applicable) Add screenshots to help explain your changes. ## Additional Notes --------- Co-authored-by: JerrettDavis --- pyproject.toml | 10 +++++----- .../test_transforms/test_tree_sitter_thread_safety.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a46be9b74..18f04bd3f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,11 +91,11 @@ proxy-prod = [ "gunicorn>=21.0.0; sys_platform != 'win32'", ] # AST-based code compression (tree-sitter) -# NOTE: cap below 1.0. tree-sitter-language-pack 1.x is a breaking rewrite whose -# get_language()/get_parser() return the pack's own binding types instead of -# standalone tree_sitter.Language/Parser, so _get_parser() in -# transforms/code_compressor.py fails and code compression silently no-ops. -# The 0.x line (>=0.10,<1.0) returns standalone tree_sitter objects as expected. +# tree-sitter-language-pack >=1.0 removed the bundled tree-sitter package and +# switched to an incompatible internal node API (.kind vs .type, callable +# root_node, etc.). Pin to <1.0.0 so that tree-sitter>=0.25.2 is pulled in +# as a transitive dependency and the existing code_compressor.py node-walk +# logic continues to work. See issue #1216. code = [ "tree-sitter-language-pack>=0.10.0,<1.0", "tree-sitter>=0.25.2,<0.27", diff --git a/tests/test_transforms/test_tree_sitter_thread_safety.py b/tests/test_transforms/test_tree_sitter_thread_safety.py index 5d551bbe1..6c9c99387 100644 --- a/tests/test_transforms/test_tree_sitter_thread_safety.py +++ b/tests/test_transforms/test_tree_sitter_thread_safety.py @@ -98,7 +98,7 @@ def test_parser_usable_in_thread_pool() -> None: def parse_in_worker() -> bool: parser = _get_parser("python") - tree = parser.parse("x = 1\n") + tree = parser.parse(b"x = 1\n") return tree is not None with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: