diff --git a/tree_sitter/__init__.pyi b/tree_sitter/__init__.pyi index 3e3ac10..cc310e5 100644 --- a/tree_sitter/__init__.pyi +++ b/tree_sitter/__init__.pyi @@ -1,6 +1,7 @@ from enum import IntEnum from collections.abc import ByteString, Callable, Iterator, Sequence from typing import Annotated, Any, Final, Literal, NamedTuple, Protocol, Self, final, overload +from typing_extensions import deprecated class _SupportsFileno(Protocol): def fileno(self) -> int: ... @@ -15,8 +16,12 @@ class LogType(IntEnum): @final class Language: - # TODO(0.25): ptr: Callable[[], CapsuleType] | CapsuleType - def __init__(self, ptr: Annotated[int | object, "TSLanguage *"], /) -> None: ... + # TODO(0.25): ptr: Callable[[], object] | object + @overload + @deprecated("int argument support is deprecated") + def __init__(self, ptr: Annotated[int, "TSLanguage *"], /) -> None: ... + @overload + def __init__(self, ptr: Annotated[object, "TSLanguage *"], /) -> None: ... # TODO(0.25): implement name # @property diff --git a/tree_sitter/binding/language.c b/tree_sitter/binding/language.c index b8cb79e..858ddb8 100644 --- a/tree_sitter/binding/language.c +++ b/tree_sitter/binding/language.c @@ -16,6 +16,9 @@ int language_init(Language *self, PyObject *args, PyObject *Py_UNUSED(kwargs)) { } return -1; } + if (DEPRECATE("int argument support is deprecated") < 0) { + return -1; + } self->language = PyLong_AsVoidPtr(language); }