Update stubs

This commit is contained in:
Trinh Anh Ngoc
2022-10-07 22:47:08 +07:00
parent f1e2217ed7
commit 09d89a7c60
5 changed files with 61 additions and 46 deletions

View File

@@ -23,18 +23,18 @@ class Params:
class Meta(type): class Meta(type):
def __new__(meta, name: str, bases: tuple, attrs: dict): ... def __new__(meta, name: str, bases: tuple, attrs: dict): ...
def attrsetter(attr, value) -> Callable: ... def attrsetter(attr, value) -> Callable[[_T], _T]: ...
def propagate(method1: Callable, method2: _CallableT) -> _CallableT: ... def propagate(method1: Callable, method2: _CallableT) -> _CallableT: ...
def constrains(*args: str) -> Callable: ... def constrains(*args: str) -> Callable[[_T], _T]: ...
def ondelete(*, at_uninstall: bool) -> Callable: ... def ondelete(*, at_uninstall: bool) -> Callable[[_T], _T]: ...
def onchange(*args: str) -> Callable: ... def onchange(*args: str) -> Callable[[_T], _T]: ...
def depends(*args: Union[str, Callable]) -> Callable: ... def depends(*args: Union[str, Callable]) -> Callable[[_T], _T]: ...
def depends_context(*args: str) -> Callable: ... def depends_context(*args: str) -> Callable[[_T], _T]: ...
def returns(model: str | None, downgrade: Callable | None = ..., upgrade: Callable | None = ...) -> Callable: ... def returns(model: str | None, downgrade: Callable | None = ..., upgrade: Callable | None = ...) -> Callable[[_T], _T]: ...
def downgrade(method: Callable, value, self, args, kwargs): ... def downgrade(method: Callable, value, self, args, kwargs): ...
def split_context(method: Callable, args, kwargs) -> tuple: ... def split_context(method: Callable, args, kwargs) -> tuple: ...
def autovacuum(method: Callable) -> Callable: ... def autovacuum(method: _CallableT) -> _CallableT: ...
def model(method: Callable) -> Callable: ... def model(method: _CallableT) -> _CallableT: ...
def _model_create_single(create: Callable[..., _ModelT], self: _ModelT, arg) -> _ModelT: ... def _model_create_single(create: Callable[..., _ModelT], self: _ModelT, arg) -> _ModelT: ...
def model_create_single(method: _CallableT) -> _CallableT: ... def model_create_single(method: _CallableT) -> _CallableT: ...

View File

@@ -4,6 +4,7 @@ from threading import Lock, RLock
from typing import Any, Callable, Iterable, Iterator, Literal, NoReturn, Sequence, TypeVar from typing import Any, Callable, Iterable, Iterator, Literal, NoReturn, Sequence, TypeVar
import psycopg2.extensions import psycopg2.extensions
from decorator import decorator
from .api import Transaction from .api import Transaction
from .tools import Callbacks from .tools import Callbacks
@@ -21,6 +22,7 @@ re_from: Pattern
re_into: Pattern re_into: Pattern
sql_counter: int sql_counter: int
@decorator
def check(f: Callable[..., _T], self: Cursor, *args, **kwargs) -> _T: ... def check(f: Callable[..., _T], self: Cursor, *args, **kwargs) -> _T: ...
class BaseCursor: class BaseCursor:
@@ -94,7 +96,7 @@ class TestCursor(BaseCursor):
class PsycoConnection(psycopg2.extensions.connection): ... class PsycoConnection(psycopg2.extensions.connection): ...
class ConnectionPool: class ConnectionPool:
def locked(fun: Callable) -> Callable: ... 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

View File

@@ -1,9 +1,12 @@
from collections import defaultdict from collections import defaultdict
from typing import Any, Callable from typing import Any, Callable, TypeVar
from .lru import LRU from .lru import LRU
from ..models import BaseModel from ..models import BaseModel
_T = TypeVar('_T')
_CallableT = TypeVar('_CallableT')
unsafe_eval = eval unsafe_eval = eval
class ormcache_counter: class ormcache_counter:
@@ -21,7 +24,7 @@ class ormcache:
skiparg: Any skiparg: Any
def __init__(self, *args, **kwargs) -> None: ... def __init__(self, *args, **kwargs) -> None: ...
method: Callable method: Callable
def __call__(self, method: Callable): ... def __call__(self, method: _CallableT) -> _CallableT: ...
key: Any key: Any
def determine_key(self): ... def determine_key(self): ...
def lru(self, model: BaseModel) -> tuple[LRU, tuple[str, Callable], ormcache_counter]: ... def lru(self, model: BaseModel) -> tuple[LRU, tuple[str, Callable], ormcache_counter]: ...

View File

