diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 7d6ba1ff8..fc00d96c3 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -77,7 +77,6 @@ "stubs/SQLAlchemy", "stubs/stripe", "stubs/tqdm", - "stubs/tree-sitter", "stubs/ttkthemes", "stubs/urllib3", "stubs/vobject" diff --git a/stubs/tree-sitter/tree_sitter/__init__.pyi b/stubs/tree-sitter/tree_sitter/__init__.pyi index 12060f23f..d26b17620 100644 --- a/stubs/tree-sitter/tree_sitter/__init__.pyi +++ b/stubs/tree-sitter/tree_sitter/__init__.pyi @@ -3,7 +3,7 @@ from _typeshed import StrPath from collections.abc import Sequence # At runtime, Query and Range are available only in tree_sitter.binding -from tree_sitter.binding import Node as Node, Parser as Parser, Tree as Tree, TreeCursor as TreeCursor +from tree_sitter.binding import Node as Node, Parser as Parser, Query, Tree as Tree, TreeCursor as TreeCursor class Language: @staticmethod @@ -13,5 +13,5 @@ class Language: language_id: int # library_path is passed into ctypes LoadLibrary def __init__(self, library_path: str, name: str) -> None: ... - def field_id_for_name(self, name): ... - def query(self, source): ... + def field_id_for_name(self, name: str) -> int | None: ... + def query(self, source: str) -> Query: ... diff --git a/stubs/tree-sitter/tree_sitter/binding.pyi b/stubs/tree-sitter/tree_sitter/binding.pyi index ec4b031dd..f8d4d32d5 100644 --- a/stubs/tree-sitter/tree_sitter/binding.pyi +++ b/stubs/tree-sitter/tree_sitter/binding.pyi @@ -72,7 +72,9 @@ class Parser: @final class Query: # start_point and end_point arguments don't seem to do anything - def captures(self) -> list[tuple[Node, str]]: ... + # TODO: sync with + # https://github.com/tree-sitter/py-tree-sitter/blob/d3016edac2c33ce647653d896fbfb435ac2a6245/tree_sitter/binding.c#L1304 + def captures(self, node: Node) -> list[tuple[Node, str]]: ... @final class Range: