diff --git a/stubs/peewee/@tests/stubtest_allowlist.txt b/stubs/peewee/@tests/stubtest_allowlist.txt index 4f13b464e2d2..0dde2407ee08 100644 --- a/stubs/peewee/@tests/stubtest_allowlist.txt +++ b/stubs/peewee/@tests/stubtest_allowlist.txt @@ -42,3 +42,5 @@ playhouse\.\w+? playhouse.flask_utils.PaginatedQuery playhouse.flask_utils.get_\w+ playhouse.flask_utils.object_list +# Only a small part of these modules is stubbed +playhouse\.(postgres_ext|sqlite_ext|test_utils)(\.\w+)* diff --git a/stubs/peewee/playhouse/postgres_ext.pyi b/stubs/peewee/playhouse/postgres_ext.pyi new file mode 100644 index 000000000000..ac70de7ce1a3 --- /dev/null +++ b/stubs/peewee/playhouse/postgres_ext.pyi @@ -0,0 +1,18 @@ +from typing import Any + +from peewee import Expression, Field + +class ArrayField(Field[list[Any]]): + dimensions: int + def __init__( + self, + field_class: type[Field[Any]] = ..., + field_kwargs: dict[str, Any] | None = ..., + dimensions: int = 1, + convert_values: bool = False, + *args: Any, + **kwargs: Any, + ) -> None: ... + def contains(self, *items: Any) -> Expression: ... + def contains_any(self, *items: Any) -> Expression: ... + def contained_by(self, *items: Any) -> Expression: ... diff --git a/stubs/peewee/playhouse/sqlite_ext.pyi b/stubs/peewee/playhouse/sqlite_ext.pyi new file mode 100644 index 000000000000..c39c1e3aa049 --- /dev/null +++ b/stubs/peewee/playhouse/sqlite_ext.pyi @@ -0,0 +1,14 @@ +from collections.abc import Callable +from typing import Any + +from peewee import Expression, TextField + +class JSONField(TextField[str]): + def __init__( + self, json_dumps: Callable[[Any], str] | None = ..., json_loads: Callable[[str], Any] | None = ..., **kwargs: Any + ) -> None: ... + def db_value(self, value: Any) -> str | None: ... + def python_value(self, value: str | None) -> Any: ... + def children(self) -> Expression: ... + def length(self, path: str | None = None) -> Expression: ... + def json_type(self) -> Expression: ... diff --git a/stubs/peewee/playhouse/test_utils.pyi b/stubs/peewee/playhouse/test_utils.pyi new file mode 100644 index 000000000000..0ed9a9ae3d5f --- /dev/null +++ b/stubs/peewee/playhouse/test_utils.pyi @@ -0,0 +1,12 @@ +from logging import LogRecord +from types import TracebackType +from typing_extensions import Self + +class count_queries: + count: int + def __init__(self, only_select: bool = False) -> None: ... + def get_queries(self) -> list[LogRecord]: ... + def __enter__(self) -> Self: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ...