textual icon indicating copy to clipboard operation
textual copied to clipboard

Incompatibility with `tree-sitter-markdown==0.5.0`

Open GaetanLepage opened this issue 6 months ago • 2 comments

textual version: 3.4.0.

When updating tree-sitter-markdown to its latest 0.5.0 version, the following textual tests fail:

=========================== short test summary info ============================
FAILED tests/text_area/test_languages.py::test_setting_builtin_language_via_attribute - ValueError: Incompatible Language version 15. Must be between 13 and 14
FAILED tests/text_area/test_languages.py::test_setting_builtin_language_via_constructor - ValueError: Incompatible Language version 15. Must be between 13 and 14
======= 2 failed, 2849 passed, 1 skipped, 4 xfailed, 1 warning in 16.57s =======

Is this something that textual should adapt too? Is it safe to skip those tests?

Context: bumping tree-sitter-markdown in nixpkgs. https://github.com/NixOS/nixpkgs/pull/411181

GaetanLepage avatar Jun 15 '25 07:06 GaetanLepage

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

github-actions[bot] avatar Jun 15 '25 07:06 github-actions[bot]

I don't think the Python bindings for tree-sitter even supports ABI 15 yet. The latest tree-sitter-markdown on PyPi is v0.3.2.

TomJGooding avatar Jun 15 '25 08:06 TomJGooding

They have merged this PR to their branch. After bumping it up to there (so that it works with tree-sitter 0.15) I get a couple of test failures, all related to this line:

=========================== short test summary info ============================
FAILED tests/test_widget.py::test_widget_construct - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_languages.py::test_setting_language_to_none - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_languages.py::test_update_highlight_query - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_languages.py::test_register_language - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_languages.py::test_setting_unknown_language - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_setting_themes.py::test_setting_unknown_theme_raises_exception - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_setting_themes.py::test_default_theme - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_setting_themes.py::test_setting_builtin_themes - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
FAILED tests/text_area/test_setting_themes.py::test_registering_and_setting_theme - AttributeError: 'tree_sitter.Query' object has no attribute 'captures'
= 9 failed, 2840 passed, 1 skipped, 4 xfailed, 10 warnings in 62.22s (0:01:02) =

I guess that file needs to be refactored to work with QueryCursor's instead.

dtomvan avatar Jul 10 '25 11:07 dtomvan

It looks there's definitely some major changes in ABI 15 which will need addressing.

However, the tree-sitter package on PyPI hasn't had a release since Jan 2025, so the whole Python ecosystem for tree-sitter is lagging behind. For example, the latest version of tree-sitter-markdown on PyPi is v0.3.2, so several versions behind v0.5.0 referenced in this issue.

I assume NixOS have taken it upon themselves to create their own versions of these tree-sitter packages?

TomJGooding avatar Jul 11 '25 17:07 TomJGooding

I assume NixOS have taken it upon themselves to create their own versions of these tree-sitter packages?

We are fetching tree-sitter-markdown and py-tree-sitter repos from GitHub due to them being outdated on PyPI

gepbird avatar Jul 11 '25 18:07 gepbird

So you've broken all Python packages that depend on tree-sitter in NixOS? Unless they also fetch from GitHub rather than PyPI releases? Sorry but I really don't understand how this beneits anyone.

TomJGooding avatar Jul 12 '25 01:07 TomJGooding

Good point, probably we should roll it back if it doesn't break other packages. Tracking this at upstream: https://github.com/tree-sitter-grammars/tree-sitter-markdown/issues/193

gepbird avatar Jul 12 '25 08:07 gepbird

We've done this because otherwise they wouldn't work with the tree-sitter package in NixOS. If we didn't bump the py-tree-sitter to the git version, every package using it would inherently be broken because it fails to build against TS 0.15 (ValueError: Incompatible Language version 15. Must be between 13 and 14). At least this way only packages which suffer from the breaking changes fail to build, which probably is a small subset (note that those failing builds are largely unrelated to the change at hand, they've been broken for longer)

dtomvan avatar Jul 12 '25 12:07 dtomvan

Related discussion: https://github.com/tree-sitter/py-tree-sitter/discussions/368

dtomvan avatar Jul 12 '25 12:07 dtomvan

Ugh, I think I see the problem. py-tree-sitter apparently uses the tree-sitter-rust package in some of its tests. The problem is that the latest release on PyPI isn't actually compatible, which I suspect is why you're seeing this "Incompatible Language version 15" failure in your build. Related issue here: https://github.com/tree-sitter/tree-sitter-rust/issues/273

TomJGooding avatar Jul 13 '25 10:07 TomJGooding

py-tree-sitter 0.25.0 was released btw

leona-ya avatar Jul 15 '25 10:07 leona-ya

py-tree-sitter 0.25.0 was released btw

Not yet according to PyPI? https://pypi.org/project/tree-sitter/#history

TomJGooding avatar Jul 15 '25 10:07 TomJGooding

https://github.com/tree-sitter/py-tree-sitter/commit/81d0188f3393c2076cd07b1cbcad751676ff7d6a I guess. It's tagged in git just not in the repos yet.

dtomvan avatar Jul 15 '25 19:07 dtomvan

How do you expect Textual to resolve this? Python packages install dependencies via PyPI, so why are the latest changes in GitHub repositories relevant?

TomJGooding avatar Jul 15 '25 19:07 TomJGooding

Not saying you should switch to a git dep right now, but you don't necessarily have to fetch dependencies from pypi: https://peps.python.org/pep-0508/#examples

dtomvan avatar Jul 15 '25 20:07 dtomvan

@GaetanLepage If we're finally agreed that this isn't a Textual problem, would you mind closing this issue?

TomJGooding avatar Jul 17 '25 21:07 TomJGooding

@GaetanLepage If we're finally agreed that this isn't a Textual problem, would you mind closing this issue?

Sure! Thanks for taking the time to answer :)

GaetanLepage avatar Jul 20 '25 23:07 GaetanLepage

I hope I solved your issue!

Consider sponsoring my work to continue to maintain and develop Textual.

  • Will McGugan

github-actions[bot] avatar Jul 20 '25 23:07 github-actions[bot]

py-tree-sitter 0.25.0 was released btw

Not yet according to PyPI? https://pypi.org/project/tree-sitter/#history

Well, it is now, and it's causing errors Workaround: Add tree-sitter<0.25 to your dependencies

uninstall-your-browser avatar Jul 20 '25 23:07 uninstall-your-browser