diff --git a/odoo-stubs/api.pyi b/odoo-stubs/api.pyi index 70b665f..12fa52a 100644 --- a/odoo-stubs/api.pyi +++ b/odoo-stubs/api.pyi @@ -48,7 +48,7 @@ def call_kw(model: BaseModel, name: str, args, kwargs): ... class Environment(Mapping): cr: Cursor = ... uid: int = ... - context: dict = ... + context: dict[str, Any] = ... su: bool = ... envs: None args: tuple[Cursor, int, dict, bool] diff --git a/odoo-stubs/tools/misc.pyi b/odoo-stubs/tools/misc.pyi index 9d35d05..900a3f5 100644 --- a/odoo-stubs/tools/misc.pyi +++ b/odoo-stubs/tools/misc.pyi @@ -1,123 +1,135 @@ -from .cache import * import pickle as pickle_ +from collections.abc import Mapping, MutableMapping, MutableSet +from logging import Filter, LogRecord +from typing import Any, Collection, Generic, IO, AnyStr, Iterable, Iterator, NoReturn, TypeVar, Callable + import xlsxwriter import xlwt +from babel.core import Locale +from xlwt import Worksheet + +from .cache import * from .parse_version import parse_version as parse_version -from collections.abc import Mapping, MutableMapping, MutableSet -from odoo.loglevels import exception_to_unicode as exception_to_unicode, get_encodings as get_encodings -from typing import Any +from ..loglevels import exception_to_unicode as exception_to_unicode, get_encodings as get_encodings +from ..sql_db import Cursor -_logger: Any -SKIPPED_ELEMENT_TYPES: Any +_T = TypeVar('_T') +_T1 = TypeVar('_T1') +_KT = TypeVar('_KT') +_VT = TypeVar('_VT') -def find_in_path(name): ... -def _exec_pipe(prog, args, env: Any | None = ...): ... -def exec_command_pipe(name, *args): ... -def find_pg_tool(name): ... -def exec_pg_environ(): ... -def exec_pg_command(name, *args) -> None: ... -def exec_pg_command_pipe(name, *args): ... -def file_path(file_path, filter_ext=...): ... -def file_open(name, mode: str = ..., filter_ext: Any | None = ...): ... -def flatten(list): ... +SKIPPED_ELEMENT_TYPES: tuple +NON_BREAKING_SPACE: str + +def find_in_path(name: str) -> str: ... +def _exec_pipe(prog, args, env: Mapping[str, str] | None = ...) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... +def exec_command_pipe(name: str, *args) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... +def find_pg_tool(name: str) -> str: ... +def exec_pg_environ() -> dict[str, str]: ... +def exec_pg_command(name: str, *args) -> 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_open(name: str, mode: str = ..., filter_ext: tuple[str] | None = ...) -> IO: ... +def flatten(list) -> list: ... def reverse_enumerate(l): ... -def partition(pred, elems): ... -def topological_sort(elems): ... -def merge_sequences(*iterables): ... +def partition(pred: Callable[[_T], bool], elems: Iterable[_T]) -> tuple[list[_T], list[_T]]: ... +def topological_sort(elems: dict[_T, Any]) -> list[_T]: ... +def merge_sequences(*iterables: Iterable[_T]) -> list[_T]: ... class PatchedWorkbook(xlwt.Workbook): - def add_sheet(self, name, cell_overwrite_ok: bool = ...): ... + def add_sheet(self, name: str, cell_overwrite_ok: bool = ...) -> Worksheet: ... class PatchedXlsxWorkbook(xlsxwriter.Workbook): - def add_worksheet(self, name: Any | None = ..., **kw): ... + def add_worksheet(self, name: str | None = ..., **kw) -> Worksheet: ... -def to_xml(s): ... -def get_iso_codes(lang): ... -def scan_languages(): ... -def mod10r(number): ... -def str2bool(s, default: Any | None = ...): ... -def human_size(sz): ... -def logged(f): ... +def to_xml(s: str) -> str: ... +def get_iso_codes(lang: str) -> str: ... +def scan_languages() -> list[tuple[str, str]]: ... +def mod10r(number: str) -> str: ... +def str2bool(s: str, default: Any | None = ...) -> bool: ... +def human_size(sz) -> str: ... +def logged(f: Callable) -> Callable: ... class profile: - fname: Any - def __init__(self, fname: Any | None = ...) -> None: ... - def __call__(self, f): ... + fname: str | None + def __init__(self, fname: str | None = ...) -> None: ... + def __call__(self, f: Callable) -> Callable: ... -def detect_ip_addr(): ... +def detect_ip_addr() -> str: ... DEFAULT_SERVER_DATE_FORMAT: str DEFAULT_SERVER_TIME_FORMAT: str -DEFAULT_SERVER_DATETIME_FORMAT: Any -DATE_LENGTH: Any -DATETIME_FORMATS_MAP: Any -POSIX_TO_LDML: Any +DEFAULT_SERVER_DATETIME_FORMAT: str +DATE_LENGTH: int +DATETIME_FORMATS_MAP: dict[str, str] +POSIX_TO_LDML: dict[str, str] -def posix_to_ldml(fmt, locale): ... -def split_every(n, iterable, piece_maker=...) -> None: ... -def get_and_group_by_field(cr, uid, obj, ids, field, context: Any | None = ...): ... -def get_and_group_by_company(cr, uid, obj, ids, context: Any | None = ...): ... -def resolve_attr(obj, attr): ... +def posix_to_ldml(fmt: str, locale: Locale) -> str: ... +def split_every(n: int, iterable: Iterable[_T], piece_maker: Callable[[Iterable[_T]], _T1] = ...) -> Iterator[_T1]: ... +def get_and_group_by_field(cr: Cursor, uid: int, obj, ids, field: str, context: dict | None = ...) -> dict: ... +def get_and_group_by_company(cr: Cursor, uid: int, obj, ids, context: dict | None = ...) -> dict: ... +def resolve_attr(obj, attr: str): ... def attrgetter(*items): ... -def discardattr(obj, key) -> None: ... -def remove_accents(input_str): ... +def discardattr(obj, key: str) -> None: ... +def remove_accents(input_str: str) -> str: ... class unquote(str): - def __repr__(self): ... + def __repr__(self) -> str: ... class UnquoteEvalContext(defaultdict): def __init__(self, *args, **kwargs) -> None: ... - def __missing__(self, key): ... + def __missing__(self, key) -> unquote: ... -class mute_logger: - loggers: Any - def __init__(self, *loggers) -> None: ... - def filter(self, record): ... +class mute_logger(Filter): + loggers: tuple[str] + def __init__(self, *loggers: str) -> None: ... + def filter(self, record: LogRecord) -> int: ... def __enter__(self) -> None: ... def __exit__(self, exc_type: Any | None = ..., exc_val: Any | None = ..., exc_tb: Any | None = ...) -> None: ... - def __call__(self, func): ... + def __call__(self, func: Callable) -> Callable: ... _ph: Any -class CountingStream: - stream: Any - index: Any +class CountingStream(Generic[_T]): + stream: Iterator[_T] + index: int stopped: bool - def __init__(self, stream, start: int = ...) -> None: ... - def __iter__(self): ... - def next(self): ... - __next__: Any + def __init__(self, stream: Iterable[_T], start: int = ...) -> None: ... + def __iter__(self) -> CountingStream[_T]: ... + def next(self) -> _T: ... + __next__ = next -def stripped_sys_argv(*strip_args): ... +def stripped_sys_argv(*strip_args: str) -> list[str]: ... -class ConstantMapping(Mapping): - __slots__: Any - _value: Any - def __init__(self, val) -> None: ... - def __len__(self): ... - def __iter__(self): ... - def __getitem__(self, item): ... +class ConstantMapping(Mapping[_KT, _VT]): + __slots__ = ['_value'] + _value: _VT + def __init__(self, val: _VT) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator: ... + def __getitem__(self, item) -> _VT: ... def dumpstacks(sig: Any | None = ..., frame: Any | None = ..., thread_idents: Any | None = ...) -> None: ... -def freehash(arg): ... -def clean_context(context): ... +def freehash(arg) -> int: ... +def clean_context(context: dict[str, Any]) -> dict[str, Any]: ... class frozendict(dict): - __slots__: Any - def __delitem__(self, key) -> None: ... - def __setitem__(self, key, val) -> None: ... - def clear(self) -> None: ... - def pop(self, key, default: Any | None = ...) -> None: ... - def popitem(self) -> None: ... - def setdefault(self, key, default: Any | None = ...) -> None: ... - def update(self, *args, **kwargs) -> None: ... - def __hash__(self): ... + __slots__ = () + def __delitem__(self, key) -> NoReturn: ... + def __setitem__(self, key, val) -> NoReturn: ... + def clear(self) -> NoReturn: ... + def pop(self, key, default: Any | None = ...) -> NoReturn: ... + def popitem(self) -> NoReturn: ... + def setdefault(self, key, default: Any | None = ...) -> NoReturn: ... + def update(self, *args, **kwargs) -> NoReturn: ... + def __hash__(self) -> int: ... -class Collector(dict): - __slots__: Any - def __getitem__(self, key): ... - def __setitem__(self, key, val) -> None: ... - def add(self, key, val) -> None: ... +class Collector(dict[_KT, tuple[_T]]): + __slots__ = () + def __getitem__(self, key: _KT) -> tuple[_T]: ... + def __setitem__(self, key: _KT, val: Iterable[_T]) -> None: ... + def add(self, key: _KT, val: _T) -> None: ... + def discard_keys_and_values(self, excludes: Collection): ... class StackMap(MutableMapping): __slots__: Any