Skip to content

Commit 11f5a61

Browse files
committed
[peewee] Update to 4.2.6
Closes: #16064 + reflect what was done in the library's stubs (mostly old objects were typed)
1 parent 5d4298c commit 11f5a61

2 files changed

Lines changed: 52 additions & 36 deletions

File tree

stubs/peewee/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "4.1.2"
1+
version = "4.2.6"
22
upstream-repository = "https://github.com/coleifer/peewee"
33
# We're not providing stubs for all playhouse modules right now
44
# https://github.com/python/typeshed/pull/11731#issuecomment-2065729058

stubs/peewee/peewee.pyi

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import re
22
import threading
3-
from _typeshed import Incomplete, SupportsKeysAndGetItem, Unused
3+
from _typeshed import Incomplete, SupportsKeysAndGetItem
44
from collections.abc import Callable, Generator, Iterable, Iterator
55
from datetime import date, datetime, time
66
from decimal import Decimal
77
from types import TracebackType
8-
from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, NoReturn, TypeAlias, TypedDict, overload, type_check_only
8+
from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, TypeAlias, TypedDict, overload, type_check_only
99
from typing_extensions import Self, TypeIs, TypeVar, Unpack
1010
from uuid import UUID
1111

1212
def callable_(c: object) -> TypeIs[Callable[..., object]]: ...
1313

1414
multi_types: tuple[type[Incomplete], ...]
1515

16-
def reraise(tp: Unused, value: BaseException, tb: TracebackType | None = None) -> NoReturn: ...
17-
1816
_T = TypeVar("_T")
1917
_VT = TypeVar("_VT")
2018
_F = TypeVar("_F", bound=Callable[..., Any])
@@ -205,6 +203,7 @@ class Source(Node):
205203
class _HashableSource:
206204
def __init__(self, *args, **kwargs) -> None: ...
207205
def alias(self, name) -> Self: ...
206+
def clone(self) -> _HashableSource: ...
208207
def __hash__(self) -> int: ...
209208
def __eq__(self, other) -> Expression | bool: ... # type: ignore[override]
210209
def __ne__(self, other) -> Expression | bool: ... # type: ignore[override]
@@ -289,13 +288,11 @@ class ColumnBase(Node):
289288
def __add__(self, rhs: Any) -> Expression: ...
290289
__sub__: ClassVar[Callable[[Self, Any], Expression]]
291290
__mul__: ClassVar[Callable[[Self, Any], Expression]]
292-
__div__: ClassVar[Callable[[Self, Any], Expression]]
293291
__truediv__: ClassVar[Callable[[Self, Any], Expression]]
294292
__xor__: ClassVar[Callable[[Self, Any], Expression]]
295293
def __radd__(self, rhs: Any) -> Expression: ...
296294
__rsub__: ClassVar[Callable[[Self, Any], Expression]]
297295
__rmul__: ClassVar[Callable[[Self, Any], Expression]]
298-
__rdiv__: ClassVar[Callable[[Self, Any], Expression]]
299296
__rtruediv__: ClassVar[Callable[[Self, Any], Expression]]
300297
__rand__: ClassVar[Callable[[Self, Any], Expression]]
301298
__ror__: ClassVar[Callable[[Self, Any], Expression]]
@@ -411,9 +408,12 @@ class Ordering(WrappedNode):
411408
collation: Incomplete
412409
nulls: Incomplete
413410
def __init__(self, node, direction, collation=None, nulls=None) -> None: ...
414-
def collate(self, collation=None) -> Ordering: ... # type: ignore[override]
411+
def collate(self, collation=None) -> Self: ... # type: ignore[override]
415412
def __sql__(self, ctx): ...
416413

414+
def Asc(node, collation=None, nulls=None) -> Ordering: ...
415+
def Desc(node, collation=None, nulls=None) -> Ordering: ...
416+
417417
class Expression(ColumnBase):
418418
lhs: Incomplete
419419
op: Incomplete
@@ -520,6 +520,9 @@ class NodeList(ColumnBase):
520520
def __init__(self, nodes, glue: str = " ", parens: bool = False) -> None: ...
521521
def __sql__(self, ctx): ...
522522

