diff --git a/jq.pyi b/jq.pyi new file mode 100644 index 0000000..d1de0f1 --- /dev/null +++ b/jq.pyi @@ -0,0 +1,51 @@ +from collections.abc import Iterable +from typing import Any, overload + +from typing_extensions import Self, TypeAlias + +JSON: TypeAlias = Any + +class _EmptyValue: ... + +_NO_VALUE: _EmptyValue + +class _Program: + def __init__(self, program_bytes: bytes, args: Any) -> None: ... + @overload + def input(self, value: JSON, text: _EmptyValue = _NO_VALUE) -> _ProgramWithInput: ... + @overload + def input(self, value: _EmptyValue = _NO_VALUE, *, text: str) -> _ProgramWithInput: ... + def input_value(self, value: JSON) -> _ProgramWithInput: ... + def input_values(self, values: Iterable[JSON]) -> _ProgramWithInput: ... + def input_text(self, text: str, *, slurp: bool = False) -> _ProgramWithInput: ... + @property + def program_string(self) -> str: ... + def __repr__(self) -> str: ... + +class _ProgramWithInput: + def __iter__(self) -> _ResultIterator: ... + def text(self) -> str: ... + def all(self) -> list[JSON]: ... + def first(self) -> JSON: ... + +class _ResultIterator: + def __iter__(self) -> Self: ... + def __next__(self) -> JSON: ... + +def compile(program: str, args: Any | None = None) -> _Program: ... +@overload +def all(program: str, value: JSON, text: _EmptyValue = _NO_VALUE) -> list[JSON]: ... +@overload +def all(program: str, value: _EmptyValue = _NO_VALUE, *, text: str) -> list[JSON]: ... +@overload +def first(program: str, value: JSON, text: _EmptyValue = _NO_VALUE) -> JSON: ... +@overload +def first(program: str, value: _EmptyValue = _NO_VALUE, *, text: str) -> JSON: ... +@overload +def iter(program: str, value: JSON, text: _EmptyValue = _NO_VALUE) -> _ResultIterator: ... +@overload +def iter(program: str, value: _EmptyValue = _NO_VALUE, *, text: str) -> _ResultIterator: ... +@overload +def text(program: str, value: JSON, text: _EmptyValue = _NO_VALUE) -> str: ... +@overload +def text(program: str, value: _EmptyValue = _NO_VALUE, *, text: str) -> str: ... diff --git a/py.typed b/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index b00b35d..5bf6573 100644 --- a/setup.py +++ b/setup.py @@ -114,6 +114,7 @@ def _extract_tarball(self, tarball_path, lib_dir): license='BSD 2-Clause', ext_modules = [jq_extension], cmdclass={"build_ext": jq_build_ext}, + package_data={"jq": ["py.typed"]}, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -129,4 +130,3 @@ def _extract_tarball(self, tarball_path, lib_dir): 'Programming Language :: Python :: 3.12', ], ) -