@@ -1,27 +1,29 @@
from json import JSONEncoder as JSONEncoder from json import JSONEncoder as JSONEncoder
from typing import Any, Callable from typing import Callable, Generic, TypeVar
class lazy_property: _T = TypeVar('_T')
fget: Any
def __init__(self, fget) -> None: ... class lazy_property(Generic[_T]):
def __get__(self, obj, cls): ... fget: Callable[..., _T]
def __init__(self, fget: Callable[..., _T]) -> None: ...
def __get__(self, obj, cls) -> _T: ...
@property @property
def __doc__(self): ... def __doc__(self): ...
@staticmethod @staticmethod
def reset_all(obj) -> None: ... def reset_all(obj) -> None: ...
class lazy_classproperty(lazy_property): class lazy_classproperty(lazy_property[_T]):
def __get__(self, obj, cls): ... def __get__(self, obj, cls) -> _T: ...
def conditional(condition, decorator): ... def conditional(condition, decorator): ...
def synchronized(lock_attr: str = ...): ... def synchronized(lock_attr: str = ...): ...
def frame_codeinfo(fframe, back: int = ...): ... def frame_codeinfo(fframe, back: int = ...): ...
def compose(a: Callable, b: Callable): ... def compose(a: Callable[..., _T], b: Callable) -> Callable[..., _T]: ...
class _ClassProperty(property): class _ClassProperty(property, Generic[_T]):
def __get__(self, cls, owner): ... def __get__(self, cls, owner) -> _T: ...
def classproperty(func): ... def classproperty(func: Callable[..., _T]) -> _ClassProperty[_T]: ...
class lazy: class lazy:
__slots__ = ['_func', '_args', '_kwargs', '_cached_value'] __slots__ = ['_func', '_args', '_kwargs', '_cached_value']

View File

