Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stubs/peewee/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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+)*
18 changes: 18 additions & 0 deletions stubs/peewee/playhouse/postgres_ext.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Any

from peewee import Expression, Field

class ArrayField(Field[list[Any]]):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to make ArrayField generic over the type of the list items?

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,
Comment on lines +13 to +14

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, Any needs a comment explaining allowed types or how the item is used. (Field[Any] and dict[str, Any] are exceptions, since they are obvious.)

) -> None: ...
def contains(self, *items: Any) -> Expression: ...
def contains_any(self, *items: Any) -> Expression: ...
def contained_by(self, *items: Any) -> Expression: ...
14 changes: 14 additions & 0 deletions stubs/peewee/playhouse/sqlite_ext.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
12 changes: 12 additions & 0 deletions stubs/peewee/playhouse/test_utils.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Loading