Update stubs

This commit is contained in:
Trinh Anh Ngoc
2022-10-16 16:03:04 +07:00
parent e0f5c762e0
commit b4919fe7a3

View File

@@ -1,29 +1,40 @@
from datetime import datetime from datetime import datetime
from re import Pattern from re import Pattern
from threading import Lock, RLock from threading import Lock, RLock
from typing import Any, Callable, Iterable, Iterator, Literal, NoReturn, Sequence, TypeVar from typing import Any, Generator, Iterable, Iterator, Literal, NoReturn, Sequence, TypeVar
import psycopg2.extensions import psycopg2.extensions
from decorator import decorator from psycopg2.sql import Identifier
from .api import Transaction from .api import Transaction
from .tools import Callbacks from .tools import Callbacks
_T = TypeVar('_T') _T = TypeVar('_T')
_CursorT = TypeVar('_CursorT', bound=Cursor) _CursorT = TypeVar('_CursorT', bound=Cursor)
_SavepointT = TypeVar('_SavepointT', bound=Savepoint)
def unbuffer(symb, cr: Cursor): ... def undecimalize(symb, cr: Cursor) -> float | None: ...
def undecimalize(symb, cr: Cursor): ...
def adapt_string(adapted: str) -> psycopg2.extensions.QuotedString: ...
def flush_env(cr: Cursor, *, clear: bool = ...) -> None: ...
def clear_env(cr: Cursor) -> None: ...
re_from: Pattern re_from: Pattern
re_into: Pattern re_into: Pattern
sql_counter: int sql_counter: int
@decorator class Savepoint:
def check(f: Callable[..., _T], self: Cursor, *args, **kwargs) -> _T: ... name: str
_name: Identifier
_cr: BaseCursor
closed: bool
def __init__(self, cr: BaseCursor) -> None: ...
def __enter__(self: _SavepointT) -> _SavepointT: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def close(self, *, rollback: bool = ...) -> None: ...
def rollback(self) -> None: ...
def _close(self, rollback: bool) -> None: ...
class _FlushingSavepoint(Savepoint):
def __init__(self, cr: BaseCursor) -> None: ...
def rollback(self) -> None: ...
def _close(self, rollback: bool) -> None: ...
class BaseCursor: class BaseCursor:
precommit: Callbacks precommit: Callbacks
@@ -39,7 +50,7 @@ class BaseCursor:
def flush(self) -> None: ... def flush(self) -> None: ...
def clear(self) -> None: ... def clear(self) -> None: ...
def reset(self) -> None: ... def reset(self) -> None: ...
def savepoint(self, flush: bool = ...) -> None: ... def savepoint(self, flush: bool = ...) -> Savepoint: ...
def __enter__(self: _CursorT) -> _CursorT: ... def __enter__(self: _CursorT) -> _CursorT: ...
def __exit__(self, exc_type, exc_value, traceback) -> None: ... def __exit__(self, exc_type, exc_value, traceback) -> None: ...
@@ -47,32 +58,29 @@ class Cursor(BaseCursor):
IN_MAX: int IN_MAX: int
sql_from_log: dict sql_from_log: dict
sql_into_log: dict sql_into_log: dict
sql_log: bool
sql_log_count: int sql_log_count: int
_closed: bool _closed: bool
__pool: ConnectionPool __pool: ConnectionPool
dbname: str dbname: str
_serialized: bool
_cnx: PsycoConnection _cnx: PsycoConnection
_obj: psycopg2.extensions.cursor _obj: psycopg2.extensions.cursor
__caller: tuple[str, int | str] | Literal[False] __caller: tuple[str, int | str] | Literal[False]
_default_log_exceptions: bool
cache: dict cache: dict
_now: datetime | None _now: datetime | None
def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict, serialized: bool = ...) -> None: ... def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict, **kwargs) -> None: ...
def __build_dict(self, row: Sequence) -> dict[str, Any]: ... def __build_dict(self, row: Sequence) -> dict[str, Any]: ...
def dictfetchone(self) -> dict[str, Any] | None: ... def dictfetchone(self) -> dict[str, Any] | None: ...
def dictfetchmany(self, size) -> list[dict[str, Any]]: ... def dictfetchmany(self, size) -> list[dict[str, Any]]: ...
def dictfetchall(self) -> list[dict[str, Any]]: ... def dictfetchall(self) -> list[dict[str, Any]]: ...
def __del__(self) -> None: ... def __del__(self) -> None: ...
def _format(self, query, params: Any | None = ...): ... def _format(self, query, params: Any | None = ...): ...
def execute(self, query, params: Any | None = ..., log_exceptions: Any | None = ...): ... def execute(self, query, params: Any | None = ..., log_exceptions: bool = ...): ...
def split_for_in_conditions(self, ids: Iterable, size: int | None = ...) -> Iterator[tuple]: ... def split_for_in_conditions(self, ids: Iterable, size: int | None = ...) -> Iterator[tuple]: ...
def print_log(self): ... def print_log(self): ...
def _enable_logging(self) -> Generator[None, None, None]: ...
def close(self): ... def close(self): ...
def _close(self, leak: bool = ...) -> None: ... def _close(self, leak: bool = ...) -> None: ...
def autocommit(self, on: bool) -> None: ... def autocommit(self, on: bool) -> None: ...
def after(self, event: str, func: Callable) -> None: ...
def commit(self): ... def commit(self): ...
def rollback(self): ... def rollback(self): ...
def __getattr__(self, name: str): ... def __getattr__(self, name: str): ...
@@ -81,22 +89,24 @@ class Cursor(BaseCursor):
def now(self) -> datetime: ... def now(self) -> datetime: ...
class TestCursor(BaseCursor): class TestCursor(BaseCursor):
_savepoint_seq: Iterator[int] _cursors_stack: list[TestCursor]
_now: datetime | None
_closed: bool _closed: bool
_cursor: Cursor _cursor: Cursor
_lock: RLock _lock: RLock
_savepoint: str _savepoint: Savepoint | None
def __init__(self, cursor: Cursor, lock: RLock) -> None: ... def __init__(self, cursor: Cursor, lock: RLock) -> None: ...
def execute(self, *args, **kwargs): ...
def close(self) -> None: ... def close(self) -> None: ...
def autocommit(self, on: bool) -> None: ... def autocommit(self, on: bool) -> None: ...
def commit(self) -> None: ... def commit(self) -> None: ...
def rollback(self) -> None: ... def rollback(self) -> None: ...
def __getattr__(self, name: str): ... def __getattr__(self, name: str): ...
def now(self) -> datetime: ...
class PsycoConnection(psycopg2.extensions.connection): ... class PsycoConnection(psycopg2.extensions.connection): ...
class ConnectionPool: class ConnectionPool:
def locked(fun: Callable[..., _T]) -> Callable[..., _T]: ...
_connections: list[tuple[psycopg2.extensions.connection, bool]] _connections: list[tuple[psycopg2.extensions.connection, bool]]
_maxconn: int _maxconn: int
_lock: Lock _lock: Lock
@@ -112,8 +122,8 @@ class Connection:
dsn: dict dsn: dict
__pool: ConnectionPool __pool: ConnectionPool
def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict) -> None: ... def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict) -> None: ...
def cursor(self, serialized: bool = ...) -> Cursor: ... def cursor(self, **kwargs) -> Cursor: ...
serialized_cursor = cursor def serialized_cursor(self, **kwargs) -> Cursor: ...
def __bool__(self) -> NoReturn: ... def __bool__(self) -> NoReturn: ...
def connection_info_for(db_or_uri: str) -> tuple[str, dict]: ... def connection_info_for(db_or_uri: str) -> tuple[str, dict]: ...