523+
def CommaNodeList(nodes) -> NodeList: ...
524+
def EnclosedNodeList(nodes) -> NodeList: ...
525+
523526
class _Namespace(Node):
524527
__slots__ = ("_name",)
525528
def __init__(self, name) -> None: ...
@@ -541,6 +544,7 @@ class DQ(ColumnBase):
541544
Tuple: Incomplete
542545

543546
class QualifiedNames(WrappedNode):
547+
def __init__(self, node, scope: int = 16) -> None: ...
544548
def __sql__(self, ctx): ...
545549

546550
class OnConflict(Node):
@@ -643,7 +647,7 @@ class Select(SelectBase):
643647
**kwargs,
644648
) -> None: ...
645649
def clone(self) -> Self: ...
646-
def columns(self, *columns, **kwargs) -> Self: ...
650+
def columns(self, *columns) -> Self: ...
647651
select = columns
648652
def select_extend(self, *columns) -> Self: ...
649653

@@ -805,12 +809,12 @@ class Database(_callable_context_manager):
805809
param: str
806810
quote: str
807811
server_version: Incomplete
808-
commit_select: bool
809812
compound_select_parentheses: Incomplete
810813
for_update: bool
811814
index_schema_prefix: bool
812815
index_using_precedes_table: bool
813-
limit_max: Incomplete
816+
index_value_literals: bool
817+
limit_max: int | None
814818
nulls_ordering: bool
815819
returning_clause: bool
816820
safe_create_index: bool
@@ -897,6 +901,7 @@ class SqliteDatabase(Database):
897901
field_types: Incomplete
898902
operations: Incomplete
899903
index_schema_prefix: bool
904+
index_value_literals: bool
900905
limit_max: int
901906
server_version: Incomplete
902907
truncate_table: bool
@@ -942,7 +947,6 @@ class SqliteDatabase(Database):
942947
def attach(self, filename, name) -> bool: ...
943948
def detach(self, name) -> bool: ...
944949
def last_insert_id(self, cursor, query_type=None): ...
945-
def rows_affected(self, cursor): ...
946950
def begin(self, lock_type=None) -> None: ...
947951
def get_tables(self, schema: str | None = None) -> list[str]: ...
948952
def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ...
@@ -973,6 +977,8 @@ class _BasePsycopgAdapter:
973977
@overload
974978
def isolation_level_str(self, isolation_level: _T) -> _T: ...
975979

980+
def server_side_cursor(self, conn): ...
981+
976982
class Psycopg2Adapter(_BasePsycopgAdapter):
977983
json_type: Incomplete
978984
jsonb_type: Incomplete
@@ -1003,7 +1009,6 @@ class PostgresqlDatabase(Database):
10031009
field_types: Incomplete
10041010
operations: Incomplete
10051011
param: str
1006-
commit_select: bool
10071012
compound_select_parentheses: Incomplete
10081013
for_update: bool
10091014
nulls_ordering: bool
@@ -1023,7 +1028,6 @@ class PostgresqlDatabase(Database):
10231028
) -> None: ...
10241029
def is_connection_usable(self) -> bool: ...
10251030
def last_insert_id(self, cursor, query_type=None): ...
1026-
def rows_affected(self, cursor): ...
10271031
def begin(self, isolation_level: str | None = None) -> None: ...
10281032
def get_tables(self, schema: str | None = None) -> list[str]: ...
10291033
def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ...
@@ -1049,7 +1053,6 @@ class MySQLDatabase(Database):
10491053
operations: Incomplete
10501054
param: str
10511055
quote: str
1052-
commit_select: bool
10531056
compound_select_parentheses: Incomplete
10541057
for_update: bool
10551058
index_using_precedes_table: bool
@@ -1200,7 +1203,6 @@ class Field(ColumnBase, Generic[_V]):
12001203
auto_increment: bool
12011204
default_index_type: Incomplete
12021205
field_type: ClassVar[str]
1203-
unpack: bool
12041206
null: Incomplete
12051207
index: Incomplete
12061208
unique: Incomplete
@@ -1263,7 +1265,7 @@ class BigAutoField(AutoField[_V]):
12631265
def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigAutoField[int]: ...
12641266

