Skip to content

feat!: ABI 15 & QueryCursor#333

Merged
maxbrunsfeld merged 5 commits intomasterfrom
0.25
Jun 2, 2025
Merged

feat!: ABI 15 & QueryCursor#333
maxbrunsfeld merged 5 commits intomasterfrom
0.25

Conversation

@ObserverOfTime
Copy link
Member

@ObserverOfTime ObserverOfTime commented Feb 5, 2025

Breaking changes are marked with !.

Additions:

  • Language.name (getter)
  • Language.abi_version (getter)
  • Language.semantic_version (getter)
  • Language.supertypes (getter)
  • Language.subtypes(supertype)
  • Node.first_child_for_byte(byte)
  • Node.first_named_child_for_byte(byte)
  • Query.string_count (getter)
  • Query.capture_name(index)
  • Query.capture_quantifier(pattern_index, capture_index)
  • Query.string_value(index)
  • QueryCursor(query)
  • QueryCursor.match_limit (getter, setter, deleter)
  • QueryCursor.timeout_micros (getter, setter, deleter)
  • QueryCursor.did_exceed_match_limit (getter)
  • QueryCursor.set_max_start_depth(depth)
  • QueryCursor.set_byte_range(start, end)
  • QueryCursor.set_point_range(start, end)
  • QueryCursor.captures(node, predicate, progress_callback)
  • QueryCursor.matches(node, predicate, progress_callback)
  • LookaheadIterator.names()
  • LookaheadIterator.symbols()

Deprecations:

  • Language.version: use Language.abi_version
  • Language.query(source): use Query(language, source)
  • Parser.timeout_micros: use the progress_callback in parse()
  • QueryCursor.timeout_micros: use the progress_callback in matches() or captures()

Removals:

  • Node.child_containing_descendant(descendant): use Node.child_with_descendant(descendant) !
  • Query.match_limit: moved to QueryCursor.match_limit !
  • Query.set_match_limit(limit): moved to QueryCursor.match_limit !
  • Query.did_exceed_match_limit: moved to QueryCursor.did_exceed_match_limit !
  • Query.timeout_micros: moved to QueryCursor.timeout_micros !
  • Query.set_timeout_micros(timeout): moved to QueryCursor.timeout_micros !
  • Query.set_max_start_depth(depth): moved to QueryCursor.set_max_start_depth(depth) !
  • Query.set_byte_range(byte_range): moved to QueryCursor.set_byte_range(start, end) !
  • Query.set_point_range(point_range): moved to QueryCursor.set_point_range(start, end) !
  • Query.captures(node, predicate): moved to QueryCursor.captures(node, predicate, progress_callback) !
  • Query.matches(node, predicate): moved to QueryCursor.matches(node, predicate, progress_callback) !
  • LookaheadIterator.iter_names(): use LookaheadIterator.names() !

Changes:

  • Parser.parse(): encoding parameter also accepts "utf16le" & "utf16be"
  • Parser.parse(): added progress_callback parameter
  • LookaheadIterator.__next__(): yields tuple[int, str] !
  • LookaheadIterator.reset(state, language): renamed from reset_state !

@ObserverOfTime
Copy link
Member Author

@amaanq

@ChrisFloofyKitsune

This comment was marked as resolved.

@ChrisFloofyKitsune

This comment was marked as resolved.

@ChrisFloofyKitsune

This comment was marked as resolved.

@ObserverOfTime

This comment was marked as resolved.

@maxbrunsfeld
Copy link
Contributor

In my opinion, methods that in C return iterator structs should in Python return simple Lists of values. It will likely be more efficient, because crossing the Python to C border is expensive. It’s also simpler from an API perspective.

@ObserverOfTime
Copy link
Member Author

@maxbrunsfeld Can I have admin rights to this repo (like the Java and Kotlin ones) so I can actually merge PRs?

