diff --git a/stubs/peewee/METADATA.toml b/stubs/peewee/METADATA.toml index 5fc0f5088484..fd90d18f0b87 100644 --- a/stubs/peewee/METADATA.toml +++ b/stubs/peewee/METADATA.toml @@ -1,4 +1,4 @@ -version = "4.0.0" +version = "4.0.1" 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 13f5b1922710..4473cb766d91 100644 --- a/stubs/peewee/peewee.pyi +++ b/stubs/peewee/peewee.pyi @@ -6,7 +6,7 @@ from collections.abc import Callable, Generator, Iterable, Iterator from datetime import datetime from decimal import Decimal from types import TracebackType -from typing import Any, ClassVar, Final, Literal, NamedTuple, TypeVar +from typing import Any, ClassVar, Final, Literal, NamedTuple, TypeVar, overload from typing_extensions import Self from uuid import UUID @@ -20,6 +20,7 @@ basestring = str long = int izip_longest = itertools.zip_longest +_T = TypeVar("_T") _VT = TypeVar("_VT") _F = TypeVar("_F", bound=Callable[..., Any]) @@ -400,6 +401,7 @@ class SQL(ColumnBase): def __sql__(self, ctx): ... def Check(constraint, name=None): ... +def Default(value) -> SQL: ... class Function(ColumnBase): no_coerce_functions: ClassVar[set[str]] @@ -849,7 +851,9 @@ class SqliteDatabase(Database): server_version: Incomplete truncate_table: bool nulls_ordering: bool - def __init__(self, database, regexp_function: bool = False, *args, **kwargs) -> None: ... + def __init__( + self, database, pragmas=None, regexp_function: bool = False, rank_functions: bool = False, *args, **kwargs + ) -> None: ... returning_clause: Incomplete def init(self, database, pragmas=None, timeout: int = 5, returning_clause=None, **kwargs) -> None: ... def pragma(self, key, value=..., permanent: bool = False, schema: str | None = None): ... @@ -902,7 +906,20 @@ class SqliteDatabase(Database): def to_timestamp(self, date_field) -> Cast: ... def from_timestamp(self, date_field) -> Function: ... -class Psycopg2Adapter: +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 + def isolation_level_str(self, isolation_level: _T) -> _T: ... + +class Psycopg2Adapter(_BasePsycopgAdapter): json_type: Incomplete jsonb_type: Incomplete cast_json_case: bool @@ -916,7 +933,7 @@ class Psycopg2Adapter: def is_connection_closed(self, conn) -> bool: ... def extract_date(self, date_part, date_field) -> Function: ... -class Psycopg3Adapter: +class Psycopg3Adapter(_BasePsycopgAdapter): json_type: Incomplete jsonb_type: Incomplete cast_json_case: bool @@ -973,6 +990,7 @@ class PostgresqlDatabase(Database): def from_timestamp(self, date_field) -> Function: ... def get_noop_select(self, ctx): ... def set_time_zone(self, timezone) -> None: ... + def set_isolation_level(self, isolation_level: int | str) -> None: ... class MySQLDatabase(Database): field_types: Incomplete @@ -1037,7 +1055,7 @@ class _savepoint(_callable_context_manager): quoted_sid: Incomplete def __init__(self, db, sid=None) -> None: ... def commit(self, begin: bool = True) -> None: ... - def rollback(self) -> None: ... + def rollback(self, begin: bool = True) -> None: ... def __enter__(self) -> Self: ... def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None @@ -1854,6 +1872,7 @@ __all__ = [ "DateField", "DateTimeField", "DecimalField", + "Default", "DeferredForeignKey", "DeferredThroughModel", "DJANGO_MAP",