12651267
class IdentityField(AutoField[_V]):
1266-
def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> IdentityField[int]: ...
1268+
def __new__(cls, *args: Any, generate_always: bool = False, **kwargs: Unpack[_FieldKwargs]) -> IdentityField[int]: ...
12671269

12681270
class PrimaryKeyField(AutoField[_V]):
12691271
def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> PrimaryKeyField[int]: ...
@@ -1359,6 +1361,24 @@ class BlobField(FieldDatabaseHook, Field[_V]):
13591361

13601362
def db_value(self, value): ...
13611363

1364+
class JSONPath(ColumnBase):
1365+
def __init__(self, field, keys=..., as_text: bool = False) -> None: ...
1366+
def __getitem__(self, key) -> JSONPath: ...
1367+
def path(self, *keys) -> JSONPath: ...
1368+
def as_text(self, as_text: bool = True) -> Self: ...
1369+
def as_int(self) -> Cast: ...
1370+
def as_float(self) -> Cast: ...
1371+
def set(self, value) -> Expression: ...
1372+
def insert(self, value) -> Expression: ...
1373+
def replace(self, value) -> Expression: ...
1374+
def append(self, value) -> Expression: ...
1375+
def remove(self) -> Expression: ...
1376+
def length(self) -> Expression: ...
1377+
def contained_by(self, value) -> Expression: ...
1378+
def has_key(self, key) -> Expression: ...
1379+
def has_keys(self, key_list) -> Expression: ...
1380+
def has_any_keys(self, key_list) -> Expression: ...
1381+
13621382
class JSONField(FieldDatabaseHook, Field):
13631383
def __init__(self, dumps=None, loads=None, **kwargs) -> None: ...
13641384
def path(self, *keys): ...
@@ -1441,7 +1461,7 @@ class DateTimeField(_BaseFormattedField[_V]):
14411461
cls, formats: list[str] | None = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]
14421462
) -> DateTimeField[datetime]: ...
14431463

1444-
formats: Incomplete
1464+
formats: list[str]
14451465
def adapt(self, value): ...
14461466
def to_timestamp(self): ...
14471467
def truncate(self, part): ...
@@ -1468,7 +1488,7 @@ class DateField(_BaseFormattedField[_V]):
14681488
cls, formats: list[str] | None = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]
14691489
) -> DateField[date]: ...
14701490

1471-
formats: Incomplete
1491+
formats: list[str]
14721492
def adapt(self, value): ...
14731493
def to_timestamp(self): ...
14741494
def truncate(self, part): ...
@@ -1489,7 +1509,7 @@ class TimeField(_BaseFormattedField[_V]):
14891509
cls, formats: list[str] | None = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]
14901510
) -> TimeField[time]: ...
14911511

1492-
formats: Incomplete
1512+
formats: list[str]
14931513
def adapt(self, value): ...
14941514
@property
14951515
def hour(self): ...
@@ -1503,15 +1523,17 @@ class TimestampField(BigIntegerField[_V]):
15031523
resolution: Incomplete
15041524
ticks_to_microsecond: Incomplete
15051525
utc: Incomplete
1506-
formats: Incomplete
1526+
formats: list[str]
15071527

