Skip to content
Merged
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: 1 addition & 1 deletion stubs/peewee/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "4.3.0"
version = "4.4.0"
upstream-repository = "https://github.com/coleifer/peewee"
# We're not providing stubs for all playhouse modules right now
# https://github.com/python/typeshed/pull/11731#issuecomment-2065729058
Expand Down
16 changes: 12 additions & 4 deletions stubs/peewee/peewee.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def callable_(c: object) -> TypeIs[Callable[..., object]]: ...
multi_types: tuple[type[Incomplete], ...]

_T = TypeVar("_T")
_R = TypeVar("_R")
_VT = TypeVar("_VT")
_F = TypeVar("_F", bound=Callable[..., Any])
_Model: TypeAlias = Model
Expand Down Expand Up @@ -54,6 +55,11 @@ class _FKKwargs(_FieldKwargs, total=False):
related_name: str | Callable[[Field[Any]], str] | None
rel_model: type[Model] | None

class classmethod_only(Generic[_T, _R]):
fn: Callable[[type[_T]], _R]
def __init__(self, fn: Callable[[type[_T]], _R]) -> None: ...
def __get__(self, instance: None, instance_type: type[_T] | None = None) -> Callable[[], _R]: ...

class attrdict(dict[str, _VT]):
def __getattr__(self, attr: str) -> _VT: ...
def __setattr__(self, attr: str, value: _VT) -> None: ...
Expand Down Expand Up @@ -980,8 +986,6 @@ class _BasePsycopgAdapter:
@overload
def isolation_level_str(self, isolation_level: _T) -> _T: ...

def server_side_cursor(self, conn): ...

class Psycopg2Adapter(_BasePsycopgAdapter):
json_type: Incomplete
jsonb_type: Incomplete
Expand All @@ -994,6 +998,7 @@ class Psycopg2Adapter(_BasePsycopgAdapter):
def is_connection_usable(self, conn) -> bool: ...
def is_connection_reusable(self, conn) -> bool: ...
def is_connection_closed(self, conn) -> bool: ...
def server_side_cursor(self, conn): ...

class Psycopg3Adapter(_BasePsycopgAdapter):
json_type: Incomplete
Expand All @@ -1007,6 +1012,7 @@ class Psycopg3Adapter(_BasePsycopgAdapter):
def is_connection_usable(self, conn) -> bool: ...
def is_connection_reusable(self, conn) -> bool: ...
def is_connection_closed(self, conn) -> bool: ...
def server_side_cursor(self, conn): ...

class PostgresqlDatabase(Database):
field_types: Incomplete
Expand All @@ -1029,6 +1035,8 @@ class PostgresqlDatabase(Database):
prefer_psycopg3: bool = False,
**kwargs,
) -> None: ...
@property
def index_value_literals(self) -> bool: ... # type: ignore[override]
def is_connection_usable(self) -> bool: ...
def begin(self, isolation_level: str | None = None) -> None: ...
def get_tables(self, schema: str | None = None) -> list[str]: ...
Expand Down Expand Up @@ -1816,6 +1824,7 @@ class Metadata:
def fields_to_index(self) -> list[Incomplete]: ...
def set_database(self, database: _DatabaseType) -> None: ...
def set_table_name(self, table_name) -> None: ...
def get_database_instance(self) -> _DatabaseType | None: ...

class SubclassAwareMetadata(Metadata):
models: Incomplete
Expand Down Expand Up @@ -1872,8 +1881,7 @@ class Model(metaclass=ModelBase):
def replace_many(cls, rows, fields=None): ...
@classmethod
def raw(cls, sql, *params) -> ModelRaw: ...
@classmethod
def delete(cls) -> ModelDelete: ...
delete: classmethod_only[Self, ModelDelete]
@classmethod
def create(cls, **query) -> Self: ...
@classmethod
Expand Down