Skip to content

Commit

Permalink
feat(language): deprecate int constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Oct 23, 2024
1 parent 040d362 commit ac012e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tree_sitter/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tree_sitter/binding/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit ac012e9

Please sign in to comment.