Skip to content

Commit

Permalink
Add stub file
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Apr 14, 2024
1 parent b98fcab commit 60d6674
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
87 changes: 87 additions & 0 deletions jq.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from collections.abc import Iterable
from typing import Any, Literal, overload

from typing_extensions import Self, TypeAlias, deprecated

JSON: TypeAlias = Any

class _EmptyValue: ...

_NO_VALUE: _EmptyValue

class _JqStatePool:
def __init__(self, program_bytes: bytes, args: Any) -> None: ...

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: ...
@overload
@deprecated("'transform' is kept for 0.1.x backwards compatibility")
def transform(
self,
value: JSON | _EmptyValue = _NO_VALUE,
text: JSON | _EmptyValue = _NO_VALUE,
*,
text_output: Literal[True],
multiple_output: Literal[False] = False,
) -> str: ...
@overload
@deprecated("'transform' is kept for 0.1.x backwards compatibility")
def transform(
self,
value: JSON | _EmptyValue = _NO_VALUE,
text: JSON | _EmptyValue = _NO_VALUE,
*,
text_output: Literal[False] = False,
multiple_output: Literal[True],
) -> list[JSON]: ...
@overload
@deprecated("'transform' is kept for 0.1.x backwards compatibility")
def transform(
self,
value: JSON | _EmptyValue = _NO_VALUE,
text: JSON | _EmptyValue = _NO_VALUE,
text_output: Literal[False] = False,
multiple_output: Literal[False] = False,
) -> JSON: ...

class _ProgramWithInput:
def __init__(self, jq_state_pool: _JqStatePool, bytes_input: bytes, *, slurp: bool) -> None: ...
def __iter__(self) -> _ResultIterator: ...
def text(self) -> str: ...
def all(self) -> list[JSON]: ...
def first(self) -> JSON: ...

class _ResultIterator:
def __init__(self, jq_state_pool: _JqStatePool, bytes_input: bytes, *, slurp: bool) -> None: ...
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: ...
@deprecated("'jq' is kept for 0.1.x backwards compatibility")
def jq(program: str) -> _Program: ...
Empty file added py.typed
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,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',
Expand All @@ -116,4 +117,3 @@ def _extract_tarball(self, tarball_path, lib_dir):
'Programming Language :: Python :: 3.11',
],
)

0 comments on commit 60d6674

Please sign in to comment.