@ObserverOfTime ObserverOfTime linked an issue Mar 30, 2025 that may be closed by this pull request
@ObserverOfTime
Copy link
Member Author

@amaanq

@gpijat

This comment was marked as resolved.

@ObserverOfTime
Copy link
Member Author

@amaanq

haxtibal added a commit to haxtibal/tree-sitter-robot that referenced this pull request May 1, 2025
On publish, the pypi workflow currently regenerates our parser for ABI
15 because that's the default from the central workflow [1].

In Python, one needs py-tree-sitter [2] to load the robot language.
Since py-tree-sitter folks have not yet finished ABI 15 migration,
there's currently no way to load our binding. Using the lattest
py-tree-sitter 0.24 would fail with "ValueError: Incompatible Language
version 15. Must be between 13 and 14".

Therefore to make tree-sitter-robot available for users, we enforce ABI
14 on regeneration for upload.

PS: Some of the central language bindings have basically the same
problem. However, since they have published former pypi releases with
lower ABI versions, there's something users can fallback to. We don't
have previous releases, so no fallback is available.

[1] https://github.com/tree-sitter/workflows/blob/ec44bc4f4667a458dd397ed9864f1b560e8fdca2/.github/workflows/package-pypi.yml#L24
[2] https://github.com/tree-sitter/py-tree-sitter
[3] tree-sitter/py-tree-sitter#333
haxtibal added a commit to haxtibal/tree-sitter-robot that referenced this pull request May 1, 2025
On publish, the pypi workflow currently regenerates our parser for ABI
15 because that's the default from the central workflow [1].

In Python, one needs py-tree-sitter [2] to load the robot language.
Since py-tree-sitter folks have not yet finished ABI 15 migration [3],
there's currently no way to load our binding. Using the lattest
py-tree-sitter 0.24 would fail with "ValueError: Incompatible Language
version 15. Must be between 13 and 14".

Therefore to make tree-sitter-robot available for users, we enforce ABI
14 on regeneration for upload.

PS: Some of the central language bindings have basically the same
problem. However, since they have published former pypi releases with
lower ABI versions, there's something users can fallback to. We don't
have previous releases, so no fallback is available.

[1] https://github.com/tree-sitter/workflows/blob/ec44bc4f4667a458dd397ed9864f1b560e8fdca2/.github/workflows/package-pypi.yml#L24
[2] https://github.com/tree-sitter/py-tree-sitter
[3] tree-sitter/py-tree-sitter#333
@ObserverOfTime ObserverOfTime linked an issue May 27, 2025 that may be closed by this pull request
@ZedThree
Copy link

ZedThree commented Jun 2, 2025

@maxbrunsfeld @amaanq Please could someone merge this? Python projects are currently stuck using older versions of some grammars due to the language version conflict. Thanks! 🙂

@maxbrunsfeld maxbrunsfeld merged commit 9c78f3b into master Jun 2, 2025
12 checks passed
@maxbrunsfeld
Copy link
Contributor

Thanks @ObserverOfTime; nice work. sorry for the delay. It's a really big diff, but it all makes sense AFAICT.

@ObserverOfTime
Copy link
Member Author

Thanks @maxbrunsfeld. Now can I have write access so I can merge other PRs? :)

@ObserverOfTime ObserverOfTime deleted the 0.25 branch June 3, 2025 07:09
@ObserverOfTime ObserverOfTime restored the 0.25 branch June 3, 2025 07:10
@ObserverOfTime ObserverOfTime deleted the 0.25 branch June 3, 2025 07:11
TomJGooding added a commit to TomJGooding/textual that referenced this pull request Jul 15, 2025
Fix breaking change in tree-sitter v0.25.0 where `Query.captures` has
been moved to `QueryCursor.captures`.

Related PR: tree-sitter/py-tree-sitter#333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incompatible Language version 15. Must be between 13 and 14 Parser Hangs forever Parsing Kotling code

7 participants