@@ -1,7 +1,9 @@
import datetime
import pickle as pickle_ import pickle as pickle_
from collections import deque from collections import deque
from collections.abc import Mapping, MutableMapping, MutableSet from collections.abc import Mapping, MutableMapping, MutableSet
from logging import Filter, LogRecord from logging import Filter, LogRecord
from types import ModuleType
from typing import Any, Collection, Generic, IO, AnyStr, ItemsView, Iterable, Iterator, NoReturn, TypeVar, Callable from typing import Any, Collection, Generic, IO, AnyStr, ItemsView, Iterable, Iterator, NoReturn, TypeVar, Callable
import markupsafe import markupsafe
@@ -12,6 +14,7 @@ from xlwt import Worksheet
from .cache import * from .cache import *
from .parse_version import parse_version as parse_version from .parse_version import parse_version as parse_version
from ..api import Environment
from ..loglevels import exception_to_unicode as exception_to_unicode, get_encodings as get_encodings from ..loglevels import exception_to_unicode as exception_to_unicode, get_encodings as get_encodings
from ..sql_db import Cursor from ..sql_db import Cursor
@@ -19,6 +22,7 @@ _T = TypeVar('_T')
_T1 = TypeVar('_T1') _T1 = TypeVar('_T1')
_KT = TypeVar('_KT') _KT = TypeVar('_KT')
_VT = TypeVar('_VT') _VT = TypeVar('_VT')
_CallableT = TypeVar('_CallableT', bound=Callable)
SKIPPED_ELEMENT_TYPES: tuple SKIPPED_ELEMENT_TYPES: tuple
NON_BREAKING_SPACE: str NON_BREAKING_SPACE: str
@@ -31,7 +35,7 @@ def exec_pg_environ() -> dict[str, str]: ...
def exec_pg_command(name: str, *args) -> None: ... def exec_pg_command(name: str, *args) -> None: ...
def exec_pg_command_pipe(name: str, *args) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... def exec_pg_command_pipe(name: str, *args) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ...
def file_path(file_path: str, filter_ext: tuple[str, ...] = ...) -> str: ... def file_path(file_path: str, filter_ext: tuple[str, ...] = ...) -> str: ...
def file_open(name: str, mode: str = ..., filter_ext: tuple[str] | None = ...) -> IO: ... def file_open(name: str, mode: str = ..., filter_ext: tuple[str, ...] | None = ...) -> IO: ...
def flatten(list) -> list: ... def flatten(list) -> list: ...
def reverse_enumerate(l): ... def reverse_enumerate(l): ...
def partition(pred: Callable[[_T], bool], elems: Iterable[_T]) -> tuple[list[_T], list[_T]]: ... def partition(pred: Callable[[_T], bool], elems: Iterable[_T]) -> tuple[list[_T], list[_T]]: ...
@@ -50,12 +54,12 @@ def scan_languages() -> list[tuple[str, str]]: ...
def mod10r(number: str) -> str: ... def mod10r(number: str) -> str: ...
def str2bool(s: str, default: Any | None = ...) -> bool: ... def str2bool(s: str, default: Any | None = ...) -> bool: ...
def human_size(sz) -> str: ... def human_size(sz) -> str: ...
def logged(f: Callable) -> Callable: ... def logged(f: _CallableT) -> _CallableT: ...
class profile: class profile:
fname: str | None fname: str | None
def __init__(self, fname: str | None = ...) -> None: ... def __init__(self, fname: str | None = ...) -> None: ...
def __call__(self, f: Callable) -> Callable: ... def __call__(self, f: _CallableT) -> _CallableT: ...
def detect_ip_addr() -> str: ... def detect_ip_addr() -> str: ...
@@ -88,7 +92,7 @@ class mute_logger(Filter):
def filter(self, record: LogRecord) -> int: ... def filter(self, record: LogRecord) -> int: ...
def __enter__(self) -> None: ... def __enter__(self) -> None: ...
def __exit__(self, exc_type: Any | None = ..., exc_val: Any | None = ..., exc_tb: Any | None = ...) -> None: ... def __exit__(self, exc_type: Any | None = ..., exc_val: Any | None = ..., exc_tb: Any | None = ...) -> None: ...
def __call__(self, func: Callable) -> Callable: ... def __call__(self, func: _CallableT) -> _CallableT: ...
_ph: Any _ph: Any
@@ -196,33 +200,37 @@ def ignore(*exc) -> None: ...
html_escape = markupsafe.escape html_escape = markupsafe.escape
def get_lang(env, lang_code: str = ...): ... def get_lang(env: Environment, lang_code: str = ...) -> 'odoo.model.res_lang': ...
def babel_locale_parse(lang_code): ... def babel_locale_parse(lang_code: str) -> Locale: ...
def formatLang(env, value, digits: Any | None = ..., grouping: bool = ..., monetary: bool = ..., dp: bool = ..., currency_obj: bool = ...): ... def formatLang(env: Environment, value, digits: int | None = ..., grouping: bool = ..., monetary: bool = ...,
def format_date(env, value, lang_code: str = ..., date_format: bool = ...): ... dp: bool = ..., currency_obj: 'odoo.model.res_currency' = ...) -> str: ...
def parse_date(env, value, lang_code: str = ...): ... def format_date(env: Environment, value: datetime.date | datetime.datetime | str, lang_code: str = ...,
def format_datetime(env, value, tz: str = ..., dt_format: str = ..., lang_code: str = ...): ... date_format: str = ...) -> str: ...
def format_time(env, value, tz: str = ..., time_format: str = ..., lang_code: str = ...): ... def parse_date(env: Environment, value: str, lang_code: str = ...) -> datetime.date: ...
def _format_time_ago(env, time_delta, lang_code: str = ..., add_direction: bool = ...): ... def format_datetime(env: Environment, value: str | datetime.datetime, tz: str = ...,
def format_decimalized_number(number, decimal: int = ...): ... dt_format: str = ..., lang_code: str = ...) -> str: ...
def format_decimalized_amount(amount, currency: Any | None = ...): ... def format_time(env: Environment, value, tz: str = ..., time_format: str = ..., lang_code: str = ...) -> str: ...
def format_amount(env, amount, currency, lang_code: str = ...): ... def _format_time_ago(env: Environment, time_delta: datetime.timedelta | int, lang_code: str = ...,
def format_duration(value): ... add_direction: bool = ...) -> str: ...
def _consteq(str1, str2): ... def format_decimalized_number(number: float, decimal: int = ...) -> str: ...
def format_decimalized_amount(amount: float, currency: 'odoo.model.res_currency | None' = ...) -> str: ...
def format_amount(env: Environment, amount: float, currency: 'odoo.model.res_currency', lang_code: str = ...) -> str: ...
def format_duration(value: float) -> str: ...
def _consteq(str1: str, str2: str) -> bool: ...
consteq: Any consteq: Callable[[str, str], bool]
class Unpickler(pickle_.Unpickler): class Unpickler(pickle_.Unpickler):
find_global: Any find_global: Any
find_class: Any find_class: Any
def _pickle_load(stream, encoding: str = ..., errors: bool = ...): ... def _pickle_load(stream: pickle_._ReadableFileobj, encoding: str = ..., errors: bool = ...): ...
pickle: Any pickle: ModuleType
class DotDict(dict): class DotDict(dict):
def __getattr__(self, attrib): ... def __getattr__(self, attrib): ...
def get_diff(data_from, data_to, custom_style: bool = ...): ... def get_diff(data_from: tuple[str, str], data_to: tuple[str, str], custom_style: bool = ...) -> str: ...
def traverse_containers(val, type_) -> None: ... def traverse_containers(val, type_) -> Iterator: ...
def hmac(env, scope, message, hash_function=...): ... def hmac(env: Environment, scope, message, hash_function = ...) -> str: ...