Skip to content

Commit 8c3fcf9

Browse files
committed
[peewee] Model.select() type contains the model being selected
[pre-commit.ci] auto fixes from pre-commit.com hooks
1 parent 3c62217 commit 8c3fcf9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

stubs/peewee/peewee.pyi

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from collections.abc import Callable, Generator, Iterable, Iterator
55
from datetime import datetime
66
from decimal import Decimal
77
from types import TracebackType
8-
from typing import Any, ClassVar, Final, Literal, NamedTuple, NoReturn, TypeVar, overload, type_check_only
8+
from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, NoReturn, TypeVar, overload, type_check_only
99
from typing_extensions import Self, TypeIs
1010
from uuid import UUID
1111

@@ -18,6 +18,7 @@ def reraise(tp: Unused, value: BaseException, tb: TracebackType | None = None) -
1818
_T = TypeVar("_T")
1919
_VT = TypeVar("_VT")
2020
_F = TypeVar("_F", bound=Callable[..., Any])
21+
_TModel = TypeVar("_TModel", bound=Model)
2122

2223
class attrdict(dict[str, _VT]):
2324
def __getattr__(self, attr: str) -> _VT: ...
@@ -1660,7 +1661,7 @@ class Model(metaclass=ModelBase):
16601661
@classmethod
16611662
def alias(cls, alias=None) -> ModelAlias: ...
16621663
@classmethod
1663-
def select(cls, *fields) -> ModelSelect: ...
1664+
def select(cls: type[_TModel], *fields) -> ModelSelect[_TModel]: ...
16641665
@classmethod
16651666
def update(cls, data=None, /, **update) -> ModelUpdate: ...
16661667
@classmethod
@@ -1782,11 +1783,11 @@ class ModelCompoundSelectQuery(BaseModelSelect, CompoundSelectQuery): # type: i
17821783
model: Incomplete
17831784
def __init__(self, model, *args, **kwargs) -> None: ...
17841785

1785-
class ModelSelect(BaseModelSelect, Select): # type: ignore[misc]
1786-
model: Incomplete
1786+
class ModelSelect(BaseModelSelect, Select, Generic[_TModel]): # type: ignore[misc]
1787+
model: _TModel
17871788
def __init__(self, model, fields_or_models, is_default: bool = False) -> None: ...
17881789
def clone(self) -> Self: ...
1789-
def select(self, *fields_or_models): ...
1790+
def select(self, *fields_or_models) -> ModelSelect[_TModel]: ...
17901791
def select_extend(self, *columns): ...
17911792
def switch(self, ctx=None) -> Self: ...
17921793
def join(self, dest, join_type="INNER JOIN", on=None, src=None, attr=None) -> Self: ... # type: ignore[override]

0 commit comments

Comments
 (0)