From 39ddcb163595a4eaff337461a79e4b57fb40b9ec Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Sat, 13 Jun 2026 10:04:00 -0500 Subject: [PATCH 1/8] [peewee] Update to 4.0.8 --- stubs/peewee/METADATA.toml | 2 +- stubs/peewee/peewee.pyi | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/stubs/peewee/METADATA.toml b/stubs/peewee/METADATA.toml index 4bb0e2ed3ad3..2afd31f409f6 100644 --- a/stubs/peewee/METADATA.toml +++ b/stubs/peewee/METADATA.toml @@ -1,4 +1,4 @@ -version = "4.0.5" +version = "4.0.8" 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 816b7a7e8d0c..8a8b1b49e8b7 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -42,7 +42,6 @@ CSQ_PARENTHESES_UNNESTED: Final = 2 SNAKE_CASE_STEP1: Final[re.Pattern[str]] SNAKE_CASE_STEP2: Final[re.Pattern[str]] IDENTIFIER_RE: Final[re.Pattern[str]] -MODEL_BASE: Final = "_metaclass_helper_" def make_identifier(s: str) -> str: ... def chunked(it, n) -> Generator[list[Incomplete]]: ... @@ -538,6 +537,7 @@ class BaseQuery(Node): def __sql__(self, ctx) -> None: ... def sql(self): ... def execute(self, database=None): ... + async def aexecute(self, database=None): ... def iterator(self, database=None): ... def __iter__(self): ... def __getitem__(self, value): ... @@ -756,6 +756,7 @@ class ConnectionContext(_callable_context_manager): class Database(_callable_context_manager): context_class: Incomplete + json_methods: Incomplete field_types: Incomplete operations: Incomplete param: str @@ -1254,6 +1255,18 @@ class FieldDatabaseHook: class BlobField(FieldDatabaseHook, Field): def db_value(self, value): ... +class JSONField(FieldDatabaseHook, Field): + def __init__(self, dumps=None, loads=None, **kwargs) -> None: ... + def path(self, *keys): ... + def length(self): ... + def append(self, value): ... + def update(self, value): ... + def contains(self, value): ... # type: ignore[override] + def contained_by(self, value): ... + def has_key(self, key): ... + def has_keys(self, key_list): ... + def has_any_keys(self, key_list): ... + class BitField(BitwiseMixin, BigIntegerField): def __init__(self, *args, **kwargs) -> None: ... def flag(self, value=None): ... @@ -1938,6 +1951,7 @@ __all__ = [ "InternalError", "IPField", "JOIN", + "JSONField", "ManyToManyField", "Model", "ModelIndex", From ac26f0cd4e9d7e1a33fcae07a08911b332f07ba4 Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Sat, 13 Jun 2026 11:21:21 -0500 Subject: [PATCH 2/8] [peewee] Type the field classes --- stubs/peewee/@tests/stubtest_allowlist.txt | 21 ++ stubs/peewee/peewee.pyi | 331 ++++++++++++++------- 2 files changed, 248 insertions(+), 104 deletions(-) diff --git a/stubs/peewee/@tests/stubtest_allowlist.txt b/stubs/peewee/@tests/stubtest_allowlist.txt index 06bd8788cae5..4c26ccb565a1 100644 --- a/stubs/peewee/@tests/stubtest_allowlist.txt +++ b/stubs/peewee/@tests/stubtest_allowlist.txt @@ -22,6 +22,27 @@ peewee.SelectBase.peek peewee.SelectBase.scalar peewee.SelectBase.scalars +# Descriptor methods exist on FieldAccessor at runtime, but are declared on the +# generic Field classes in the stub so that `instance.field` resolves to the +# field's Python value and `Model.field` resolves to the field (for queries). +peewee.Field.__get__ +peewee.Field.__set__ +peewee.Field.__init__ +# Per-field __new__ overloads encode null=True -> Optional; not present at runtime. +peewee.\w+Field.__new__ +# Constructor args are carried by the __new__ overloads above (which can +# reparameterize the instance, unlike __init__); the runtime __init__ for these +# fields is therefore covered there rather than by a stub __init__. +peewee.CharField.__init__ +peewee.AutoField.__init__ +peewee.ForeignKeyField.__init__ +peewee.DecimalField.__init__ +peewee.IdentityField.__init__ +peewee.PrimaryKeyField.__init__ +peewee.BitField.__init__ +peewee.BigBitField.__init__ +peewee.TimestampField.__init__ + # Ignore missing playhouse modules and names we don't currently provide playhouse\.\w+? playhouse.flask_utils.PaginatedQuery diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index 8a8b1b49e8b7..a40c42b03ebf 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -2,11 +2,11 @@ import re import threading from _typeshed import Incomplete, SupportsKeysAndGetItem, Unused from collections.abc import Callable, Generator, Iterable, Iterator -from datetime import datetime +from datetime import date, datetime, time from decimal import Decimal from types import TracebackType -from typing import Any, ClassVar, Final, Literal, NamedTuple, NoReturn, TypeVar, overload, type_check_only -from typing_extensions import Self, TypeIs +from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, NoReturn, overload, type_check_only +from typing_extensions import Self, TypedDict, TypeIs, TypeVar, Unpack from uuid import UUID def callable_(c: object) -> TypeIs[Callable[..., object]]: ... @@ -18,6 +18,40 @@ def reraise(tp: Unused, value: BaseException, tb: TracebackType | None = None) - _T = TypeVar("_T") _VT = TypeVar("_VT") _F = TypeVar("_F", bound=Callable[..., Any]) +_M = TypeVar("_M", bound=Model) +# __set__/__get__ value types. Bare Field defaults to Field[Any, Any]. +_S = TypeVar("_S", default=Any) +_G = TypeVar("_G", default=Any) + +# Common field kwargs, Unpack-ed into the field __new__ overloads. +class _FieldKwargs(TypedDict, total=False): + index: bool + unique: bool + primary_key: bool + column_name: str | None + default: Any + constraints: Any + sequence: Any + collation: str | None + unindexed: bool + choices: Any + help_text: str | None + verbose_name: str | None + index_type: str | None + db_column: str | None + +class _FKKwargs(_FieldKwargs, total=False): + field: Any + backref: str | None + on_delete: str | None + on_update: str | None + deferrable: Any + to_field: Any + object_id_name: str | None + lazy_load: bool + constraint_name: str | None + related_name: str | None + rel_model: Any class attrdict(dict[str, _VT]): def __getattr__(self, attr: str) -> _VT: ... @@ -321,12 +355,10 @@ class Alias(WrappedNode): c: Incomplete def __init__(self, node, alias) -> None: ... def __hash__(self) -> int: ... - @property def name(self): ... @name.setter def name(self, value) -> None: ... - def alias(self, alias=None): ... def unalias(self): ... def is_alias(self) -> bool: ... @@ -608,12 +640,10 @@ class Select(SelectBase): def columns(self, *columns, **kwargs) -> Self: ... select = columns def select_extend(self, *columns) -> Self: ... - @property def selected_columns(self): ... @selected_columns.setter def selected_columns(self, value) -> None: ... - def from_(self, *sources) -> Self: ... def join(self, dest, join_type="INNER JOIN", on=None) -> Self: ... # type: ignore[override] def left_outer_join(self, dest, on=None) -> Self: ... # type: ignore[override] @@ -880,7 +910,6 @@ class SqliteDatabase(Database): def timeout(self): ... @timeout.setter def timeout(self, seconds) -> None: ... - def register_aggregate(self, klass, name=None, num_params: int = -1) -> None: ... def aggregate(self, name=None, num_params: int = -1): ... def register_collation(self, fn, name=None) -> None: ... @@ -918,12 +947,10 @@ class _BasePsycopgAdapter: isolation_levels: dict[int, str] isolation_levels_inv: dict[str, int] def __init__(self) -> None: ... - @overload def isolation_level_int(self, isolation_level: str) -> int: ... @overload def isolation_level_int(self, isolation_level: _T) -> _T: ... - @overload def isolation_level_str(self, isolation_level: int) -> str: ... @overload @@ -1142,7 +1169,12 @@ class ObjectIdAccessor: def __get__(self, instance, instance_type=None): ... def __set__(self, instance, value) -> None: ... -class Field(ColumnBase): +class Field(ColumnBase, Generic[_S, _G]): + @overload + def __get__(self, instance: None, owner: Any) -> Self: ... + @overload + def __get__(self, instance: object, owner: Any) -> _G: ... + def __set__(self, instance: object, value: _S) -> None: ... accessor_class: Incomplete auto_increment: bool default_index_type: Incomplete @@ -1162,25 +1194,8 @@ class Field(ColumnBase): help_text: Incomplete verbose_name: Incomplete index_type: Incomplete - def __init__( - self, - null: bool = False, - index: bool = False, - unique: bool = False, - column_name=None, - default=None, - primary_key: bool = False, - constraints=None, - sequence=None, - collation=None, - unindexed: bool = False, - choices=None, - help_text=None, - verbose_name=None, - index_type=None, - db_column=None, - _hidden: bool = False, - ) -> None: ... + # Field constructor args are typed per-field in the __new__ overloads. + def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __hash__(self) -> int: ... model: Incomplete name: Incomplete @@ -1199,76 +1214,148 @@ class Field(ColumnBase): class AnyField(Field): ... -class IntegerField(Field): +class IntegerField(Field[_S, _G]): + @overload + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int | None, int | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int, int]: ... def adapt(self, value): ... -class BigIntegerField(IntegerField): ... -class SmallIntegerField(IntegerField): ... +class BigIntegerField(IntegerField[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> BigIntegerField[int | None, int | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BigIntegerField[int, int]: ... + +class SmallIntegerField(IntegerField[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> SmallIntegerField[int | None, int | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> SmallIntegerField[int, int]: ... -class AutoField(IntegerField): +class AutoField(IntegerField[_S, _G]): auto_increment: bool - def __init__(self, *args, **kwargs) -> None: ... + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> AutoField[int, int]: ... -class BigAutoField(AutoField): ... +class BigAutoField(AutoField[_S, _G]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigAutoField[int, int]: ... -class IdentityField(AutoField): - def __init__(self, generate_always: bool = False, **kwargs) -> None: ... +class IdentityField(AutoField[_S, _G]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> IdentityField[int, int]: ... -class PrimaryKeyField(AutoField): - def __init__(self, *args, **kwargs) -> None: ... +class PrimaryKeyField(AutoField[_S, _G]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> PrimaryKeyField[int, int]: ... -class FloatField(Field): +class FloatField(Field[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> FloatField[float | None, float | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FloatField[float, float]: ... def adapt(self, value): ... -class DoubleField(FloatField): ... +class DoubleField(FloatField[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> DoubleField[float | None, float | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> DoubleField[float, float]: ... -class DecimalField(Field): +class DecimalField(Field[_S, _G]): max_digits: Incomplete decimal_places: Incomplete auto_round: Incomplete rounding: Incomplete - def __init__( - self, max_digits: int = 10, decimal_places: int = 5, auto_round: bool = False, rounding=None, *args, **kwargs - ) -> None: ... + @overload + def __new__( + cls, + max_digits: int = ..., + decimal_places: int = ..., + auto_round: bool = ..., + rounding: Any = ..., + *args: Any, + null: Literal[True], + **kwargs: Unpack[_FieldKwargs], + ) -> DecimalField[Decimal | None, Decimal | None]: ... + @overload + def __new__( + cls, + max_digits: int = ..., + decimal_places: int = ..., + auto_round: bool = ..., + rounding: Any = ..., + *args: Any, + null: Literal[False] = ..., + **kwargs: Unpack[_FieldKwargs], + ) -> DecimalField[Decimal, Decimal]: ... def get_modifiers(self) -> list[int]: ... def db_value(self, value): ... def python_value(self, value) -> Decimal | None: ... -class _StringField(Field): +class _StringField(Field[_S, _G]): def adapt(self, value) -> str: ... def __add__(self, other) -> StringExpression: ... def __radd__(self, other) -> StringExpression: ... -class CharField(_StringField): +class CharField(_StringField[_S, _G]): max_length: int - def __init__(self, max_length: int = 255, *args, **kwargs) -> None: ... + @overload + def __new__( + cls, max_length: int = 255, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> CharField[str | None, str | None]: ... + @overload + def __new__( + cls, max_length: int = 255, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] + ) -> CharField[str, str]: ... def get_modifiers(self) -> list[int] | None: ... -class FixedCharField(CharField): +class FixedCharField(CharField[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> FixedCharField[str | None, str | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FixedCharField[str, str]: ... def adapt(self, value) -> str: ... -class TextField(_StringField): ... +class TextField(_StringField[_S, _G]): + @overload + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> TextField[str | None, str | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> TextField[str, str]: ... class FieldDatabaseHook: def bind(self, model, name, set_attribute: bool = True): ... -class BlobField(FieldDatabaseHook, Field): +class BlobField(FieldDatabaseHook, Field[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> BlobField[bytes | None, bytes | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BlobField[bytes, bytes]: ... def db_value(self, value): ... class JSONField(FieldDatabaseHook, Field): def __init__(self, dumps=None, loads=None, **kwargs) -> None: ... def path(self, *keys): ... - def length(self): ... - def append(self, value): ... - def update(self, value): ... - def contains(self, value): ... # type: ignore[override] - def contained_by(self, value): ... - def has_key(self, key): ... - def has_keys(self, key_list): ... - def has_any_keys(self, key_list): ... - -class BitField(BitwiseMixin, BigIntegerField): - def __init__(self, *args, **kwargs) -> None: ... + def length(self) -> Expression: ... + def append(self, value) -> Expression: ... + def update(self, value) -> Expression: ... + def contains(self, value) -> Expression: ... # type: ignore[override] + 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 BitField(BitwiseMixin, BigIntegerField[_S, _G]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BitField[int, int]: ... def flag(self, value=None): ... class BigBitFieldData: @@ -1294,24 +1381,42 @@ class BigBitFieldAccessor(FieldAccessor): def __get__(self, instance, instance_type=None): ... def __set__(self, instance, value) -> None: ... -class BigBitField(BlobField): +class BigBitField(BlobField[_S, _G]): accessor_class: Incomplete - def __init__(self, *args, **kwargs) -> None: ... + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigBitField[bytes, BigBitFieldData]: ... def db_value(self, value): ... -class UUIDField(Field): +class UUIDField(Field[_S, _G]): + @overload + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID | None, UUID | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID, UUID]: ... def db_value(self, value): ... def python_value(self, value) -> UUID | None: ... -class BinaryUUIDField(BlobField): +class BinaryUUIDField(BlobField[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> BinaryUUIDField[UUID | None, UUID | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BinaryUUIDField[UUID, UUID]: ... def db_value(self, value): ... def python_value(self, value) -> UUID | None: ... -class _BaseFormattedField(Field): +class _BaseFormattedField(Field[_S, _G]): formats: Incomplete def __init__(self, formats=None, *args, **kwargs) -> None: ... -class DateTimeField(_BaseFormattedField): +class DateTimeField(_BaseFormattedField[_S, _G]): + @overload + def __new__( + cls, formats: Any = ..., *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> DateTimeField[datetime | None, datetime | None]: ... + @overload + def __new__( + cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] + ) -> DateTimeField[datetime, datetime]: ... formats: Incomplete def adapt(self, value): ... def to_timestamp(self): ... @@ -1329,7 +1434,15 @@ class DateTimeField(_BaseFormattedField): @property def second(self): ... -class DateField(_BaseFormattedField): +class DateField(_BaseFormattedField[_S, _G]): + @overload + def __new__( + cls, formats: Any = ..., *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> DateField[date | None, date | None]: ... + @overload + def __new__( + cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] + ) -> DateField[date, date]: ... formats: Incomplete def adapt(self, value): ... def to_timestamp(self): ... @@ -1341,7 +1454,15 @@ class DateField(_BaseFormattedField): @property def day(self): ... -class TimeField(_BaseFormattedField): +class TimeField(_BaseFormattedField[_S, _G]): + @overload + def __new__( + cls, formats: Any = ..., *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> TimeField[time | None, time | None]: ... + @overload + def __new__( + cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] + ) -> TimeField[time, time]: ... formats: Incomplete def adapt(self, value): ... @property @@ -1351,12 +1472,19 @@ class TimeField(_BaseFormattedField): @property def second(self): ... -class TimestampField(BigIntegerField): +class TimestampField(BigIntegerField[_S, _G]): valid_resolutions: Incomplete resolution: Incomplete ticks_to_microsecond: Incomplete utc: Incomplete - def __init__(self, *args, **kwargs) -> None: ... + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> TimestampField[datetime | None, datetime | None]: ... + @overload + def __new__( + cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] + ) -> TimestampField[datetime, datetime]: ... def local_to_utc(self, dt) -> datetime: ... def utc_to_local(self, dt) -> datetime: ... def get_timestamp(self, value) -> float: ... @@ -1376,11 +1504,21 @@ class TimestampField(BigIntegerField): @property def second(self): ... -class IPField(BigIntegerField): +class IPField(BigIntegerField[_S, _G]): + @overload + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IPField[str | None, str | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IPField[str, str]: ... def db_value(self, val): ... def python_value(self, val) -> str | None: ... -class BooleanField(Field): +class BooleanField(Field[_S, _G]): + @overload + def __new__( + cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] + ) -> BooleanField[bool | None, bool | None]: ... + @overload + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BooleanField[bool, bool]: ... adapt: Incomplete class BareField(Field): @@ -1388,7 +1526,7 @@ class BareField(Field): def __init__(self, adapt=None, *args, **kwargs) -> None: ... def ddl_datatype(self, ctx): ... -class ForeignKeyField(Field): +class ForeignKeyField(Field[_S, _G]): accessor_class: Incomplete backref_accessor_class: Incomplete rel_model: Incomplete @@ -1402,24 +1540,16 @@ class ForeignKeyField(Field): object_id_name: Incomplete lazy_load: Incomplete constraint_name: str | None - def __init__( - self, - model, - field=None, - backref=None, - on_delete=None, - on_update=None, - deferrable=None, - _deferred=None, - rel_model=None, - to_field=None, - object_id_name=None, - lazy_load: bool = True, - constraint_name: str | None = None, - related_name=None, - *args, - **kwargs, - ) -> None: ... + @overload + def __new__( + cls, model: type[_M], *args: Any, null: Literal[True], **kwargs: Unpack[_FKKwargs] + ) -> ForeignKeyField[_M | None, _M | None]: ... + @overload + def __new__( + cls, model: type[_M], *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FKKwargs] + ) -> ForeignKeyField[_M, _M]: ... + @overload + def __new__(cls, model: Any = ..., *args: Any, **kwargs: Unpack[_FKKwargs]) -> ForeignKeyField[Any, Any]: ... @property def field_type(self): ... # type: ignore[override] def get_modifiers(self): ... @@ -1481,12 +1611,10 @@ class ManyToManyField(MetaField): ) -> None: ... def bind(self, model, name, set_attribute: bool = True) -> None: ... def get_models(self) -> list[Incomplete]: ... - @property def through_model(self): ... @through_model.setter def through_model(self, value) -> None: ... - def get_through_model(self): ... class VirtualField(MetaField): @@ -1529,12 +1657,10 @@ class SchemaManager: model: Incomplete context_options: Incomplete def __init__(self, model, database=None, **context_options) -> None: ... - @property def database(self): ... @database.setter def database(self, value) -> None: ... - def create_table(self, safe: bool = True, **options) -> None: ... def create_table_as(self, table_name, query, safe: bool = True, **meta) -> None: ... def drop_table(self, safe: bool = True, **options) -> None: ... @@ -1608,17 +1734,14 @@ class Metadata: def remove_ref(self, field) -> None: ... def add_manytomany(self, field) -> None: ... def remove_manytomany(self, field) -> None: ... - @property def table(self) -> Table: ... @table.deleter def table(self) -> None: ... - @property def schema(self): ... @schema.setter def schema(self, value) -> None: ... - @property def entity(self) -> Entity: ... def get_rel_for_model(self, model) -> tuple[list[Incomplete], list[Incomplete]]: ... @@ -1699,11 +1822,11 @@ class Model(metaclass=ModelBase): @classmethod def noop(cls) -> NoopModelSelect: ... @classmethod - def get(cls, *query, **filters): ... + def get(cls, *query, **filters) -> Self: ... @classmethod - def get_or_none(cls, *query, **filters): ... + def get_or_none(cls, *query, **filters) -> Self | None: ... @classmethod - def get_by_id(cls, pk): ... + def get_by_id(cls, pk) -> Self: ... @classmethod def set_by_id(cls, key, value): ... @classmethod From f1c5d9ec195b6ac6197cb8b0df853803d68b3177 Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Sat, 13 Jun 2026 13:02:35 -0500 Subject: [PATCH 3/8] [peewee] Type query results --- stubs/peewee/peewee.pyi | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index a40c42b03ebf..383184a98f7a 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -18,7 +18,7 @@ def reraise(tp: Unused, value: BaseException, tb: TracebackType | None = None) - _T = TypeVar("_T") _VT = TypeVar("_VT") _F = TypeVar("_F", bound=Callable[..., Any]) -_M = TypeVar("_M", bound=Model) +_M = TypeVar("_M", bound=Model, default=Model) # __set__/__get__ value types. Bare Field defaults to Field[Any, Any]. _S = TypeVar("_S", default=Any) _G = TypeVar("_G", default=Any) @@ -1796,7 +1796,7 @@ class Model(metaclass=ModelBase): @classmethod def alias(cls, alias=None) -> ModelAlias: ... @classmethod - def select(cls, *fields) -> ModelSelect: ... + def select(cls, *fields) -> ModelSelect[Self]: ... @classmethod def update(cls, data=None, /, **update) -> ModelUpdate: ... @classmethod @@ -1918,11 +1918,14 @@ class ModelCompoundSelectQuery(BaseModelSelect, CompoundSelectQuery): # type: i model: Incomplete def __init__(self, model, *args, **kwargs) -> None: ... -class ModelSelect(BaseModelSelect, Select): # type: ignore[misc] +class ModelSelect(BaseModelSelect, Select, Generic[_M]): # type: ignore[misc] model: Incomplete def __init__(self, model, fields_or_models, is_default: bool = False) -> None: ... + def __iter__(self) -> Iterator[_M]: ... + def get(self, database=None) -> _M: ... + def get_or_none(self, database=None) -> _M | None: ... def clone(self) -> Self: ... - def select(self, *fields_or_models): ... + def select(self, *fields_or_models) -> ModelSelect[_M]: ... def select_extend(self, *columns): ... def switch(self, ctx=None) -> Self: ... def join(self, dest, join_type="INNER JOIN", on=None, src=None, attr=None) -> Self: ... # type: ignore[override] From ad32472c50e75c9b34a8f7c214f4683da378354d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jun 2026 19:33:44 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/peewee/peewee.pyi | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index 383184a98f7a..cfd6b38aa3fb 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -355,10 +355,12 @@ class Alias(WrappedNode): c: Incomplete def __init__(self, node, alias) -> None: ... def __hash__(self) -> int: ... + @property def name(self): ... @name.setter def name(self, value) -> None: ... + def alias(self, alias=None): ... def unalias(self): ... def is_alias(self) -> bool: ... @@ -640,10 +642,12 @@ class Select(SelectBase): def columns(self, *columns, **kwargs) -> Self: ... select = columns def select_extend(self, *columns) -> Self: ... + @property def selected_columns(self): ... @selected_columns.setter def selected_columns(self, value) -> None: ... + def from_(self, *sources) -> Self: ... def join(self, dest, join_type="INNER JOIN", on=None) -> Self: ... # type: ignore[override] def left_outer_join(self, dest, on=None) -> Self: ... # type: ignore[override] @@ -910,6 +914,7 @@ class SqliteDatabase(Database): def timeout(self): ... @timeout.setter def timeout(self, seconds) -> None: ... + def register_aggregate(self, klass, name=None, num_params: int = -1) -> None: ... def aggregate(self, name=None, num_params: int = -1): ... def register_collation(self, fn, name=None) -> None: ... @@ -947,10 +952,12 @@ class _BasePsycopgAdapter: isolation_levels: dict[int, str] isolation_levels_inv: dict[str, int] def __init__(self) -> None: ... + @overload def isolation_level_int(self, isolation_level: str) -> int: ... @overload def isolation_level_int(self, isolation_level: _T) -> _T: ... + @overload def isolation_level_str(self, isolation_level: int) -> str: ... @overload @@ -1174,6 +1181,7 @@ class Field(ColumnBase, Generic[_S, _G]): def __get__(self, instance: None, owner: Any) -> Self: ... @overload def __get__(self, instance: object, owner: Any) -> _G: ... + def __set__(self, instance: object, value: _S) -> None: ... accessor_class: Incomplete auto_increment: bool @@ -1219,6 +1227,7 @@ class IntegerField(Field[_S, _G]): def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int | None, int | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int, int]: ... + def adapt(self, value): ... class BigIntegerField(IntegerField[_S, _G]): @@ -1257,6 +1266,7 @@ class FloatField(Field[_S, _G]): ) -> FloatField[float | None, float | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FloatField[float, float]: ... + def adapt(self, value): ... class DoubleField(FloatField[_S, _G]): @@ -1272,6 +1282,7 @@ class DecimalField(Field[_S, _G]): decimal_places: Incomplete auto_round: Incomplete rounding: Incomplete + @overload def __new__( cls, @@ -1294,6 +1305,7 @@ class DecimalField(Field[_S, _G]): null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs], ) -> DecimalField[Decimal, Decimal]: ... + def get_modifiers(self) -> list[int]: ... def db_value(self, value): ... def python_value(self, value) -> Decimal | None: ... @@ -1305,6 +1317,7 @@ class _StringField(Field[_S, _G]): class CharField(_StringField[_S, _G]): max_length: int + @overload def __new__( cls, max_length: int = 255, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] @@ -1313,6 +1326,7 @@ class CharField(_StringField[_S, _G]): def __new__( cls, max_length: int = 255, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> CharField[str, str]: ... + def get_modifiers(self) -> list[int] | None: ... class FixedCharField(CharField[_S, _G]): @@ -1322,6 +1336,7 @@ class FixedCharField(CharField[_S, _G]): ) -> FixedCharField[str | None, str | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FixedCharField[str, str]: ... + def adapt(self, value) -> str: ... class TextField(_StringField[_S, _G]): @@ -1340,6 +1355,7 @@ class BlobField(FieldDatabaseHook, Field[_S, _G]): ) -> BlobField[bytes | None, bytes | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BlobField[bytes, bytes]: ... + def db_value(self, value): ... class JSONField(FieldDatabaseHook, Field): @@ -1391,6 +1407,7 @@ class UUIDField(Field[_S, _G]): def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID | None, UUID | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID, UUID]: ... + def db_value(self, value): ... def python_value(self, value) -> UUID | None: ... @@ -1401,6 +1418,7 @@ class BinaryUUIDField(BlobField[_S, _G]): ) -> BinaryUUIDField[UUID | None, UUID | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BinaryUUIDField[UUID, UUID]: ... + def db_value(self, value): ... def python_value(self, value) -> UUID | None: ... @@ -1417,6 +1435,7 @@ class DateTimeField(_BaseFormattedField[_S, _G]): def __new__( cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> DateTimeField[datetime, datetime]: ... + formats: Incomplete def adapt(self, value): ... def to_timestamp(self): ... @@ -1443,6 +1462,7 @@ class DateField(_BaseFormattedField[_S, _G]): def __new__( cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> DateField[date, date]: ... + formats: Incomplete def adapt(self, value): ... def to_timestamp(self): ... @@ -1463,6 +1483,7 @@ class TimeField(_BaseFormattedField[_S, _G]): def __new__( cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> TimeField[time, time]: ... + formats: Incomplete def adapt(self, value): ... @property @@ -1477,6 +1498,7 @@ class TimestampField(BigIntegerField[_S, _G]): resolution: Incomplete ticks_to_microsecond: Incomplete utc: Incomplete + @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] @@ -1485,6 +1507,7 @@ class TimestampField(BigIntegerField[_S, _G]): def __new__( cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] ) -> TimestampField[datetime, datetime]: ... + def local_to_utc(self, dt) -> datetime: ... def utc_to_local(self, dt) -> datetime: ... def get_timestamp(self, value) -> float: ... @@ -1509,6 +1532,7 @@ class IPField(BigIntegerField[_S, _G]): def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IPField[str | None, str | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IPField[str, str]: ... + def db_value(self, val): ... def python_value(self, val) -> str | None: ... @@ -1519,6 +1543,7 @@ class BooleanField(Field[_S, _G]): ) -> BooleanField[bool | None, bool | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BooleanField[bool, bool]: ... + adapt: Incomplete class BareField(Field): @@ -1540,6 +1565,7 @@ class ForeignKeyField(Field[_S, _G]): object_id_name: Incomplete lazy_load: Incomplete constraint_name: str | None + @overload def __new__( cls, model: type[_M], *args: Any, null: Literal[True], **kwargs: Unpack[_FKKwargs] @@ -1550,6 +1576,7 @@ class ForeignKeyField(Field[_S, _G]): ) -> ForeignKeyField[_M, _M]: ... @overload def __new__(cls, model: Any = ..., *args: Any, **kwargs: Unpack[_FKKwargs]) -> ForeignKeyField[Any, Any]: ... + @property def field_type(self): ... # type: ignore[override] def get_modifiers(self): ... @@ -1611,10 +1638,12 @@ class ManyToManyField(MetaField): ) -> None: ... def bind(self, model, name, set_attribute: bool = True) -> None: ... def get_models(self) -> list[Incomplete]: ... + @property def through_model(self): ... @through_model.setter def through_model(self, value) -> None: ... + def get_through_model(self): ... class VirtualField(MetaField): @@ -1657,10 +1686,12 @@ class SchemaManager: model: Incomplete context_options: Incomplete def __init__(self, model, database=None, **context_options) -> None: ... + @property def database(self): ... @database.setter def database(self, value) -> None: ... + def create_table(self, safe: bool = True, **options) -> None: ... def create_table_as(self, table_name, query, safe: bool = True, **meta) -> None: ... def drop_table(self, safe: bool = True, **options) -> None: ... @@ -1734,14 +1765,17 @@ class Metadata: def remove_ref(self, field) -> None: ... def add_manytomany(self, field) -> None: ... def remove_manytomany(self, field) -> None: ... + @property def table(self) -> Table: ... @table.deleter def table(self) -> None: ... + @property def schema(self): ... @schema.setter def schema(self, value) -> None: ... + @property def entity(self) -> Entity: ... def get_rel_for_model(self, model) -> tuple[list[Incomplete], list[Incomplete]]: ... From cf7f39afb4af79edbce9308c7e21ebef8d6db336 Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Sat, 13 Jun 2026 14:46:46 -0500 Subject: [PATCH 5/8] [peewee] Mark kwargs TypedDicts type_check_only and fix TypedDict import --- stubs/peewee/@tests/stubtest_allowlist.txt | 11 +---------- stubs/peewee/peewee.pyi | 6 ++++-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/stubs/peewee/@tests/stubtest_allowlist.txt b/stubs/peewee/@tests/stubtest_allowlist.txt index 4c26ccb565a1..b5756158d39d 100644 --- a/stubs/peewee/@tests/stubtest_allowlist.txt +++ b/stubs/peewee/@tests/stubtest_allowlist.txt @@ -28,20 +28,11 @@ peewee.SelectBase.scalars peewee.Field.__get__ peewee.Field.__set__ peewee.Field.__init__ -# Per-field __new__ overloads encode null=True -> Optional; not present at runtime. -peewee.\w+Field.__new__ -# Constructor args are carried by the __new__ overloads above (which can -# reparameterize the instance, unlike __init__); the runtime __init__ for these -# fields is therefore covered there rather than by a stub __init__. +# These fields take named constructor args, carried by their __new__ overloads. peewee.CharField.__init__ -peewee.AutoField.__init__ peewee.ForeignKeyField.__init__ peewee.DecimalField.__init__ peewee.IdentityField.__init__ -peewee.PrimaryKeyField.__init__ -peewee.BitField.__init__ -peewee.BigBitField.__init__ -peewee.TimestampField.__init__ # Ignore missing playhouse modules and names we don't currently provide playhouse\.\w+? diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index cfd6b38aa3fb..25888cfd1db9 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -5,8 +5,8 @@ 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, overload, type_check_only -from typing_extensions import Self, TypedDict, TypeIs, TypeVar, Unpack +from typing import Any, ClassVar, Final, Generic, Literal, NamedTuple, NoReturn, TypedDict, overload, type_check_only +from typing_extensions import Self, TypeIs, TypeVar, Unpack from uuid import UUID def callable_(c: object) -> TypeIs[Callable[..., object]]: ... @@ -24,6 +24,7 @@ _S = TypeVar("_S", default=Any) _G = TypeVar("_G", default=Any) # Common field kwargs, Unpack-ed into the field __new__ overloads. +@type_check_only class _FieldKwargs(TypedDict, total=False): index: bool unique: bool @@ -40,6 +41,7 @@ class _FieldKwargs(TypedDict, total=False): index_type: str | None db_column: str | None +@type_check_only class _FKKwargs(_FieldKwargs, total=False): field: Any backref: str | None From 4e1ce14c605352b4549ccdfeca7a73a6b2662397 Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Sat, 13 Jun 2026 15:35:59 -0500 Subject: [PATCH 6/8] [peewee] Instead of separating get/set, just override for BigBitField. Also fix up fn. --- stubs/peewee/@tests/stubtest_allowlist.txt | 2 + stubs/peewee/peewee.pyi | 188 +++++++++++---------- 2 files changed, 98 insertions(+), 92 deletions(-) diff --git a/stubs/peewee/@tests/stubtest_allowlist.txt b/stubs/peewee/@tests/stubtest_allowlist.txt index b5756158d39d..63e6f01a49f3 100644 --- a/stubs/peewee/@tests/stubtest_allowlist.txt +++ b/stubs/peewee/@tests/stubtest_allowlist.txt @@ -27,6 +27,8 @@ peewee.SelectBase.scalars # field's Python value and `Model.field` resolves to the field (for queries). peewee.Field.__get__ peewee.Field.__set__ +# BigBitField overrides __get__ to yield a BigBitFieldData wrapper, not bytes. +peewee.BigBitField.__get__ peewee.Field.__init__ # These fields take named constructor args, carried by their __new__ overloads. peewee.CharField.__init__ diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index 25888cfd1db9..1959369e1e61 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -19,9 +19,8 @@ _T = TypeVar("_T") _VT = TypeVar("_VT") _F = TypeVar("_F", bound=Callable[..., Any]) _M = TypeVar("_M", bound=Model, default=Model) -# __set__/__get__ value types. Bare Field defaults to Field[Any, Any]. -_S = TypeVar("_S", default=Any) -_G = TypeVar("_G", default=Any) +# __get__/__set__ value type. Bare Field defaults to Field[Any]. +_V = TypeVar("_V", default=Any) # Common field kwargs, Unpack-ed into the field __new__ overloads. @type_check_only @@ -31,11 +30,11 @@ class _FieldKwargs(TypedDict, total=False): primary_key: bool column_name: str | None default: Any - constraints: Any - sequence: Any + constraints: list[Node] | None + sequence: str | None collation: str | None unindexed: bool - choices: Any + choices: Iterable[tuple[Any, str]] | None help_text: str | None verbose_name: str | None index_type: str | None @@ -43,17 +42,17 @@ class _FieldKwargs(TypedDict, total=False): @type_check_only class _FKKwargs(_FieldKwargs, total=False): - field: Any - backref: str | None + field: Field[Any] | str | None + backref: str | Callable[[Field[Any]], str] | None on_delete: str | None on_update: str | None - deferrable: Any - to_field: Any + deferrable: str | None + to_field: Field[Any] | str | None object_id_name: str | None lazy_load: bool constraint_name: str | None - related_name: str | None - rel_model: Any + related_name: str | Callable[[Field[Any]], str] | None + rel_model: type[Model] | None class attrdict(dict[str, _VT]): def __getattr__(self, attr: str) -> _VT: ... @@ -438,15 +437,16 @@ class SQL(ColumnBase): def __init__(self, sql, params=None) -> None: ... def __sql__(self, ctx): ... -def Check(constraint, name=None): ... +def Check(constraint, name=None) -> Node: ... def Default(value) -> SQL: ... class Function(ColumnBase): no_coerce_functions: ClassVar[set[str]] - name: Incomplete - arguments: Incomplete + name: str | None + arguments: tuple[Any, ...] | None def __init__(self, name, arguments, coerce: bool = True, python_value=None) -> None: ... - def __getattr__(self, attr: str): ... + # fn.COUNT(...), fn.SUM(...), etc. each build a Function node. + def __getattr__(self, attr: str) -> Callable[..., Function]: ... def filter(self, where=None) -> Self: ... def order_by(self, *ordering) -> Self: ... def python_value(self, func=None) -> Self: ... @@ -455,7 +455,7 @@ class Function(ColumnBase): ) -> NodeList: ... def __sql__(self, ctx): ... -fn: Incomplete +fn: Function class Window(Node): CURRENT_ROW: SQL @@ -1178,13 +1178,13 @@ class ObjectIdAccessor: def __get__(self, instance, instance_type=None): ... def __set__(self, instance, value) -> None: ... -class Field(ColumnBase, Generic[_S, _G]): +class Field(ColumnBase, Generic[_V]): @overload def __get__(self, instance: None, owner: Any) -> Self: ... @overload - def __get__(self, instance: object, owner: Any) -> _G: ... + def __get__(self, instance: object, owner: Any) -> _V: ... - def __set__(self, instance: object, value: _S) -> None: ... + def __set__(self, instance: object, value: _V) -> None: ... accessor_class: Incomplete auto_increment: bool default_index_type: Incomplete @@ -1224,62 +1224,62 @@ class Field(ColumnBase, Generic[_S, _G]): class AnyField(Field): ... -class IntegerField(Field[_S, _G]): +class IntegerField(Field[_V]): @overload - def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int | None, int | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int, int]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IntegerField[int]: ... def adapt(self, value): ... -class BigIntegerField(IntegerField[_S, _G]): +class BigIntegerField(IntegerField[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BigIntegerField[int | None, int | None]: ... + ) -> BigIntegerField[int | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BigIntegerField[int, int]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BigIntegerField[int]: ... -class SmallIntegerField(IntegerField[_S, _G]): +class SmallIntegerField(IntegerField[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> SmallIntegerField[int | None, int | None]: ... + ) -> SmallIntegerField[int | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> SmallIntegerField[int, int]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> SmallIntegerField[int]: ... -class AutoField(IntegerField[_S, _G]): +class AutoField(IntegerField[_V]): auto_increment: bool - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> AutoField[int, int]: ... + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> AutoField[int]: ... -class BigAutoField(AutoField[_S, _G]): - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigAutoField[int, int]: ... +class BigAutoField(AutoField[_V]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigAutoField[int]: ... -class IdentityField(AutoField[_S, _G]): - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> IdentityField[int, int]: ... +class IdentityField(AutoField[_V]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> IdentityField[int]: ... -class PrimaryKeyField(AutoField[_S, _G]): - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> PrimaryKeyField[int, int]: ... +class PrimaryKeyField(AutoField[_V]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> PrimaryKeyField[int]: ... -class FloatField(Field[_S, _G]): +class FloatField(Field[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> FloatField[float | None, float | None]: ... + ) -> FloatField[float | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FloatField[float, float]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FloatField[float]: ... def adapt(self, value): ... -class DoubleField(FloatField[_S, _G]): +class DoubleField(FloatField[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> DoubleField[float | None, float | None]: ... + ) -> DoubleField[float | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> DoubleField[float, float]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> DoubleField[float]: ... -class DecimalField(Field[_S, _G]): +class DecimalField(Field[_V]): max_digits: Incomplete decimal_places: Incomplete auto_round: Incomplete @@ -1295,7 +1295,7 @@ class DecimalField(Field[_S, _G]): *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs], - ) -> DecimalField[Decimal | None, Decimal | None]: ... + ) -> DecimalField[Decimal | None]: ... @overload def __new__( cls, @@ -1306,57 +1306,57 @@ class DecimalField(Field[_S, _G]): *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs], - ) -> DecimalField[Decimal, Decimal]: ... + ) -> DecimalField[Decimal]: ... def get_modifiers(self) -> list[int]: ... def db_value(self, value): ... def python_value(self, value) -> Decimal | None: ... -class _StringField(Field[_S, _G]): +class _StringField(Field[_V]): def adapt(self, value) -> str: ... def __add__(self, other) -> StringExpression: ... def __radd__(self, other) -> StringExpression: ... -class CharField(_StringField[_S, _G]): +class CharField(_StringField[_V]): max_length: int @overload def __new__( cls, max_length: int = 255, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> CharField[str | None, str | None]: ... + ) -> CharField[str | None]: ... @overload def __new__( cls, max_length: int = 255, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] - ) -> CharField[str, str]: ... + ) -> CharField[str]: ... def get_modifiers(self) -> list[int] | None: ... -class FixedCharField(CharField[_S, _G]): +class FixedCharField(CharField[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> FixedCharField[str | None, str | None]: ... + ) -> FixedCharField[str | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FixedCharField[str, str]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FixedCharField[str]: ... def adapt(self, value) -> str: ... -class TextField(_StringField[_S, _G]): +class TextField(_StringField[_V]): @overload - def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> TextField[str | None, str | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> TextField[str | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> TextField[str, str]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> TextField[str]: ... class FieldDatabaseHook: def bind(self, model, name, set_attribute: bool = True): ... -class BlobField(FieldDatabaseHook, Field[_S, _G]): +class BlobField(FieldDatabaseHook, Field[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BlobField[bytes | None, bytes | None]: ... + ) -> BlobField[bytes | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BlobField[bytes, bytes]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BlobField[bytes]: ... def db_value(self, value): ... @@ -1372,8 +1372,8 @@ class JSONField(FieldDatabaseHook, Field): def has_keys(self, key_list) -> Expression: ... def has_any_keys(self, key_list) -> Expression: ... -class BitField(BitwiseMixin, BigIntegerField[_S, _G]): - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BitField[int, int]: ... +class BitField(BitwiseMixin, BigIntegerField[_V]): + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BitField[int]: ... def flag(self, value=None): ... class BigBitFieldData: @@ -1399,44 +1399,48 @@ class BigBitFieldAccessor(FieldAccessor): def __get__(self, instance, instance_type=None): ... def __set__(self, instance, value) -> None: ... -class BigBitField(BlobField[_S, _G]): +class BigBitField(BlobField[bytes]): accessor_class: Incomplete - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigBitField[bytes, BigBitFieldData]: ... + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigBitField: ... + @overload # type: ignore[override] + def __get__(self, instance: None, owner: Any) -> Self: ... + @overload + def __get__(self, instance: object, owner: Any) -> BigBitFieldData: ... def db_value(self, value): ... -class UUIDField(Field[_S, _G]): +class UUIDField(Field[_V]): @overload - def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID | None, UUID | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID, UUID]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> UUIDField[UUID]: ... def db_value(self, value): ... def python_value(self, value) -> UUID | None: ... -class BinaryUUIDField(BlobField[_S, _G]): +class BinaryUUIDField(BlobField[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BinaryUUIDField[UUID | None, UUID | None]: ... + ) -> BinaryUUIDField[UUID | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BinaryUUIDField[UUID, UUID]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BinaryUUIDField[UUID]: ... def db_value(self, value): ... def python_value(self, value) -> UUID | None: ... -class _BaseFormattedField(Field[_S, _G]): +class _BaseFormattedField(Field[_V]): formats: Incomplete def __init__(self, formats=None, *args, **kwargs) -> None: ... -class DateTimeField(_BaseFormattedField[_S, _G]): +class DateTimeField(_BaseFormattedField[_V]): @overload def __new__( cls, formats: Any = ..., *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> DateTimeField[datetime | None, datetime | None]: ... + ) -> DateTimeField[datetime | None]: ... @overload def __new__( cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] - ) -> DateTimeField[datetime, datetime]: ... + ) -> DateTimeField[datetime]: ... formats: Incomplete def adapt(self, value): ... @@ -1455,15 +1459,15 @@ class DateTimeField(_BaseFormattedField[_S, _G]): @property def second(self): ... -class DateField(_BaseFormattedField[_S, _G]): +class DateField(_BaseFormattedField[_V]): @overload def __new__( cls, formats: Any = ..., *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> DateField[date | None, date | None]: ... + ) -> DateField[date | None]: ... @overload def __new__( cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] - ) -> DateField[date, date]: ... + ) -> DateField[date]: ... formats: Incomplete def adapt(self, value): ... @@ -1476,15 +1480,15 @@ class DateField(_BaseFormattedField[_S, _G]): @property def day(self): ... -class TimeField(_BaseFormattedField[_S, _G]): +class TimeField(_BaseFormattedField[_V]): @overload def __new__( cls, formats: Any = ..., *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> TimeField[time | None, time | None]: ... + ) -> TimeField[time | None]: ... @overload def __new__( cls, formats: Any = ..., *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] - ) -> TimeField[time, time]: ... + ) -> TimeField[time]: ... formats: Incomplete def adapt(self, value): ... @@ -1495,7 +1499,7 @@ class TimeField(_BaseFormattedField[_S, _G]): @property def second(self): ... -class TimestampField(BigIntegerField[_S, _G]): +class TimestampField(BigIntegerField[_V]): valid_resolutions: Incomplete resolution: Incomplete ticks_to_microsecond: Incomplete @@ -1504,11 +1508,11 @@ class TimestampField(BigIntegerField[_S, _G]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> TimestampField[datetime | None, datetime | None]: ... + ) -> TimestampField[datetime | None]: ... @overload def __new__( cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs] - ) -> TimestampField[datetime, datetime]: ... + ) -> TimestampField[datetime]: ... def local_to_utc(self, dt) -> datetime: ... def utc_to_local(self, dt) -> datetime: ... @@ -1529,22 +1533,22 @@ class TimestampField(BigIntegerField[_S, _G]): @property def second(self): ... -class IPField(BigIntegerField[_S, _G]): +class IPField(BigIntegerField[_V]): @overload - def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IPField[str | None, str | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> IPField[str | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IPField[str, str]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> IPField[str]: ... def db_value(self, val): ... def python_value(self, val) -> str | None: ... -class BooleanField(Field[_S, _G]): +class BooleanField(Field[_V]): @overload def __new__( cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BooleanField[bool | None, bool | None]: ... + ) -> BooleanField[bool | None]: ... @overload - def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BooleanField[bool, bool]: ... + def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BooleanField[bool]: ... adapt: Incomplete @@ -1553,7 +1557,7 @@ class BareField(Field): def __init__(self, adapt=None, *args, **kwargs) -> None: ... def ddl_datatype(self, ctx): ... -class ForeignKeyField(Field[_S, _G]): +class ForeignKeyField(Field[_V]): accessor_class: Incomplete backref_accessor_class: Incomplete rel_model: Incomplete @@ -1571,13 +1575,13 @@ class ForeignKeyField(Field[_S, _G]): @overload def __new__( cls, model: type[_M], *args: Any, null: Literal[True], **kwargs: Unpack[_FKKwargs] - ) -> ForeignKeyField[_M | None, _M | None]: ... + ) -> ForeignKeyField[_M | None]: ... @overload def __new__( cls, model: type[_M], *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FKKwargs] - ) -> ForeignKeyField[_M, _M]: ... + ) -> ForeignKeyField[_M]: ... @overload - def __new__(cls, model: Any = ..., *args: Any, **kwargs: Unpack[_FKKwargs]) -> ForeignKeyField[Any, Any]: ... + def __new__(cls, model: Any = ..., *args: Any, **kwargs: Unpack[_FKKwargs]) -> ForeignKeyField[Any]: ... @property def field_type(self): ... # type: ignore[override] From f0e8e58f90986491f16e8e9a33897f5753f19525 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 13 Jun 2026 20:38:28 +0000 Subject: [PATCH 7/8] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/peewee/peewee.pyi | 42 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index 1959369e1e61..f1510ffa74ea 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -1234,17 +1234,13 @@ class IntegerField(Field[_V]): class BigIntegerField(IntegerField[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BigIntegerField[int | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> BigIntegerField[int | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BigIntegerField[int]: ... class SmallIntegerField(IntegerField[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> SmallIntegerField[int | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> SmallIntegerField[int | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> SmallIntegerField[int]: ... @@ -1263,9 +1259,7 @@ class PrimaryKeyField(AutoField[_V]): class FloatField(Field[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> FloatField[float | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> FloatField[float | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FloatField[float]: ... @@ -1273,9 +1267,7 @@ class FloatField(Field[_V]): class DoubleField(FloatField[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> DoubleField[float | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> DoubleField[float | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> DoubleField[float]: ... @@ -1333,9 +1325,7 @@ class CharField(_StringField[_V]): class FixedCharField(CharField[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> FixedCharField[str | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> FixedCharField[str | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> FixedCharField[str]: ... @@ -1352,9 +1342,7 @@ class FieldDatabaseHook: class BlobField(FieldDatabaseHook, Field[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BlobField[bytes | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> BlobField[bytes | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BlobField[bytes]: ... @@ -1402,10 +1390,12 @@ class BigBitFieldAccessor(FieldAccessor): class BigBitField(BlobField[bytes]): accessor_class: Incomplete def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigBitField: ... + @overload # type: ignore[override] def __get__(self, instance: None, owner: Any) -> Self: ... @overload def __get__(self, instance: object, owner: Any) -> BigBitFieldData: ... + def db_value(self, value): ... class UUIDField(Field[_V]): @@ -1419,9 +1409,7 @@ class UUIDField(Field[_V]): class BinaryUUIDField(BlobField[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BinaryUUIDField[UUID | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> BinaryUUIDField[UUID | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BinaryUUIDField[UUID]: ... @@ -1506,13 +1494,9 @@ class TimestampField(BigIntegerField[_V]): utc: Incomplete @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> TimestampField[datetime | None]: ... + def __new__(cls, *args: Any, 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: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> TimestampField[datetime]: ... def local_to_utc(self, dt) -> datetime: ... def utc_to_local(self, dt) -> datetime: ... @@ -1544,9 +1528,7 @@ class IPField(BigIntegerField[_V]): class BooleanField(Field[_V]): @overload - def __new__( - cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs] - ) -> BooleanField[bool | None]: ... + def __new__(cls, *args: Any, null: Literal[True], **kwargs: Unpack[_FieldKwargs]) -> BooleanField[bool | None]: ... @overload def __new__(cls, *args: Any, null: Literal[False] = ..., **kwargs: Unpack[_FieldKwargs]) -> BooleanField[bool]: ... From eea557761b1971ee7ba895e03579df46a8b0f9fd Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Sat, 13 Jun 2026 16:00:27 -0500 Subject: [PATCH 8/8] [peewee] Couple more low-hangin' fruits. --- stubs/peewee/peewee.pyi | 52 +++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/stubs/peewee/peewee.pyi b/stubs/peewee/peewee.pyi index f1510ffa74ea..99398277f060 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -264,7 +264,7 @@ class ValuesList(_HashableSource, BaseTable): # type: ignore[misc] class CTE(_HashableSource, Source): # type: ignore[misc] def __init__(self, name, query, recursive: bool = False, columns=None, materialized=None) -> None: ... - def select_from(self, *columns): ... + def select_from(self, *columns) -> Select: ... def union_all(self, rhs) -> CTE: ... __add__ = union_all def union(self, rhs) -> CTE: ... @@ -273,7 +273,7 @@ class CTE(_HashableSource, Source): # type: ignore[misc] class ColumnBase(Node): def converter(self, converter=None) -> Self: ... - def alias(self, alias): ... + def alias(self, alias) -> Alias | Self: ... def unalias(self) -> Self: ... def bind_to(self, dest) -> BindTo: ... def cast(self, as_type) -> Cast: ... @@ -282,10 +282,10 @@ class ColumnBase(Node): def desc(self, collation=None, nulls=None) -> Ordering: ... __neg__ = desc def __invert__(self): ... - __and__: Incomplete - __or__: Incomplete + __and__: ClassVar[Callable[[Self, Any], Expression]] + __or__: ClassVar[Callable[[Self, Any], Expression]] def __add__(self, rhs: Any) -> Expression: ... - __sub__: Incomplete + __sub__: ClassVar[Callable[[Self, Any], Expression]] __mul__: ClassVar[Callable[[Self, Any], Expression]] __div__: ClassVar[Callable[[Self, Any], Expression]] __truediv__: ClassVar[Callable[[Self, Any], Expression]] @@ -377,9 +377,9 @@ class Negated(WrappedNode): def __sql__(self, ctx): ... class BitwiseMixin: - def __and__(self, other): ... - def __or__(self, other): ... - def __sub__(self, other): ... + def __and__(self, other) -> Expression: ... + def __or__(self, other) -> Expression: ... + def __sub__(self, other) -> Expression: ... def __invert__(self) -> BitwiseNegated: ... class BitwiseNegated(BitwiseMixin, WrappedNode): @@ -571,7 +571,7 @@ class BaseQuery(Node): def namedtuples(self, as_namedtuple: bool = True) -> Self: ... def objects(self, constructor=None) -> Self: ... def __sql__(self, ctx) -> None: ... - def sql(self): ... + def sql(self) -> tuple[str, list[Any]]: ... def execute(self, database=None): ... async def aexecute(self, database=None): ... def iterator(self, database=None): ... @@ -1080,8 +1080,10 @@ class _manual(_callable_context_manager): class _atomic(_callable_context_manager): db: Incomplete def __init__(self, db, *args, **kwargs) -> None: ... - def __enter__(self): ... - def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None): ... + def __enter__(self) -> _transaction | _savepoint: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> None: ... class _transaction(_callable_context_manager): db: Incomplete @@ -1389,7 +1391,7 @@ class BigBitFieldAccessor(FieldAccessor): class BigBitField(BlobField[bytes]): accessor_class: Incomplete - def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> BigBitField: ... + def __new__(cls, *args: Any, **kwargs: Unpack[_FieldKwargs]) -> Self: ... @overload # type: ignore[override] def __get__(self, instance: None, owner: Any) -> Self: ... @@ -1696,7 +1698,7 @@ class SchemaManager: def drop_all(self, safe: bool = True, drop_sequences: bool = True, **options) -> None: ... class Metadata: - model: Incomplete + model: type[Model] database: Incomplete fields: Incomplete columns: Incomplete @@ -1710,7 +1712,7 @@ class Metadata: table_name: Incomplete indexes: Incomplete constraints: Incomplete - primary_key: Incomplete + primary_key: Field[Any] | Literal[False] composite_key: Incomplete only_save_dirty: Incomplete depends_on: Incomplete @@ -1760,7 +1762,7 @@ class Metadata: def table(self) -> None: ... @property - def schema(self): ... + def schema(self) -> str | None: ... @schema.setter def schema(self, value) -> None: ... @@ -1858,14 +1860,14 @@ class Model(metaclass=ModelBase): @classmethod def filter(cls, *dq_nodes, **filters): ... def get_id(self): ... - def save(self, force_insert: bool = False, only=None): ... + def save(self, force_insert: bool = False, only=None) -> int: ... def is_dirty(self) -> bool: ... @property - def dirty_fields(self) -> list[Incomplete]: ... + def dirty_fields(self) -> list[Field[Any]]: ... @property - def dirty_field_names(self) -> list[Incomplete]: ... + def dirty_field_names(self) -> list[str]: ... def dependencies(self, search_nullable: bool = True, exclude_null_children: bool = False) -> Generator[Incomplete]: ... - def delete_instance(self, recursive: bool = False, delete_nullable: bool = False): ... + def delete_instance(self, recursive: bool = False, delete_nullable: bool = False) -> int: ... def __hash__(self) -> int: ... def __eq__(self, other) -> Expression | bool: ... # type: ignore[override] def __ne__(self, other) -> Expression | bool: ... # type: ignore[override] @@ -1919,7 +1921,7 @@ class _ModelQueryHelper: class ModelRaw(_ModelQueryHelper, RawQuery): # type: ignore[misc] model: Incomplete def __init__(self, model, sql, params, **kwargs) -> None: ... - def get(self): ... + def get(self) -> Model: ... class BaseModelSelect(_ModelQueryHelper): def union_all(self, rhs) -> ModelCompoundSelectQuery: ... @@ -1941,21 +1943,21 @@ class ModelCompoundSelectQuery(BaseModelSelect, CompoundSelectQuery): # type: i def __init__(self, model, *args, **kwargs) -> None: ... class ModelSelect(BaseModelSelect, Select, Generic[_M]): # type: ignore[misc] - model: Incomplete + model: type[_M] def __init__(self, model, fields_or_models, is_default: bool = False) -> None: ... def __iter__(self) -> Iterator[_M]: ... def get(self, database=None) -> _M: ... def get_or_none(self, database=None) -> _M | None: ... def clone(self) -> Self: ... def select(self, *fields_or_models) -> ModelSelect[_M]: ... - def select_extend(self, *columns): ... + def select_extend(self, *columns) -> Self: ... def switch(self, ctx=None) -> Self: ... def join(self, dest, join_type="INNER JOIN", on=None, src=None, attr=None) -> Self: ... # type: ignore[override] def left_outer_join(self, dest, on=None, src=None, attr=None) -> Self: ... # type: ignore[override] def join_from(self, src, dest, join_type="INNER JOIN", on=None, attr=None) -> Self: ... def ensure_join(self, lm, rm, on=None, **join_kwargs): ... def convert_dict_to_node(self, qdict) -> tuple[list[Incomplete], list[Incomplete]]: ... - def filter(self, *args, **kwargs): ... + def filter(self, *args, **kwargs) -> Self: ... def create_table(self, name, safe: bool = True, **meta): ... def __sql_selection__(self, ctx, is_subquery: bool = False): ... @@ -1965,14 +1967,14 @@ class NoopModelSelect(ModelSelect): class _ModelWriteQueryHelper(_ModelQueryHelper): model: Incomplete def __init__(self, model, *args, **kwargs) -> None: ... - def returning(self, *returning): ... + def returning(self, *returning) -> Self: ... class ModelUpdate(_ModelWriteQueryHelper, Update): ... # type: ignore[misc] class ModelInsert(_ModelWriteQueryHelper, Insert): # type: ignore[misc] default_row_type: Incomplete def __init__(self, *args, **kwargs) -> None: ... - def returning(self, *returning): ... + def returning(self, *returning) -> Self: ... def get_default_data(self): ... def get_default_columns(self): ...