From c6822fe0033f092eeb9e15c4c809d53b5a5e9a76 Mon Sep 17 00:00:00 2001 From: Kirill Klenov Date: Fri, 20 Nov 2026 15:05:38 +0300 Subject: [PATCH 1/3] [peewee] Add stubs for playhouse extension modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cover playhouse.sqlite_ext.JSONField, playhouse.postgres_ext.ArrayField and playhouse.test_utils.count_queries, which were missing from the partial stubs. 🖇 --- stubs/peewee/playhouse/postgres_ext.pyi | 18 ++++++++++++++++++ stubs/peewee/playhouse/sqlite_ext.pyi | 11 +++++++++++ stubs/peewee/playhouse/test_utils.pyi | 13 +++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 stubs/peewee/playhouse/postgres_ext.pyi create mode 100644 stubs/peewee/playhouse/sqlite_ext.pyi create mode 100644 stubs/peewee/playhouse/test_utils.pyi 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..cba4e68db7f7 --- /dev/null +++ b/stubs/peewee/playhouse/sqlite_ext.pyi @@ -0,0 +1,11 @@ +from typing import Any + +from peewee import Expression, TextField + +class JSONField(TextField[str]): + def __init__(self, json_dumps: Any = ..., json_loads: Any = ..., **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..a389837a13be --- /dev/null +++ b/stubs/peewee/playhouse/test_utils.pyi @@ -0,0 +1,13 @@ +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: ... From 5ab66b81ea57d3a30293c9d87cbaebcffef513ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:08:06 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/peewee/playhouse/test_utils.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/peewee/playhouse/test_utils.pyi b/stubs/peewee/playhouse/test_utils.pyi index a389837a13be..0ed9a9ae3d5f 100644 --- a/stubs/peewee/playhouse/test_utils.pyi +++ b/stubs/peewee/playhouse/test_utils.pyi @@ -1,6 +1,5 @@ from logging import LogRecord from types import TracebackType - from typing_extensions import Self class count_queries: From 2933a12758d55fa1c60daa7984862ad00cc98fbb Mon Sep 17 00:00:00 2001 From: Kirill Klenov Date: Fri, 20 Nov 2026 15:10:33 +0300 Subject: [PATCH 3/3] [peewee] Allow missing playhouse members in stubtest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new playhouse extension stubs only cover a few names, so allowlist the rest and type the JSONField json_dumps/json_loads arguments. 🎂 --- stubs/peewee/@tests/stubtest_allowlist.txt | 2 ++ stubs/peewee/playhouse/sqlite_ext.pyi | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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/sqlite_ext.pyi b/stubs/peewee/playhouse/sqlite_ext.pyi index cba4e68db7f7..c39c1e3aa049 100644 --- a/stubs/peewee/playhouse/sqlite_ext.pyi +++ b/stubs/peewee/playhouse/sqlite_ext.pyi @@ -1,9 +1,12 @@ +from collections.abc import Callable from typing import Any from peewee import Expression, TextField class JSONField(TextField[str]): - def __init__(self, json_dumps: Any = ..., json_loads: Any = ..., **kwargs: Any) -> None: ... + 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: ...