15081528
@overload
1509-
def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> TimestampField[datetime | None]: ...
1529+
def __new__(
1530+
cls, *args: Any, resolution: int = 1, utc: bool = False, null: Literal[True], **kwargs: Unpack[_FieldKwargs]
1531+
) -> TimestampField[datetime | None]: ...
15101532
@overload
1511-
def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> TimestampField[datetime]: ...
1533+
def __new__(
1534+
cls, *args: Any, resolution: int = 1, utc: bool = False, null: Literal[False] = False, **kwargs: Unpack[_FieldKwargs]
1535+
) -> TimestampField[datetime]: ...
15121536

1513-
def local_to_utc(self, dt) -> datetime: ...
1514-
def utc_to_local(self, dt) -> datetime: ...
15151537
def get_timestamp(self, value) -> float: ...
15161538
def db_value(self, value) -> int | None: ...
15171539
def python_value(self, value): ...
@@ -1779,7 +1801,6 @@ class Metadata:
17791801

17801802
@property
17811803
def entity(self) -> Entity: ...
1782-
def get_rel_for_model(self, model) -> tuple[list[Incomplete], list[Incomplete]]: ...
17831804
def add_field(self, field_name, field, set_attribute: bool = True) -> None: ...
17841805
def remove_field(self, field_name) -> None: ...
17851806
auto_increment: Incomplete
@@ -1807,7 +1828,6 @@ class ModelBase(type):
18071828
def __contains__(self, key) -> bool: ...
18081829
def __len__(self) -> int: ...
18091830
def __bool__(self) -> bool: ...
1810-
def __nonzero__(self) -> bool: ...
18111831
def __sql__(self, ctx): ...
18121832

18131833
class _BoundModelsContext(_callable_context_manager):
@@ -1944,7 +1964,7 @@ class BaseModelSelect(_ModelQueryHelper):
19441964
def except_(self, rhs) -> ModelCompoundSelectQuery: ...
19451965
__sub__ = except_
19461966
def __iter__(self): ...
1947-
def prefetch(self, *subqueries): ...
1967+
def prefetch(self, *subqueries, prefetch_type: int = ...): ...
19481968
def with_related(self, *loads: Load | ForeignKeyField[Any] | BackrefAccessor) -> Self: ...
19491969
def iterator(self, database: _DatabaseType | None = ...) -> Iterator[Any]: ...
19501970
def get(self, database: _DatabaseType | None = None): ...
@@ -2037,10 +2057,8 @@ class ModelObjectCursorWrapper(ModelDictCursorWrapper):
20372057
class ModelCursorWrapper(BaseModelCursorWrapper):
20382058
from_list: Incomplete
20392059
joins: Incomplete
2040-
dicts: bool
2041-
def __init__(self, cursor, model, select, from_list, joins, dicts: bool = False) -> None: ...
2042-
key_to_constructor: Incomplete
2043-
src_is_dest: dict[Incomplete, Incomplete]
2060+
def __init__(self, cursor, model, select, from_list, joins) -> None: ...
2061+
key_to_constructor: dict[Incomplete, tuple[Incomplete, Incomplete]]
20442062
src_to_dest: list[tuple[Incomplete, Incomplete, Incomplete, bool, Incomplete, bool]]
20452063
column_keys: list[Incomplete]
20462064
def initialize(self) -> None: ...
@@ -2056,13 +2074,11 @@ class _PrefetchQuery(NamedTuple):
20562074
model: Incomplete
20572075

20582076
class PrefetchQuery(_PrefetchQuery):
2059-
def __new__(
2060-
cls, query, fields=None, is_backref: bool | None = None, rel_models=None, field_to_name=None, model=None
2061-
) -> Self: ...
2077+
def __new__(cls, query, fields=None, is_backref: bool | None = None, rel_models=None, field_to_name=None) -> Self: ...
20622078
def populate_instance(self, instance, id_map) -> None: ...
20632079
def store_instance(self, instance, id_map) -> None: ...
20642080

2065-
def prefetch(sq, *subqueries): ...
2081+
def prefetch(sq, *subqueries, prefetch_type: int = ...): ...
20662082

20672083
class Load(Node):
20682084
def __init__(

0 commit comments

Comments
 (0)