diff --git a/stubs/peewee/METADATA.toml b/stubs/peewee/METADATA.toml index 4316ca82b9b3..391b04704b37 100644 --- a/stubs/peewee/METADATA.toml +++ b/stubs/peewee/METADATA.toml @@ -1,4 +1,4 @@ -version = "4.1.2" +version = "4.2.6" 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 diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index 50020776b131..fbd003f762df 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -1,11 +1,11 @@ import re import threading -from _typeshed import Incomplete, SupportsKeysAndGetItem, Unused +from _typeshed import Incomplete, SupportsKeysAndGetItem from collections.abc import Callable, Generator, Iterable, Iterator from datetime import date, datetime, time from decimal import Decimal from types import TracebackType -from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, NoReturn, TypeAlias, TypedDict, overload, type_check_only +from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, TypeAlias, TypedDict, overload, type_check_only from typing_extensions import Self, TypeIs, TypeVar, Unpack from uuid import UUID @@ -13,8 +13,6 @@ def callable_(c: object) -> TypeIs[Callable[..., object]]: ... multi_types: tuple[type[Incomplete], ...] -def reraise(tp: Unused, value: BaseException, tb: TracebackType | None = None) -> NoReturn: ... - _T = TypeVar("_T") _VT = TypeVar("_VT") _F = TypeVar("_F", bound=Callable[..., Any]) @@ -205,6 +203,7 @@ class Source(Node): class _HashableSource: def __init__(self, *args, **kwargs) -> None: ... def alias(self, name) -> Self: ... + def clone(self) -> _HashableSource: ... def __hash__(self) -> int: ... def __eq__(self, other) -> Expression | bool: ... # type: ignore[override] def __ne__(self, other) -> Expression | bool: ... # type: ignore[override] @@ -289,13 +288,11 @@ class ColumnBase(Node): def __add__(self, rhs: Any) -> Expression: ... __sub__: ClassVar[Callable[[Self, Any], Expression]] __mul__: ClassVar[Callable[[Self, Any], Expression]] - __div__: ClassVar[Callable[[Self, Any], Expression]] __truediv__: ClassVar[Callable[[Self, Any], Expression]] __xor__: ClassVar[Callable[[Self, Any], Expression]] def __radd__(self, rhs: Any) -> Expression: ... __rsub__: ClassVar[Callable[[Self, Any], Expression]] __rmul__: ClassVar[Callable[[Self, Any], Expression]] - __rdiv__: ClassVar[Callable[[Self, Any], Expression]] __rtruediv__: ClassVar[Callable[[Self, Any], Expression]] __rand__: ClassVar[Callable[[Self, Any], Expression]] __ror__: ClassVar[Callable[[Self, Any], Expression]] @@ -411,9 +408,12 @@ class Ordering(WrappedNode): collation: Incomplete nulls: Incomplete def __init__(self, node, direction, collation=None, nulls=None) -> None: ... - def collate(self, collation=None) -> Ordering: ... # type: ignore[override] + def collate(self, collation=None) -> Self: ... # type: ignore[override] def __sql__(self, ctx): ... +def Asc(node, collation=None, nulls=None) -> Ordering: ... +def Desc(node, collation=None, nulls=None) -> Ordering: ... + class Expression(ColumnBase): lhs: Incomplete op: Incomplete @@ -520,6 +520,9 @@ class NodeList(ColumnBase): def __init__(self, nodes, glue: str = " ", parens: bool = False) -> None: ... def __sql__(self, ctx): ... +def CommaNodeList(nodes) -> NodeList: ... +def EnclosedNodeList(nodes) -> NodeList: ... + class _Namespace(Node): __slots__ = ("_name",) def __init__(self, name) -> None: ... @@ -541,6 +544,7 @@ class DQ(ColumnBase): Tuple: Incomplete class QualifiedNames(WrappedNode): + def __init__(self, node, scope: int = 16) -> None: ... def __sql__(self, ctx): ... class OnConflict(Node): @@ -643,7 +647,7 @@ class Select(SelectBase): **kwargs, ) -> None: ... def clone(self) -> Self: ... - def columns(self, *columns, **kwargs) -> Self: ... + def columns(self, *columns) -> Self: ... select = columns def select_extend(self, *columns) -> Self: ... @@ -805,12 +809,12 @@ class Database(_callable_context_manager): param: str quote: str server_version: Incomplete - commit_select: bool compound_select_parentheses: Incomplete for_update: bool index_schema_prefix: bool index_using_precedes_table: bool - limit_max: Incomplete + index_value_literals: bool + limit_max: int | None nulls_ordering: bool returning_clause: bool safe_create_index: bool @@ -897,6 +901,7 @@ class SqliteDatabase(Database): field_types: Incomplete operations: Incomplete index_schema_prefix: bool + index_value_literals: bool limit_max: int server_version: Incomplete truncate_table: bool @@ -942,7 +947,6 @@ class SqliteDatabase(Database): def attach(self, filename, name) -> bool: ... def detach(self, name) -> bool: ... def last_insert_id(self, cursor, query_type=None): ... - def rows_affected(self, cursor): ... def begin(self, lock_type=None) -> None: ... def get_tables(self, schema: str | None = None) -> list[str]: ... def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ... @@ -973,6 +977,8 @@ 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 @@ -1003,7 +1009,6 @@ class PostgresqlDatabase(Database): field_types: Incomplete operations: Incomplete param: str - commit_select: bool compound_select_parentheses: Incomplete for_update: bool nulls_ordering: bool @@ -1023,7 +1028,6 @@ class PostgresqlDatabase(Database): ) -> None: ... def is_connection_usable(self) -> bool: ... def last_insert_id(self, cursor, query_type=None): ... - def rows_affected(self, cursor): ... def begin(self, isolation_level: str | None = None) -> None: ... def get_tables(self, schema: str | None = None) -> list[str]: ... def get_views(self, schema: str | None = None) -> list[ViewMetadata]: ... @@ -1049,7 +1053,6 @@ class MySQLDatabase(Database): operations: Incomplete param: str quote: str - commit_select: bool compound_select_parentheses: Incomplete for_update: bool index_using_precedes_table: bool @@ -1200,7 +1203,6 @@ class Field(ColumnBase, Generic[_V]): auto_increment: bool default_index_type: Incomplete field_type: ClassVar[str] - unpack: bool null: Incomplete index: Incomplete unique: Incomplete @@ -1263,7 +1265,7 @@ class BigAutoField(AutoField[_V]): def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigAutoField[int]: ... class IdentityField(AutoField[_V]): - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> IdentityField[int]: ... + def __new__(cls, *args: Any, generate_always: bool = False, **kwargs: Unpack[_FieldKwargs]) -> IdentityField[int]: ... class PrimaryKeyField(AutoField[_V]): def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> PrimaryKeyField[int]: ... @@ -1359,6 +1361,24 @@ class BlobField(FieldDatabaseHook, Field[_V]): def db_value(self, value): ... +class JSONPath(ColumnBase): + def __init__(self, field, keys=..., as_text: bool = False) -> None: ... + def __getitem__(self, key) -> JSONPath: ... + def path(self, *keys) -> JSONPath: ... + def as_text(self, as_text: bool = True) -> Self: ... + def as_int(self) -> Cast: ... + def as_float(self) -> Cast: ... + def set(self, value) -> Expression: ... + def insert(self, value) -> Expression: ... + def replace(self, value) -> Expression: ... + def append(self, value) -> Expression: ... + def remove(self) -> Expression: ... + def length(self) -> Expression: ... + def contained_by(self, value) -> Expression: ... + def has_key(self, key) -> Expression: ... + def has_keys(self, key_list) -> Expression: ... + def has_any_keys(self, key_list) -> Expression: ... + class JSONField(FieldDatabaseHook, Field): def __init__(self, dumps=None, loads=None, **kwargs) -> None: ... def path(self, *keys): ... @@ -1441,7 +1461,7 @@ class DateTimeField(_BaseFormattedField[_V]): cls, formats: list[str] | None = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> DateTimeField[datetime]: ... - formats: Incomplete + formats: list[str] def adapt(self, value): ... def to_timestamp(self): ... def truncate(self, part): ... @@ -1468,7 +1488,7 @@ class DateField(_BaseFormattedField[_V]): cls, formats: list[str] | None = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> DateField[date]: ... - formats: Incomplete + formats: list[str] def adapt(self, value): ... def to_timestamp(self): ... def truncate(self, part): ... @@ -1489,7 +1509,7 @@ class TimeField(_BaseFormattedField[_V]): cls, formats: list[str] | None = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> TimeField[time]: ... - formats: Incomplete + formats: list[str] def adapt(self, value): ... @property def hour(self): ... @@ -1503,15 +1523,17 @@ class TimestampField(BigIntegerField[_V]): resolution: Incomplete ticks_to_microsecond: Incomplete utc: Incomplete - formats: Incomplete + formats: list[str] @overload - def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> TimestampField[datetime | None]: ... + def __new__( + cls, *args, resolution: int = 1, utc: bool = False, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> TimestampField[datetime | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> TimestampField[datetime]: ... + def __new__( + cls, *args, resolution: int = 1, utc: bool = False, null: Literal[False] = False, **kwargs: Unpack[_FieldKwargs] + ) -> TimestampField[datetime]: ... - def local_to_utc(self, dt) -> datetime: ... - def utc_to_local(self, dt) -> datetime: ... def get_timestamp(self, value) -> float: ... def db_value(self, value) -> int | None: ... def python_value(self, value): ... @@ -1779,7 +1801,6 @@ class Metadata: @property def entity(self) -> Entity: ... - def get_rel_for_model(self, model) -> tuple[list[Incomplete], list[Incomplete]]: ... def add_field(self, field_name, field, set_attribute: bool = True) -> None: ... def remove_field(self, field_name) -> None: ... auto_increment: Incomplete @@ -1807,7 +1828,6 @@ class ModelBase(type): def __contains__(self, key) -> bool: ... def __len__(self) -> int: ... def __bool__(self) -> bool: ... - def __nonzero__(self) -> bool: ... def __sql__(self, ctx): ... class _BoundModelsContext(_callable_context_manager): @@ -1944,7 +1964,7 @@ class BaseModelSelect(_ModelQueryHelper): def except_(self, rhs) -> ModelCompoundSelectQuery: ... __sub__ = except_ def __iter__(self): ... - def prefetch(self, *subqueries): ... + def prefetch(self, *subqueries, prefetch_type: int = ...): ... def with_related(self, *loads: Load | ForeignKeyField[Any] | BackrefAccessor) -> Self: ... def iterator(self, database: _DatabaseType | None = ...) -> Iterator[Any]: ... def get(self, database: _DatabaseType | None = None): ... @@ -2037,10 +2057,8 @@ class ModelObjectCursorWrapper(ModelDictCursorWrapper): class ModelCursorWrapper(BaseModelCursorWrapper): from_list: Incomplete joins: Incomplete - dicts: bool - def __init__(self, cursor, model, select, from_list, joins, dicts: bool = False) -> None: ... - key_to_constructor: Incomplete - src_is_dest: dict[Incomplete, Incomplete] + def __init__(self, cursor, model, select, from_list, joins) -> None: ... + key_to_constructor: dict[Incomplete, tuple[Incomplete, Incomplete]] src_to_dest: list[tuple[Incomplete, Incomplete, Incomplete, bool, Incomplete, bool]] column_keys: list[Incomplete] def initialize(self) -> None: ... @@ -2056,13 +2074,11 @@ class _PrefetchQuery(NamedTuple): model: Incomplete class PrefetchQuery(_PrefetchQuery): - def __new__( - cls, query, fields=None, is_backref: bool | None = None, rel_models=None, field_to_name=None, model=None - ) -> Self: ... + def __new__(cls, query, fields=None, is_backref: bool | None = None, rel_models=None, field_to_name=None) -> Self: ... def populate_instance(self, instance, id_map) -> None: ... def store_instance(self, instance, id_map) -> None: ... -def prefetch(sq, *subqueries): ... +def prefetch(sq, *subqueries, prefetch_type: int = ...): ... class Load(Node): def __init__(