From b83ce3c76f38238c3fddfd2fe7f3cc6b7b060a11 Mon Sep 17 00:00:00 2001 From: Trinh Anh Ngoc Date: Sat, 5 Nov 2022 14:26:47 +0700 Subject: [PATCH] Update stubs --- odoo-stubs/tools/__init__.pyi | 10 +- odoo-stubs/tools/_monkeypatches.pyi | 0 odoo-stubs/tools/_vendor/__init__.pyi | 0 odoo-stubs/tools/_vendor/sessions.pyi | 53 ++++ odoo-stubs/tools/appdirs.pyi | 52 ++-- odoo-stubs/tools/cache.pyi | 65 +++-- odoo-stubs/tools/cloc.pyi | 41 +-- odoo-stubs/tools/config.pyi | 74 ++--- odoo-stubs/tools/convert.pyi | 94 ++++--- odoo-stubs/tools/date_utils.pyi | 27 +- odoo-stubs/tools/debugger.pyi | 7 +- odoo-stubs/tools/float_utils.pyi | 19 +- odoo-stubs/tools/func.pyi | 158 +++++------ odoo-stubs/tools/image.pyi | 54 ++-- odoo-stubs/tools/json.pyi | 10 +- odoo-stubs/tools/lru.pyi | 28 +- odoo-stubs/tools/mail.pyi | 86 +++--- odoo-stubs/tools/mimetypes.pyi | 36 +-- odoo-stubs/tools/misc.pyi | 325 ++++++++++++---------- odoo-stubs/tools/osutil.pyi | 18 +- odoo-stubs/tools/parse_version.pyi | 11 +- odoo-stubs/tools/pdf.pyi | 32 ++- odoo-stubs/tools/populate.pyi | 32 ++- odoo-stubs/tools/profiler.pyi | 22 +- odoo-stubs/tools/pycompat.pyi | 30 +- odoo-stubs/tools/safe_eval.pyi | 59 ++-- odoo-stubs/tools/sql.pyi | 59 ++-- odoo-stubs/tools/template_inheritance.pyi | 15 +- odoo-stubs/tools/test_reports.pyi | 14 +- odoo-stubs/tools/translate.pyi | 193 +++++++------ odoo-stubs/tools/view_validation.pyi | 34 ++- odoo-stubs/tools/which.pyi | 13 +- odoo-stubs/tools/win32.pyi | 4 +- odoo-stubs/tools/xml_utils.pyi | 19 +- 34 files changed, 935 insertions(+), 759 deletions(-) create mode 100644 odoo-stubs/tools/_monkeypatches.pyi create mode 100644 odoo-stubs/tools/_vendor/__init__.pyi create mode 100644 odoo-stubs/tools/_vendor/sessions.pyi diff --git a/odoo-stubs/tools/__init__.pyi b/odoo-stubs/tools/__init__.pyi index 2c9eb76..c1590d3 100644 --- a/odoo-stubs/tools/__init__.pyi +++ b/odoo-stubs/tools/__init__.pyi @@ -10,5 +10,13 @@ from .xml_utils import * from .date_utils import * from .convert import * from .template_inheritance import * -from . import appdirs as appdirs, cloc as cloc, osutil as osutil, pdf as pdf, pycompat as pycompat, win32 as win32 +from . import ( + _monkeypatches as _monkeypatches, + appdirs as appdirs, + cloc as cloc, + osutil as osutil, + pdf as pdf, + pycompat as pycompat, + win32 as win32 +) from .config import config as config diff --git a/odoo-stubs/tools/_monkeypatches.pyi b/odoo-stubs/tools/_monkeypatches.pyi new file mode 100644 index 0000000..e69de29 diff --git a/odoo-stubs/tools/_vendor/__init__.pyi b/odoo-stubs/tools/_vendor/__init__.pyi new file mode 100644 index 0000000..e69de29 diff --git a/odoo-stubs/tools/_vendor/sessions.pyi b/odoo-stubs/tools/_vendor/sessions.pyi new file mode 100644 index 0000000..ada438c --- /dev/null +++ b/odoo-stubs/tools/_vendor/sessions.pyi @@ -0,0 +1,53 @@ +from re import Pattern +from typing import Any, Generic, TypeVar + +from werkzeug.datastructures import CallbackDict + +_ModificationTrackingDictT = TypeVar('_ModificationTrackingDictT', bound=ModificationTrackingDict) +_SessionT = TypeVar('_SessionT', bound=Session) + +_sha1_re: Pattern + +def generate_key(salt: Any = ...) -> str: ... + +class ModificationTrackingDict(CallbackDict): + __slots__ = ('modified',) + modified: bool + def __init__(self, *args, **kwargs): ... + def copy(self: _ModificationTrackingDictT) -> _ModificationTrackingDictT: ... + def __copy__(self: _ModificationTrackingDictT) -> _ModificationTrackingDictT: ... + +class Session(ModificationTrackingDict): + __slots__ = ('modified', 'sid', 'new') + sid: str + new: bool + def __init__(self, data, sid, new: bool = ...): ... + def __repr__(self) -> str: ... + @property + def should_save(self) -> bool: ... + +class SessionStore(Generic[_SessionT]): + session_class: type[_SessionT] + def __init__(self, session_class: type[_SessionT] | None = ...): ... + def is_valid_key(self, key) -> bool: ... + def generate_key(self, salt: Any = ...) -> str: ... + def new(self) -> _SessionT: ... + def save(self, session: _SessionT) -> None: ... + def save_if_modified(self, session: _SessionT) -> None: ... + def delete(self, session: _SessionT) -> None: ... + def get(self, sid: str) -> _SessionT: ... + +_fs_transaction_suffix: str + +class FilesystemSessionStore(SessionStore[_SessionT]): + path: str | None + filename_template: str + renew_missing: bool + mode: int + def __init__(self, path: str | None = ..., filename_template: str = ..., session_class: type[_SessionT] | None = ..., + renew_missing: bool = ..., mode: int = ...) -> None: ... + def get_session_filename(self, sid: str) -> str: ... + def save(self, session: _SessionT) -> None: ... + def delete(self, session: _SessionT) -> None: ... + def get(self, sid: str) -> _SessionT: ... + def list(self) -> list[str]: ... diff --git a/odoo-stubs/tools/appdirs.pyi b/odoo-stubs/tools/appdirs.pyi index 840bd31..0b6cd4b 100644 --- a/odoo-stubs/tools/appdirs.pyi +++ b/odoo-stubs/tools/appdirs.pyi @@ -1,38 +1,36 @@ -from typing import Any, Optional +from typing import Callable -__version_info__: Any -__version__: Any +__version_info__: tuple +__version__: str -def user_data_dir(appname: Optional[Any] = ..., appauthor: Optional[Any] = ..., version: Optional[Any] = ..., roaming: bool = ...): ... -def site_data_dir(appname: Optional[Any] = ..., appauthor: Optional[Any] = ..., version: Optional[Any] = ..., multipath: bool = ...): ... -def user_config_dir(appname: Optional[Any] = ..., appauthor: Optional[Any] = ..., version: Optional[Any] = ..., roaming: bool = ...): ... -def site_config_dir(appname: Optional[Any] = ..., appauthor: Optional[Any] = ..., version: Optional[Any] = ..., multipath: bool = ...): ... -def user_cache_dir(appname: Optional[Any] = ..., appauthor: Optional[Any] = ..., version: Optional[Any] = ..., opinion: bool = ...): ... -def user_log_dir(appname: Optional[Any] = ..., appauthor: Optional[Any] = ..., version: Optional[Any] = ..., opinion: bool = ...): ... +def user_data_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., roaming: bool = ...) -> str: ... +def site_data_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., multipath: bool = ...) -> str: ... +def user_config_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., roaming: bool = ...) -> str: ... +def site_config_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., multipath: bool = ...) -> str: ... +def user_cache_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., opinion: bool = ...) -> str: ... +def user_log_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., opinion: bool = ...) -> str: ... class AppDirs: - appname: Any = ... - appauthor: Any = ... - version: Any = ... - roaming: Any = ... - multipath: Any = ... - def __init__(self, appname: Any, appauthor: Optional[Any] = ..., version: Optional[Any] = ..., roaming: bool = ..., multipath: bool = ...) -> None: ... + appname: str + appauthor: str | None + version: str | None + roaming: bool + multipath: bool + def __init__(self, appname: str, appauthor: str | None = ..., version: str | None = ..., roaming: bool = ..., multipath: bool = ...) -> None: ... @property - def user_data_dir(self): ... + def user_data_dir(self) -> str: ... @property - def site_data_dir(self): ... + def site_data_dir(self) -> str: ... @property - def user_config_dir(self): ... + def user_config_dir(self) -> str: ... @property - def site_config_dir(self): ... + def site_config_dir(self) -> str: ... @property - def user_cache_dir(self): ... + def user_cache_dir(self) -> str: ... @property - def user_log_dir(self): ... + def user_log_dir(self) -> str: ... -def _get_win_folder_from_registry(csidl_name: Any): ... -def _get_win_folder_with_pywin32(csidl_name: Any): ... -def _get_win_folder_with_ctypes(csidl_name: Any): ... -_get_win_folder = _get_win_folder_with_pywin32 -_get_win_folder = _get_win_folder_with_ctypes -_get_win_folder = _get_win_folder_from_registry +def _get_win_folder_from_registry(csidl_name: str) -> str: ... +def _get_win_folder_with_pywin32(csidl_name: str) -> str: ... +def _get_win_folder_with_ctypes(csidl_name: str) -> str: ... +_get_win_folder: Callable[[str], str] diff --git a/odoo-stubs/tools/cache.pyi b/odoo-stubs/tools/cache.pyi index bd737cd..55b9495 100644 --- a/odoo-stubs/tools/cache.pyi +++ b/odoo-stubs/tools/cache.pyi @@ -1,50 +1,55 @@ -from typing import Any, Optional +from collections import defaultdict +from typing import Any, Callable, TypeVar + +from .lru import LRU +from ..models import BaseModel + +_T = TypeVar('_T') +_CallableT = TypeVar('_CallableT') unsafe_eval = eval -_logger: Any class ormcache_counter: - __slots__: Any = ... - hit: int = ... - miss: int = ... - err: int = ... + hit: int + miss: int + err: int def __init__(self) -> None: ... @property - def ratio(self): ... + def ratio(self) -> float: ... -STAT: Any +STAT: defaultdict[Any, ormcache_counter] class ormcache: - args: Any = ... - skiparg: Any = ... - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - method: Any = ... - def __call__(self, method: Any): ... - key: Any = ... + args: Any + skiparg: Any + def __init__(self, *args, **kwargs) -> None: ... + method: Callable + def __call__(self, method: _CallableT) -> _CallableT: ... + key: Any def determine_key(self): ... - def lru(self, model: Any): ... - def lookup(self, method: Any, *args: Any, **kwargs: Any): ... - def clear(self, model: Any, *args: Any) -> None: ... + def lru(self, model: BaseModel) -> tuple[LRU, tuple[str, Callable], ormcache_counter]: ... + def lookup(self, method: Callable, *args, **kwargs): ... + def clear(self, model: BaseModel, *args) -> None: ... class ormcache_context(ormcache): - keys: Any = ... - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - key: Any = ... + keys: Any + def __init__(self, *args, **kwargs) -> None: ... + key: Any def determine_key(self) -> None: ... class ormcache_multi(ormcache): - multi: Any = ... - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - key_multi: Any = ... - multi_pos: Any = ... + multi: Any + def __init__(self, *args, **kwargs) -> None: ... + key_multi: Any + multi_pos: Any def determine_key(self) -> None: ... - def lookup(self, method: Any, *args: Any, **kwargs: Any): ... + def lookup(self, method: Callable, *args, **kwargs): ... class dummy_cache: - def __init__(self, *l: Any, **kw: Any) -> None: ... - def __call__(self, fn: Any): ... - def clear(self, *l: Any, **kw: Any) -> None: ... + def __init__(self, *l, **kw) -> None: ... + def __call__(self, fn): ... + def clear(self, *l, **kw) -> None: ... -def log_ormcache_stats(sig: Optional[Any] = ..., frame: Optional[Any] = ...): ... -def get_cache_key_counter(bound_method: Any, *args: Any, **kwargs: Any): ... +def log_ormcache_stats(sig: Any | None = ..., frame: Any | None = ...): ... +def get_cache_key_counter(bound_method, *args, **kwargs): ... cache = ormcache diff --git a/odoo-stubs/tools/cloc.pyi b/odoo-stubs/tools/cloc.pyi index 9cecae5..66cb725 100644 --- a/odoo-stubs/tools/cloc.pyi +++ b/odoo-stubs/tools/cloc.pyi @@ -1,24 +1,27 @@ -from typing import Any, Optional +from typing import Any + +from ..api import Environment VERSION: int -DEFAULT_EXCLUDE: Any -STANDARD_MODULES: Any -MAX_FILE_SIZE: Any +DEFAULT_EXCLUDE: list[str] +STANDARD_MODULES: list[str] +MAX_FILE_SIZE: int class Cloc: - modules: Any = ... - code: Any = ... - total: Any = ... - errors: Any = ... - max_width: int = ... + modules: dict + code: dict + total: dict + errors: dict + excluded: dict + max_width: int def __init__(self) -> None: ... - def parse_xml(self, s: Any): ... - def parse_py(self, s: Any): ... - def parse_js(self, s: Any): ... - def book(self, module: Any, item: str = ..., count: Any = ...) -> None: ... - def count_path(self, path: Any, exclude: Optional[Any] = ...) -> None: ... - def count_modules(self, env: Any) -> None: ... - def count_customization(self, env: Any) -> None: ... - def count_env(self, env: Any) -> None: ... - def count_database(self, database: Any) -> None: ... - def report(self, verbose: bool = ..., width: Optional[Any] = ...): ... + def parse_xml(self, s: str) -> tuple[int, int]: ... + def parse_py(self, s: str) -> tuple[int, int]: ... + def parse_js(self, s: str) -> tuple[int, int]: ... + def book(self, module: str, item: str = ..., count: tuple[Any, Any] = ..., exclude: bool = ...) -> None: ... + def count_path(self, path: str, exclude: set[str] | None = ...) -> None: ... + def count_modules(self, env: Environment) -> None: ... + def count_customization(self, env: Environment) -> None: ... + def count_env(self, env: Environment) -> None: ... + def count_database(self, database) -> None: ... + def report(self, verbose: bool = ..., width: float | None = ...): ... diff --git a/odoo-stubs/tools/config.pyi b/odoo-stubs/tools/config.pyi index 4bb93c2..f1a756e 100644 --- a/odoo-stubs/tools/config.pyi +++ b/odoo-stubs/tools/config.pyi @@ -1,49 +1,51 @@ -import optparse -from typing import Any, Optional +from optparse import Option, OptionParser +from typing import Any -crypt_context: Any +from passlib.context import CryptContext -class MyOption(optparse.Option): - my_default: Any = ... - def __init__(self, *opts: Any, **attrs: Any) -> None: ... +crypt_context: CryptContext + +class MyOption(Option): + my_default: Any + def __init__(self, *opts, **attrs) -> None: ... DEFAULT_LOG_HANDLER: str -def _get_default_datadir(): ... -def _deduplicate_loggers(loggers: Any): ... +def _get_default_datadir() -> str: ... +def _deduplicate_loggers(loggers) -> tuple[str, ...]: ... class configmanager: - options: Any = ... - blacklist_for_save: Any = ... - casts: Any = ... - misc: Any = ... - config_file: Any = ... - _LOGLEVELS: Any = ... - parser: Any = ... - def __init__(self, fname: Optional[Any] = ...) -> None: ... - def parse_config(self, args: Optional[Any] = ...): ... - rcfile: Any = ... - def _parse_config(self, args: Optional[Any] = ...): ... + options: dict[str, Any] + blacklist_for_save: set[str] + casts: dict + misc: dict + config_file: str + _LOGLEVELS: dict + parser: OptionParser + def __init__(self, fname: str | None = ...) -> None: ... + def parse_config(self, args: list | None = ...): ... + rcfile: str + def _parse_config(self, args: list | None = ...): ... def _warn_deprecated_options(self) -> None: ... - def _is_addons_path(self, path: Any): ... - def _check_addons_path(self, option: Any, opt: Any, value: Any, parser: Any) -> None: ... - def _check_upgrade_path(self, option: Any, opt: Any, value: Any, parser: Any) -> None: ... - def _is_upgrades_path(self, res: Any): ... - def _test_enable_callback(self, option: Any, opt: Any, value: Any, parser: Any) -> None: ... + def _is_addons_path(self, path: str) -> bool: ... + def _check_addons_path(self, option: MyOption, opt, value, parser: OptionParser) -> None: ... + def _check_upgrade_path(self, option: MyOption, opt, value, parser: OptionParser) -> None: ... + def _is_upgrades_path(self, res: str) -> bool: ... + def _test_enable_callback(self, option: MyOption, opt, value, parser: OptionParser) -> None: ... def load(self) -> None: ... def save(self) -> None: ... - def get(self, key: Any, default: Optional[Any] = ...): ... - def pop(self, key: Any, default: Optional[Any] = ...): ... - def get_misc(self, sect: Any, key: Any, default: Optional[Any] = ...): ... - def __setitem__(self, key: Any, value: Any) -> None: ... - def __getitem__(self, key: Any): ... + def get(self, key, default: Any | None = ...): ... + def pop(self, key, default: Any | None = ...): ... + def get_misc(self, sect, key, default: Any | None = ...): ... + def __setitem__(self, key, value) -> None: ... + def __getitem__(self, key): ... @property - def addons_data_dir(self): ... + def addons_data_dir(self) -> str: ... @property - def session_dir(self): ... - def filestore(self, dbname: Any): ... - def set_admin_password(self, new_password: Any) -> None: ... - def verify_admin_password(self, password: Any): ... - def _normalize(self, path: Any): ... + def session_dir(self) -> str: ... + def filestore(self, dbname: str) -> str: ... + def set_admin_password(self, new_password) -> None: ... + def verify_admin_password(self, password) -> bool: ... + def _normalize(self, path: str) -> str: ... -config: Any +config: configmanager diff --git a/odoo-stubs/tools/convert.pyi b/odoo-stubs/tools/convert.pyi index 4ac0b46..b3e99ca 100644 --- a/odoo-stubs/tools/convert.pyi +++ b/odoo-stubs/tools/convert.pyi @@ -1,54 +1,62 @@ -from .misc import ustr as ustr -from odoo import api as api -from typing import Any, Optional +from io import BufferedReader +from typing import Any, Callable, TextIO -__all__: Any -_logger: Any -safe_eval: Any +from lxml.etree import _Element + +from .misc import ustr as ustr +from ..api import Environment +from ..sql_db import Cursor + +__all__ = [ + 'convert_file', 'convert_sql_import', + 'convert_csv_import', 'convert_xml_import' +] + +safe_eval: Callable class ParseError(Exception): ... class RecordDictWrapper(dict): - record: Any = ... - def __init__(self, record: Any) -> None: ... - def __getitem__(self, key: Any): ... + record: Any + def __init__(self, record) -> None: ... + def __getitem__(self, key): ... -def _get_idref(self, env: Any, model_str: Any, idref: Any): ... -def _fix_multiple_roots(node: Any) -> None: ... -def _eval_xml(self, node: Any, env: Any): ... -def str2bool(value: Any): ... -def nodeattr2bool(node: Any, attr: Any, default: bool = ...): ... +def _get_idref(self, env: Environment, model_str: str, idref: dict) -> dict: ... +def _fix_multiple_roots(node: _Element) -> None: ... +def _eval_xml(self, node: _Element, env: Environment): ... +def str2bool(value) -> bool: ... +def nodeattr2bool(node: _Element, attr, default: bool = ...) -> bool: ... class xml_import: - def get_env(self, node: Any, eval_context: Optional[Any] = ...): ... - def make_xml_id(self, xml_id: Any): ... - def _test_xml_id(self, xml_id: Any) -> None: ... - def _tag_delete(self, rec: Any) -> None: ... - def _tag_report(self, rec: Any): ... - def _tag_function(self, rec: Any) -> None: ... - def _tag_act_window(self, rec: Any) -> None: ... - def _tag_menuitem(self, rec: Any, parent: Optional[Any] = ...) -> None: ... - def _tag_record(self, rec: Any): ... - def _tag_template(self, el: Any): ... - def id_get(self, id_str: Any, raise_if_not_found: bool = ...): ... - def model_id_get(self, id_str: Any, raise_if_not_found: bool = ...): ... - def _tag_root(self, el: Any) -> None: ... + def get_env(self, node: _Element, eval_context: dict | None = ...) -> Environment: ... + def make_xml_id(self, xml_id: str) -> str: ... + def _test_xml_id(self, xml_id: str) -> None: ... + def _tag_delete(self, rec: _Element) -> None: ... + def _tag_report(self, rec: _Element): ... + def _tag_function(self, rec: _Element) -> None: ... + def _tag_act_window(self, rec: _Element) -> None: ... + def _tag_menuitem(self, rec: _Element, parent: Any | None = ...) -> None: ... + def _tag_record(self, rec: _Element) -> tuple[str, int] | None: ... + def _tag_template(self, el: _Element) -> tuple[str, int] | None: ... + def id_get(self, id_str: str, raise_if_not_found: bool = ...) -> int | None: ... + def model_id_get(self, id_str: str, raise_if_not_found: bool = ...) -> tuple[Any, Any]: ... + def _tag_root(self, el: _Element) -> None: ... @property - def env(self): ... + def env(self) -> Environment: ... @property - def noupdate(self): ... - mode: Any = ... - module: Any = ... - envs: Any = ... - idref: Any = ... - _noupdate: Any = ... - xml_filename: Any = ... - _tags: Any = ... - def __init__(self, cr: Any, module: Any, idref: Any, mode: Any, noupdate: bool = ..., xml_filename: Optional[Any] = ...) -> None: ... - def parse(self, de: Any) -> None: ... - DATA_ROOTS: Any = ... + def noupdate(self) -> bool: ... + mode: str + module: str + envs: list[Environment] + idref: dict + _noupdate: list[bool] + xml_filename: str + _tags: dict[str, Callable] + def __init__(self, cr: Cursor, module: str, idref: dict, mode: str, noupdate: bool = ..., xml_filename: str | None = ...) -> None: ... + def parse(self, de: _Element) -> None: ... + DATA_ROOTS: list[str] -def convert_file(cr: Any, module: Any, filename: Any, idref: Any, mode: str = ..., noupdate: bool = ..., kind: Optional[Any] = ..., pathname: Optional[Any] = ...) -> None: ... -def convert_sql_import(cr: Any, fp: Any) -> None: ... -def convert_csv_import(cr: Any, module: Any, fname: Any, csvcontent: Any, idref: Optional[Any] = ..., mode: str = ..., noupdate: bool = ...) -> None: ... -def convert_xml_import(cr: Any, module: Any, xmlfile: Any, idref: Optional[Any] = ..., mode: str = ..., noupdate: bool = ..., report: Optional[Any] = ...) -> None: ... +def convert_file(cr: Cursor, module: str, filename: str, idref: dict, mode: str = ..., noupdate: bool = ..., kind: str | None = ..., pathname: str | None = ...) -> None: ... +def convert_sql_import(cr: Cursor, fp: TextIO) -> None: ... +def convert_csv_import(cr: Cursor, module: str, fname: str, csvcontent: bytes, idref: dict | None = ..., mode: str = ..., noupdate: bool = ...) -> None: ... +def convert_xml_import(cr: Cursor, module: str, xmlfile: str | BufferedReader, idref: dict | None = ..., mode: str = ..., noupdate: bool = ..., report: Any | None = ...) -> None: ... diff --git a/odoo-stubs/tools/date_utils.pyi b/odoo-stubs/tools/date_utils.pyi index 1e9876f..0d8a21d 100644 --- a/odoo-stubs/tools/date_utils.pyi +++ b/odoo-stubs/tools/date_utils.pyi @@ -1,19 +1,18 @@ import datetime +from typing import Tuple, Iterator, TypeVar + from dateutil.relativedelta import relativedelta -from typing import Any, Tuple, Iterator, TypeVar +_DateTimeT = TypeVar('_DateTimeT', datetime.date, datetime.datetime) -_T = TypeVar('_T', datetime.date, datetime.datetime) - - -def get_month(date: _T) -> Tuple[_T, _T]: ... -def get_quarter_number(date: Any) -> int: ... -def get_quarter(date: _T) -> Tuple[_T, _T]: ... -def get_fiscal_year(date: _T, day: int = ..., month: int = ...) -> Tuple[_T, _T]: ... -def get_timedelta(qty: Any, granularity: Any) -> relativedelta: ... -def start_of(value: _T, granularity: Any) -> _T: ... -def end_of(value: _T, granularity: Any) -> _T: ... -def add(value: _T, *args: Any, **kwargs: Any) -> _T: ... -def subtract(value: _T, *args: Any, **kwargs: Any) -> _T: ... -def json_default(obj: Any) -> str: ... +def get_month(date: _DateTimeT) -> Tuple[_DateTimeT, _DateTimeT]: ... +def get_quarter_number(date) -> int: ... +def get_quarter(date: _DateTimeT) -> Tuple[_DateTimeT, _DateTimeT]: ... +def get_fiscal_year(date: _DateTimeT, day: int = ..., month: int = ...) -> Tuple[_DateTimeT, _DateTimeT]: ... +def get_timedelta(qty, granularity) -> relativedelta: ... +def start_of(value: _DateTimeT, granularity) -> _DateTimeT: ... +def end_of(value: _DateTimeT, granularity) -> _DateTimeT: ... +def add(value: _DateTimeT, *args, **kwargs) -> _DateTimeT: ... +def subtract(value: _DateTimeT, *args, **kwargs) -> _DateTimeT: ... +def json_default(obj) -> str: ... def date_range(start: datetime.datetime, end: datetime.datetime, step: relativedelta = ...) -> Iterator[datetime.datetime]: ... diff --git a/odoo-stubs/tools/debugger.pyi b/odoo-stubs/tools/debugger.pyi index 2f36c55..8b3f542 100644 --- a/odoo-stubs/tools/debugger.pyi +++ b/odoo-stubs/tools/debugger.pyi @@ -1,6 +1,5 @@ -from typing import Any +from ..tools.config import configmanager -_logger: Any -SUPPORTED_DEBUGGER: Any +SUPPORTED_DEBUGGER: set[str] -def post_mortem(config: Any, info: Any) -> None: ... +def post_mortem(config: configmanager, info) -> None: ... diff --git a/odoo-stubs/tools/float_utils.pyi b/odoo-stubs/tools/float_utils.pyi index add5476..c4cb251 100644 --- a/odoo-stubs/tools/float_utils.pyi +++ b/odoo-stubs/tools/float_utils.pyi @@ -1,12 +1,9 @@ -from typing import Any, Optional - -def round(f: Any): ... -def _float_check_precision(precision_digits: Optional[Any] = ..., precision_rounding: Optional[Any] = ...): ... -def float_round(value: Any, precision_digits: Optional[Any] = ..., precision_rounding: Optional[Any] = ..., rounding_method: str = ...): ... -def float_is_zero(value: Any, precision_digits: Optional[Any] = ..., precision_rounding: Optional[Any] = ...): ... -def float_compare(value1: Any, value2: Any, precision_digits: Optional[Any] = ..., precision_rounding: Optional[Any] = ...): ... -def float_repr(value: Any, precision_digits: Any): ... +def round(f: float) -> float: ... +def _float_check_precision(precision_digits: int | None = ..., precision_rounding: float | None = ...) -> float: ... +def float_round(value: float, precision_digits: int | None = ..., precision_rounding: float | None = ..., rounding_method: str = ...) -> float: ... +def float_is_zero(value: float, precision_digits: int | None = ..., precision_rounding: float | None = ...) -> bool: ... +def float_compare(value1: float, value2: float, precision_digits: int | None = ..., precision_rounding: float | None = ...) -> int: ... +def float_repr(value: float, precision_digits: int) -> str: ... _float_repr = float_repr - -def float_split_str(value: Any, precision_digits: Any): ... -def float_split(value: Any, precision_digits: Any): ... +def float_split_str(value: float, precision_digits: int) -> tuple[str, str]: ... +def float_split(value: float, precision_digits: int) -> tuple[int, int]: ... diff --git a/odoo-stubs/tools/func.pyi b/odoo-stubs/tools/func.pyi index 254edce..a6c95a2 100644 --- a/odoo-stubs/tools/func.pyi +++ b/odoo-stubs/tools/func.pyi @@ -1,100 +1,100 @@ from json import JSONEncoder as JSONEncoder -from typing import Any +from typing import Callable, Generic, TypeVar -__all__: Any +_T = TypeVar('_T') -class lazy_property: - fget: Any = ... - def __init__(self, fget: Any) -> None: ... - def __get__(self, obj: Any, cls: Any): ... +class lazy_property(Generic[_T]): + fget: Callable[..., _T] + def __init__(self, fget: Callable[..., _T]) -> None: ... + def __get__(self, obj, cls) -> _T: ... @property def __doc__(self): ... @staticmethod - def reset_all(obj: Any) -> None: ... + def reset_all(obj) -> None: ... -class lazy_classproperty(lazy_property): - def __get__(self, obj: Any, cls: Any): ... +class lazy_classproperty(lazy_property[_T]): + def __get__(self, obj, cls) -> _T: ... -def conditional(condition: Any, decorator: Any): ... -def synchronized(lock_attr: str = ...): ... -def frame_codeinfo(fframe: Any, back: int = ...): ... -def compose(a: Any, b: Any): ... +def conditional(condition, decorator): ... +def synchronized(lock_attr: str = ...) -> Callable[[_T], _T]: ... +def frame_codeinfo(fframe, back: int = ...) -> tuple[str | None, str | None]: ... +def compose(a: Callable[..., _T], b: Callable) -> Callable[..., _T]: ... -class _ClassProperty(property): - def __get__(self, cls: Any, owner: Any): ... +class _ClassProperty(property, Generic[_T]): + def __get__(self, cls, owner) -> _T: ... -def classproperty(func: Any): ... +def classproperty(func: Callable[..., _T]) -> _ClassProperty[_T]: ... class lazy: - __slots__: Any = ... - def __init__(self, func: Any, *args: Any, **kwargs: Any) -> None: ... + __slots__ = ['_func', '_args', '_kwargs', '_cached_value'] + def __init__(self, func, *args, **kwargs) -> None: ... @property def _value(self): ... - def __getattr__(self, name: Any): ... - def __setattr__(self, name: Any, value: Any): ... - def __delattr__(self, name: Any): ... + def __getattr__(self, name): ... + def __setattr__(self, name, value): ... + def __delattr__(self, name): ... def __repr__(self): ... def __str__(self): ... def __bytes__(self): ... - def __format__(self, format_spec: Any): ... - def __lt__(self, other: Any) -> Any: ... - def __le__(self, other: Any) -> Any: ... - def __eq__(self, other: Any) -> Any: ... - def __ne__(self, other: Any) -> Any: ... - def __gt__(self, other: Any) -> Any: ... - def __ge__(self, other: Any) -> Any: ... - def __hash__(self) -> Any: ... + def __format__(self, format_spec): ... + def __lt__(self, other): ... + def __le__(self, other): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def __gt__(self, other): ... + def __ge__(self, other): ... + def __hash__(self): ... def __bool__(self): ... - def __call__(self, *args: Any, **kwargs: Any): ... + def __call__(self, *args, **kwargs): ... def __len__(self): ... - def __getitem__(self, key: Any): ... - def __missing__(self, key: Any): ... - def __setitem__(self, key: Any, value: Any) -> None: ... - def __delitem__(self, key: Any) -> None: ... - def __iter__(self) -> Any: ... + def __getitem__(self, key): ... + def __missing__(self, key): ... + def __setitem__(self, key, value) -> None: ... + def __delitem__(self, key) -> None: ... + def __iter__(self): ... def __reversed__(self): ... - def __contains__(self, key: Any): ... - def __add__(self, other: Any): ... - def __sub__(self, other: Any): ... - def __mul__(self, other: Any): ... - def __matmul__(self, other: Any): ... - def __truediv__(self, other: Any): ... - def __floordiv__(self, other: Any): ... - def __mod__(self, other: Any): ... - def __divmod__(self, other: Any): ... - def __pow__(self, other: Any): ... - def __lshift__(self, other: Any): ... - def __rshift__(self, other: Any): ... - def __and__(self, other: Any): ... - def __xor__(self, other: Any): ... - def __or__(self, other: Any): ... - def __radd__(self, other: Any): ... - def __rsub__(self, other: Any): ... - def __rmul__(self, other: Any): ... - def __rmatmul__(self, other: Any): ... - def __rtruediv__(self, other: Any): ... - def __rfloordiv__(self, other: Any): ... - def __rmod__(self, other: Any): ... - def __rdivmod__(self, other: Any): ... - def __rpow__(self, other: Any): ... - def __rlshift__(self, other: Any): ... - def __rrshift__(self, other: Any): ... - def __rand__(self, other: Any): ... - def __rxor__(self, other: Any): ... - def __ror__(self, other: Any): ... - def __iadd__(self, other: Any): ... - def __isub__(self, other: Any): ... - def __imul__(self, other: Any): ... - def __imatmul__(self, other: Any): ... - def __itruediv__(self, other: Any): ... - def __ifloordiv__(self, other: Any): ... - def __imod__(self, other: Any): ... - def __ipow__(self, other: Any): ... - def __ilshift__(self, other: Any): ... - def __irshift__(self, other: Any): ... - def __iand__(self, other: Any): ... - def __ixor__(self, other: Any): ... - def __ior__(self, other: Any): ... + def __contains__(self, key): ... + def __add__(self, other): ... + def __sub__(self, other): ... + def __mul__(self, other): ... + def __matmul__(self, other): ... + def __truediv__(self, other): ... + def __floordiv__(self, other): ... + def __mod__(self, other): ... + def __divmod__(self, other): ... + def __pow__(self, other): ... + def __lshift__(self, other): ... + def __rshift__(self, other): ... + def __and__(self, other): ... + def __xor__(self, other): ... + def __or__(self, other): ... + def __radd__(self, other): ... + def __rsub__(self, other): ... + def __rmul__(self, other): ... + def __rmatmul__(self, other): ... + def __rtruediv__(self, other): ... + def __rfloordiv__(self, other): ... + def __rmod__(self, other): ... + def __rdivmod__(self, other): ... + def __rpow__(self, other): ... + def __rlshift__(self, other): ... + def __rrshift__(self, other): ... + def __rand__(self, other): ... + def __rxor__(self, other): ... + def __ror__(self, other): ... + def __iadd__(self, other): ... + def __isub__(self, other): ... + def __imul__(self, other): ... + def __imatmul__(self, other): ... + def __itruediv__(self, other): ... + def __ifloordiv__(self, other): ... + def __imod__(self, other): ... + def __ipow__(self, other): ... + def __ilshift__(self, other): ... + def __irshift__(self, other): ... + def __iand__(self, other): ... + def __ixor__(self, other): ... + def __ior__(self, other): ... def __neg__(self): ... def __pos__(self): ... def __abs__(self): ... @@ -108,9 +108,9 @@ class lazy: def __floor__(self): ... def __ceil__(self): ... def __enter__(self): ... - def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ... + def __exit__(self, exc_type, exc_value, traceback): ... def __await__(self): ... def __aiter__(self): ... def __anext__(self): ... def __aenter__(self): ... - def __aexit__(self, exc_type: Any, exc_value: Any, traceback: Any): ... + def __aexit__(self, exc_type, exc_value, traceback): ... diff --git a/odoo-stubs/tools/image.pyi b/odoo-stubs/tools/image.pyi index 31b7786..0bcd324 100644 --- a/odoo-stubs/tools/image.pyi +++ b/odoo-stubs/tools/image.pyi @@ -1,31 +1,35 @@ -from PIL import IcoImagePlugin as IcoImagePlugin -from typing import Any, Optional +from PIL import IcoImagePlugin as IcoImagePlugin, ImageOps as ImageOps +from typing import Any, Iterable, Literal -FILETYPE_BASE64_MAGICWORD: Any +from PIL.Image import Image + +FILETYPE_BASE64_MAGICWORD: dict[bytes, str] EXIF_TAG_ORIENTATION: int -EXIF_TAG_ORIENTATION_TO_TRANSPOSE_METHODS: Any +EXIF_TAG_ORIENTATION_TO_TRANSPOSE_METHODS: dict[int, list] IMAGE_MAX_RESOLUTION: float class ImageProcess: - base64_source: Any = ... - operationsCount: int = ... - image: bool = ... - original_format: Any = ... - def __init__(self, base64_source: Any, verify_resolution: bool = ...) -> None: ... - def image_base64(self, quality: int = ..., output_format: str = ...): ... - def resize(self, max_width: int = ..., max_height: int = ...): ... - def crop_resize(self, max_width: Any, max_height: Any, center_x: float = ..., center_y: float = ...): ... - def colorize(self): ... + base64_source: bytes + operationsCount: int + image: Image | Literal[False] + original_format: str + def __init__(self, base64_source: bytes, verify_resolution: bool = ...) -> None: ... + def image_quality(self, quality: int = ..., output_format: str = ...) -> bytes | Literal[False]: ... + def image_base64(self, quality: int = ..., output_format: str = ...) -> bytes | Literal[False]: ... + def resize(self, max_width: int = ..., max_height: int = ...) -> ImageProcess: ... + def crop_resize(self, max_width: int, max_height: int, center_x: float = ..., center_y: float = ...) -> ImageProcess: ... + def colorize(self) -> ImageProcess: ... -def image_process(base64_source: Any, size: Any = ..., verify_resolution: bool = ..., quality: int = ..., crop: Optional[Any] = ..., colorize: bool = ..., output_format: str = ...): ... -def average_dominant_color(colors: Any, mitigate: int = ..., max_margin: int = ...): ... -def image_fix_orientation(image: Any): ... -def base64_to_image(base64_source: Any): ... -def image_to_base64(image: Any, format: Any, **params: Any): ... -def is_image_size_above(base64_source_1: Any, base64_source_2: Any): ... -def image_guess_size_from_field_name(field_name: Any): ... -def image_data_uri(base64_source: Any): ... -def get_saturation(rgb: Any): ... -def get_lightness(rgb: Any): ... -def hex_to_rgb(hx: Any): ... -def rgb_to_hex(rgb: Any): ... +def image_process(base64_source: bytes, size: tuple[int, int] = ..., verify_resolution: bool = ..., quality: int = ..., crop: str | None = ..., colorize: bool = ..., output_format: str = ...) -> bytes: ... +def average_dominant_color(colors: list[tuple[Any, Any]], mitigate: int = ..., max_margin: int = ...) -> tuple[Any, Any]: ... +def image_fix_orientation(image: Image) -> Image: ... +def base64_to_image(base64_source: bytes) -> Image: ... +def image_apply_opt(image: Image, format: str | None, **params) -> bytes: ... +def image_to_base64(image: Image, format: str | None, **params) -> bytes: ... +def is_image_size_above(base64_source_1: bytes, base64_source_2: bytes) -> bool: ... +def image_guess_size_from_field_name(field_name: str) -> tuple[int, int]: ... +def image_data_uri(base64_source: bytes) -> str: ... +def get_saturation(rgb: Iterable[int]) -> float: ... +def get_lightness(rgb: Iterable[int]) -> float: ... +def hex_to_rgb(hx: str) -> tuple[int, int, int]: ... +def rgb_to_hex(rgb: Iterable[int]) -> str: ... diff --git a/odoo-stubs/tools/json.pyi b/odoo-stubs/tools/json.pyi index b44e293..e614789 100644 --- a/odoo-stubs/tools/json.pyi +++ b/odoo-stubs/tools/json.pyi @@ -1,9 +1,7 @@ -from typing import Any - -JSON_SCRIPTSAFE_MAPPER: Any +JSON_SCRIPTSAFE_MAPPER: dict[str, str] class JSON: - def loads(self, *args: Any, **kwargs: Any): ... - def dumps(self, *args: Any, **kwargs: Any): ... + def loads(self, *args, **kwargs): ... + def dumps(self, *args, **kwargs) -> str: ... -scriptsafe: Any +scriptsafe: JSON diff --git a/odoo-stubs/tools/lru.pyi b/odoo-stubs/tools/lru.pyi index d90ad18..66ba2ff 100644 --- a/odoo-stubs/tools/lru.pyi +++ b/odoo-stubs/tools/lru.pyi @@ -1,17 +1,19 @@ -from typing import Any, Optional +from collections import OrderedDict +from threading import RLock +from typing import Any -__all__: Any +__all__ = ['LRU'] class LRU: - _lock: Any = ... - count: Any = ... - d: Any = ... - def __init__(self, count: Any, pairs: Any = ...) -> None: ... - def __contains__(self, obj: Any): ... - def get(self, obj: Any, val: Optional[Any] = ...): ... - def __getitem__(self, obj: Any): ... - def __setitem__(self, obj: Any, val: Any) -> None: ... - def __delitem__(self, obj: Any) -> None: ... - def __len__(self): ... - def pop(self, key: Any): ... + _lock: RLock + count: int + d: OrderedDict + def __init__(self, count: int, pairs: tuple[Any, Any] = ...) -> None: ... + def __contains__(self, obj) -> bool: ... + def get(self, obj, val: Any | None = ...): ... + def __getitem__(self, obj): ... + def __setitem__(self, obj, val) -> None: ... + def __delitem__(self, obj) -> None: ... + def __len__(self) -> int: ... + def pop(self, key): ... def clear(self) -> None: ... diff --git a/odoo-stubs/tools/mail.pyi b/odoo-stubs/tools/mail.pyi index e14136c..38e3f51 100644 --- a/odoo-stubs/tools/mail.pyi +++ b/odoo-stubs/tools/mail.pyi @@ -1,47 +1,59 @@ -from lxml.html import clean -from typing import Any, Optional +from email.message import Message +from re import Pattern +from typing import Any, FrozenSet, Literal -_logger: Any -tags_to_kill: Any -tags_to_remove: Any -allowed_tags: Any -safe_attrs: Any +from lxml.etree import _Element +from lxml.html import clean +from markupsafe import Markup + +tags_to_kill: list[str] +tags_to_remove: list[str] +allowed_tags: FrozenSet +safe_attrs: FrozenSet class _Cleaner(clean.Cleaner): - _style_re: Any = ... - _style_whitelist: Any = ... - strip_classes: bool = ... - sanitize_style: bool = ... - def __call__(self, doc: Any) -> None: ... - def tag_quote(self, el: Any): ... - def strip_class(self, el: Any) -> None: ... - def parse_style(self, el: Any) -> None: ... + _style_re: Pattern + _style_whitelist: list[str] + strip_classes: bool + sanitize_style: bool + def __call__(self, doc: _Element) -> None: ... + def tag_quote(self, el: _Element) -> None: ... + def strip_class(self, el: _Element) -> None: ... + def parse_style(self, el: _Element) -> None: ... -def html_sanitize(src: Any, silent: bool = ..., sanitize_tags: bool = ..., sanitize_attributes: bool = ..., sanitize_style: bool = ..., sanitize_form: bool = ..., strip_style: bool = ..., strip_classes: bool = ...): ... +def html_sanitize(src: str, silent: bool = ..., sanitize_tags: bool = ..., sanitize_attributes: bool = ..., sanitize_style: bool = ..., + sanitize_form: bool = ..., strip_style: bool = ..., strip_classes: bool = ...) -> Markup: ... URL_REGEX: str TEXT_URL_REGEX: str -HTML_TAG_URL_REGEX: Any +HTML_TAG_URL_REGEX: str -def validate_url(url: Any): ... -def is_html_empty(html_content: Any): ... -def html_keep_url(text: Any): ... -def html2plaintext(html: Any, body_id: Optional[Any] = ..., encoding: str = ...): ... -def plaintext2html(text: Any, container_tag: bool = ...): ... -def append_content_to_html(html: Any, content: Any, plaintext: bool = ..., preserve: bool = ..., container_tag: bool = ...): ... -def prepend_html_content(html_body: Any, html_content: Any): ... +def validate_url(url: str) -> str: ... +def is_html_empty(html_content: str) -> bool: ... +def html_keep_url(text: str) -> str: ... +def html2plaintext(html: str, body_id: str | None = ..., encoding: str = ...) -> str: ... +def plaintext2html(text: str, container_tag: str = ...) -> Markup: ... +def append_content_to_html(html: str, content: str, plaintext: bool = ..., preserve: bool = ..., container_tag: str = ...) -> Markup: ... +def prepend_html_content(html_body: str, html_content: str) -> str: ... -email_re: Any -single_email_re: Any -mail_header_msgid_re: Any -email_addr_escapes_re: Any +email_re: Pattern +single_email_re: Pattern +mail_header_msgid_re: Pattern +email_addr_escapes_re: Pattern -def generate_tracking_message_id(res_id: Any): ... -def email_send(email_from: Any, email_to: Any, subject: Any, body: Any, email_cc: Optional[Any] = ..., email_bcc: Optional[Any] = ..., reply_to: bool = ..., attachments: Optional[Any] = ..., message_id: Optional[Any] = ..., references: Optional[Any] = ..., openobject_id: bool = ..., debug: bool = ..., subtype: str = ..., headers: Optional[Any] = ..., smtp_server: Optional[Any] = ..., smtp_port: Optional[Any] = ..., ssl: bool = ..., smtp_user: Optional[Any] = ..., smtp_password: Optional[Any] = ..., cr: Optional[Any] = ..., uid: Optional[Any] = ...): ... -def email_split_tuples(text: Any): ... -def email_split(text: Any): ... -def email_split_and_format(text: Any): ... -def email_normalize(text: Any): ... -def email_escape_char(email_address: Any): ... -def decode_message_header(message: Any, header: Any, separator: str = ...): ... -def formataddr(pair: Any, charset: str = ...): ... +def generate_tracking_message_id(res_id: str) -> str: ... +def email_send(email_from: str, email_to: str, subject: str, body: str, email_cc: str | None = ..., email_bcc: str | None = ..., + reply_to: bool = ..., attachments: Any | None = ..., message_id: Any | None = ..., + references: Any | None = ..., openobject_id: bool = ..., debug: bool = ..., subtype: str = ..., + headers: Any | None = ..., smtp_server: Any | None = ..., smtp_port: Any | None = ..., + ssl: bool = ..., smtp_user: Any | None = ..., smtp_password: Any | None = ..., + cr: Any | None = ..., uid: Any | None = ...): ... +def email_split_tuples(text: str) -> list[str]: ... +def email_split(text: str) -> list[str]: ... +def email_split_and_format(text: str) -> list[str]: ... +def email_normalize(text: str) -> str | Literal[False]: ... +def email_escape_char(email_address: str) -> str: ... +def email_domain_extract(email: str) -> str | Literal[False]: ... +def decode_message_header(message: Message, header: str, separator: str = ...) -> str: ... +def formataddr(pair: tuple[str, str], charset: str = ...) -> str: ... +def encapsulate_email(old_email: str, new_email: str) -> str: ... diff --git a/odoo-stubs/tools/mimetypes.pyi b/odoo-stubs/tools/mimetypes.pyi index 65eb968..34cc5e6 100644 --- a/odoo-stubs/tools/mimetypes.pyi +++ b/odoo-stubs/tools/mimetypes.pyi @@ -1,28 +1,30 @@ -from collections import namedtuple -from typing import Any +import collections +from re import Pattern +from typing import Any, Literal -__all__: Any -_logger: Any -_ooxml_dirs: Any +__all__ = ['guess_mimetype'] +_ooxml_dirs: dict[str, str] -def _check_ooxml(data: Any): ... +def _check_ooxml(data: bytes) -> str | Literal[False]: ... -_mime_validator: Any +_mime_validator: Pattern -def _check_open_container_format(data: Any): ... +def _check_open_container_format(data: bytes) -> str | Literal[False]: ... -_xls_pattern: Any -_ppt_pattern: Any +_xls_pattern: Pattern +_ppt_pattern: Pattern -def _check_olecf(data: Any): ... -def _check_svg(data: Any): ... +def _check_olecf(data: bytes) -> str | Literal[False]: ... +def _check_svg(data: bytes) -> str | None: ... -_Entry = namedtuple('_Entry', ['mimetype', 'signatures', 'discriminants']) -_mime_mappings: Any +_Entry = collections.namedtuple('_Entry', ['mimetype', 'signatures', 'discriminants']) +_mime_mappings: tuple[_Entry, ...] -def guess_mimetype(bin_data: Any, default: str = ...): ... +def guess_mimetype(bin_data: str, default: str | None = ...) -> str: ... -guess_mimetype: Any +_guesser: Any ms: Any -def neuter_mimetype(mimetype: Any, user: Any): ... +def neuter_mimetype(mimetype: str, user: 'odoo.model.res_users') -> str: ... + +def get_extension(filename: str) -> str: ... diff --git a/odoo-stubs/tools/misc.pyi b/odoo-stubs/tools/misc.pyi index c3574f0..3d06fbc 100644 --- a/odoo-stubs/tools/misc.pyi +++ b/odoo-stubs/tools/misc.pyi @@ -1,208 +1,231 @@ -from .cache import * +import datetime import pickle as pickle_ +from collections import deque +from collections.abc import Mapping, MutableMapping, MutableSet +from logging import Filter, LogRecord +from types import ModuleType +from typing import Any, Collection, Generic, IO, AnyStr, ItemsView, Iterable, Iterator, NoReturn, TypeVar, Callable + import xlsxwriter import xlwt -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, Optional +from babel.core import Locale +from xlwt import Worksheet -_logger: Any -SKIPPED_ELEMENT_TYPES: Any +from .cache import * +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 ..sql_db import Cursor -def find_in_path(name: Any): ... -def _exec_pipe(prog: Any, args: Any, env: Optional[Any] = ...): ... -def exec_command_pipe(name: Any, *args: Any): ... -def find_pg_tool(name: Any): ... -def exec_pg_environ(): ... -def exec_pg_command(name: Any, *args: Any) -> None: ... -def exec_pg_command_pipe(name: Any, *args: Any): ... -def file_open(name: Any, mode: str = ..., subdir: str = ..., pathinfo: bool = ...): ... -def _fileopen(path: Any, mode: Any, basedir: Any, pathinfo: Any, basename: Optional[Any] = ...): ... -def flatten(list: Any): ... -def reverse_enumerate(l: Any): ... -def partition(pred: Any, elems: Any): ... -def topological_sort(elems: Any): ... -def merge_sequences(*iterables: Any): ... +_T = TypeVar('_T') +_T1 = TypeVar('_T1') +_KT = TypeVar('_KT') +_VT = TypeVar('_VT') +_CallableT = TypeVar('_CallableT', bound=Callable) + +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_open(name: str, mode: str = ..., subdir: str = ..., pathinfo: bool = ..., filter_ext: Any | None = ...): ... +def _fileopen(path: str, mode: str, basedir: str, pathinfo, basename: str | None = ..., filter_ext: Any | None = ...): ... +def flatten(list) -> list: ... +def reverse_enumerate(l): ... +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: Any, cell_overwrite_ok: bool = ...): ... + def add_sheet(self, name: str, cell_overwrite_ok: bool = ...) -> Worksheet: ... class PatchedXlsxWorkbook(xlsxwriter.Workbook): - def add_worksheet(self, name: Optional[Any] = ..., **kw: Any): ... + def add_worksheet(self, name: str | None = ..., **kw) -> Worksheet: ... -def to_xml(s: Any): ... -def get_iso_codes(lang: Any): ... -def scan_languages(): ... -def mod10r(number: Any): ... -def str2bool(s: Any, default: Optional[Any] = ...): ... -def human_size(sz: Any): ... -def logged(f: Any): ... +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: _CallableT) -> _CallableT: ... class profile: - fname: Any = ... - def __init__(self, fname: Optional[Any] = ...) -> None: ... - def __call__(self, f: Any): ... + fname: str | None + def __init__(self, fname: str | None = ...) -> None: ... + def __call__(self, f: _CallableT) -> _CallableT: ... -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: Any, locale: Any): ... -def split_every(n: Any, iterable: Any, piece_maker: Any = ...) -> None: ... -def get_and_group_by_field(cr: Any, uid: Any, obj: Any, ids: Any, field: Any, context: Optional[Any] = ...): ... -def get_and_group_by_company(cr: Any, uid: Any, obj: Any, ids: Any, context: Optional[Any] = ...): ... -def resolve_attr(obj: Any, attr: Any): ... -def attrgetter(*items: Any): ... -def remove_accents(input_str: Any): ... +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 remove_accents(input_str: str) -> str: ... class unquote(str): - def __repr__(self): ... + def __repr__(self) -> str: ... class UnquoteEvalContext(defaultdict): - def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def __missing__(self, key: Any): ... + def __init__(self, *args, **kwargs) -> None: ... + def __missing__(self, key) -> unquote: ... -class mute_logger: - loggers: Any = ... - def __init__(self, *loggers: Any) -> None: ... - def filter(self, record: Any): ... +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: Optional[Any] = ..., exc_val: Optional[Any] = ..., exc_tb: Optional[Any] = ...) -> None: ... - def __call__(self, func: Any): ... + def __exit__(self, exc_type: Any | None = ..., exc_val: Any | None = ..., exc_tb: Any | None = ...) -> None: ... + def __call__(self, func: _CallableT) -> _CallableT: ... _ph: Any -class CountingStream: - stream: Any = ... - index: Any = ... - stopped: bool = ... - def __init__(self, stream: Any, start: int = ...) -> None: ... - def __iter__(self) -> Any: ... - def next(self): ... - __next__: Any = ... +class CountingStream(Generic[_T]): + stream: Iterator[_T] + index: int + stopped: bool + 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: Any): ... +def stripped_sys_argv(*strip_args: str) -> list[str]: ... -class ConstantMapping(Mapping): - __slots__: Any = ... - _value: Any = ... - def __init__(self, val: Any) -> None: ... - def __len__(self): ... - def __iter__(self) -> Any: ... - def __getitem__(self, item: Any): ... +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: Optional[Any] = ..., frame: Optional[Any] = ..., thread_idents: Optional[Any] = ...) -> None: ... -def freehash(arg: Any): ... -def clean_context(context: Any): ... +def dumpstacks(sig: Any | None = ..., frame: Any | None = ..., thread_idents: Any | None = ...) -> None: ... +def freehash(arg) -> int: ... +def clean_context(context: dict[str, Any]) -> dict[str, Any]: ... class frozendict(dict): - def __delitem__(self, key: Any) -> None: ... - def __setitem__(self, key: Any, val: Any) -> None: ... - def clear(self) -> None: ... - def pop(self, key: Any, default: Optional[Any] = ...) -> None: ... - def popitem(self) -> None: ... - def setdefault(self, key: Any, default: Optional[Any] = ...) -> None: ... - def update(self, *args: Any, **kwargs: Any) -> None: ... - def __hash__(self) -> Any: ... + 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(Mapping): - __slots__: Any = ... - _map: Any = ... +class Collector(Mapping[_KT, _VT]): + __slots__ = ['map'] + _map: dict def __init__(self) -> None: ... - def add(self, key: Any, val: Any) -> None: ... - def __getitem__(self, key: Any): ... - def __iter__(self) -> Any: ... - def __len__(self): ... + def add(self, key: _KT, val: _T) -> None: ... + def __getitem__(self, key: _KT) -> tuple[_T]: ... + def __iter__(self) -> Iterator[_KT]: ... + def __len__(self) -> int: ... + def discard_keys_and_values(self, excludes: Collection): ... class StackMap(MutableMapping): - __slots__: Any = ... - _maps: Any = ... - def __init__(self, m: Optional[Any] = ...) -> None: ... - def __getitem__(self, key: Any): ... - def __setitem__(self, key: Any, val: Any) -> None: ... - def __delitem__(self, key: Any) -> None: ... - def __iter__(self) -> Any: ... - def __len__(self): ... - def __str__(self): ... - def pushmap(self, m: Optional[Any] = ...) -> None: ... - def popmap(self): ... + __slots__ = ['_maps'] + _maps: list[MutableMapping] + def __init__(self, m: MutableMapping | None = ...) -> None: ... + def __getitem__(self, key): ... + def __setitem__(self, key, val) -> None: ... + def __delitem__(self, key) -> None: ... + def __iter__(self) -> Iterator: ... + def __len__(self) -> int: ... + def __str__(self) -> str: ... + def pushmap(self, m: MutableMapping | None = ...) -> None: ... + def popmap(self) -> MutableMapping: ... class OrderedSet(MutableSet): - __slots__: Any = ... - _map: Any = ... - def __init__(self, elems: Any = ...) -> None: ... - def __contains__(self, elem: Any): ... - def __iter__(self) -> Any: ... - def __len__(self): ... - def add(self, elem: Any) -> None: ... - def discard(self, elem: Any) -> None: ... + __slots__ = ['_map'] + _map: dict + def __init__(self, elems: Iterable = ...) -> None: ... + def __contains__(self, elem) -> bool: ... + def __iter__(self) -> Iterator: ... + def __len__(self) -> int: ... + def add(self, elem) -> None: ... + def discard(self, elem) -> None: ... class LastOrderedSet(OrderedSet): - def add(self, elem: Any) -> None: ... + def add(self, elem) -> None: ... class Callbacks: - __slots__: Any = ... - _funcs: Any = ... - data: Any = ... + __slots__ = ['_funcs', 'data'] + _funcs: deque + data: dict def __init__(self) -> None: ... - def add(self, func: Any) -> None: ... + def add(self, func: Callable) -> None: ... def run(self) -> None: ... def clear(self) -> None: ... -class IterableGenerator: - __slots__: Any = ... - func: Any = ... - args: Any = ... - def __init__(self, func: Any, *args: Any) -> None: ... - def __iter__(self) -> Any: ... +class IterableGenerator(Generic[_T]): + __slots__ = ['func', 'args'] + func: Callable + args: tuple + def __init__(self, func: Callable[..., _T], *args) -> None: ... + def __iter__(self) -> _T: ... -def groupby(iterable: Any, key: Optional[Any] = ...): ... -def unique(it: Any) -> None: ... +def groupby(iterable: Iterable[_T], key: Callable[..., _T1] | None = ...) -> ItemsView[_T1, _T]: ... +def unique(it: Iterable[_T]) -> Iterator[_T]: ... class Reverse: - __slots__: Any = ... - val: Any = ... - def __init__(self, val: Any) -> None: ... - def __eq__(self, other: Any) -> Any: ... - def __ne__(self, other: Any) -> Any: ... - def __ge__(self, other: Any) -> Any: ... - def __gt__(self, other: Any) -> Any: ... - def __le__(self, other: Any) -> Any: ... - def __lt__(self, other: Any) -> Any: ... + __slots__ = ['val'] + val: Any + def __init__(self, val) -> None: ... + def __eq__(self, other) -> bool: ... + def __ne__(self, other) -> bool: ... + def __ge__(self, other) -> bool: ... + def __gt__(self, other) -> bool: ... + def __le__(self, other) -> bool: ... + def __lt__(self, other) -> bool: ... -def ignore(*exc: Any) -> None: ... -def html_escape(text: Any): ... -def get_lang(env: Any, lang_code: str = ...): ... -def formatLang(env: Any, value: Any, digits: Optional[Any] = ..., grouping: bool = ..., monetary: bool = ..., dp: bool = ..., currency_obj: bool = ...): ... -def format_date(env: Any, value: Any, lang_code: str = ..., date_format: bool = ...): ... -def parse_date(env: Any, value: Any, lang_code: str = ...): ... -def format_datetime(env: Any, value: Any, tz: str = ..., dt_format: str = ..., lang_code: str = ...): ... -def format_time(env: Any, value: Any, tz: str = ..., time_format: str = ..., lang_code: str = ...): ... -def _format_time_ago(env: Any, time_delta: Any, lang_code: str = ..., add_direction: bool = ...): ... -def format_decimalized_number(number: Any, decimal: int = ...): ... -def format_decimalized_amount(amount: Any, currency: Optional[Any] = ...): ... -def format_amount(env: Any, amount: Any, currency: Any, lang_code: str = ...): ... -def format_duration(value: Any): ... -def _consteq(str1: Any, str2: Any): ... +def ignore(*exc) -> None: ... +def html_escape(text: str) -> str: ... +def get_lang(env: Environment, lang_code: str = ...) -> 'odoo.model.res_lang': ... +def babel_locale_parse(lang_code: str) -> Locale: ... +def formatLang(env: Environment, value, digits: int | None = ..., grouping: bool = ..., monetary: bool = ..., + dp: bool = ..., currency_obj: 'odoo.model.res_currency' = ...) -> str: ... +def format_date(env: Environment, value: datetime.date | datetime.datetime | str, lang_code: str = ..., + date_format: str = ...) -> str: ... +def parse_date(env: Environment, value: str, lang_code: str = ...) -> datetime.date: ... +def format_datetime(env: Environment, value: str | datetime.datetime, tz: str = ..., + dt_format: str = ..., lang_code: str = ...) -> str: ... +def format_time(env: Environment, value, tz: str = ..., time_format: str = ..., lang_code: str = ...) -> str: ... +def _format_time_ago(env: Environment, time_delta: datetime.timedelta | int, lang_code: str = ..., + add_direction: bool = ...) -> str: ... +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): - find_global: Any = ... - find_class: Any = ... + find_global: Any + find_class: Any -def _pickle_load(stream: Any, encoding: str = ..., errors: bool = ...): ... +def _pickle_load(stream: pickle_._ReadableFileobj, encoding: str = ..., errors: bool = ...): ... -pickle: Any +pickle: ModuleType class DotDict(dict): - def __getattr__(self, attrib: Any): ... + def __getattr__(self, attrib): ... -def get_diff(data_from: Any, data_to: Any, custom_style: bool = ...): ... -def traverse_containers(val: Any, type_: Any) -> None: ... -def hmac(env: Any, scope: Any, message: Any, hash_function: Any = ...): ... +def get_diff(data_from: tuple[str, str], data_to: tuple[str, str], custom_style: bool = ...) -> str: ... +def traverse_containers(val, type_) -> Iterator: ... +def hmac(env: Environment, scope, message, hash_function = ...) -> str: ... diff --git a/odoo-stubs/tools/osutil.pyi b/odoo-stubs/tools/osutil.pyi index 281556c..add8e05 100644 --- a/odoo-stubs/tools/osutil.pyi +++ b/odoo-stubs/tools/osutil.pyi @@ -1,16 +1,14 @@ import ctypes -from typing import Any, Optional +from typing import Any, BinaryIO, Callable, Generator, Iterable, Iterator -_logger: Any +def listdir(dir: str, recursive: bool = ...) -> Iterable[str]: ... +def walksymlinks(top: str, topdown: bool = ..., onerror: Callable[[OSError], Any] | None = ...) -> Iterator[tuple[str, list[str], list[str]]]: ... +def tempdir() -> Generator[str, None, None]: ... +def zip_dir(path: str, stream: str | BinaryIO, include_dir: bool = ..., fnct_sort: Callable | None = ...) -> None: ... -def listdir(dir: Any, recursive: bool = ...): ... -def walksymlinks(top: Any, topdown: bool = ..., onerror: Optional[Any] = ...): ... -def tempdir() -> None: ... -def zip_dir(path: Any, stream: Any, include_dir: bool = ..., fnct_sort: Optional[Any] = ...) -> None: ... - -getppid: Any -is_running_as_nt_service: Any +getppid: Callable[[], int] +is_running_as_nt_service: Callable[[], bool] _TH32CS_SNAPPROCESS: int class _PROCESSENTRY32(ctypes.Structure): - _fields_: Any = ... + _fields_: list[tuple[str, Any]] diff --git a/odoo-stubs/tools/parse_version.pyi b/odoo-stubs/tools/parse_version.pyi index 51ebb8a..245f00f 100644 --- a/odoo-stubs/tools/parse_version.pyi +++ b/odoo-stubs/tools/parse_version.pyi @@ -1,7 +1,8 @@ -from typing import Any +from re import Pattern +from typing import Callable, Iterator -component_re: Any -replace: Any +component_re: Pattern +replace: Callable -def _parse_version_parts(s: Any) -> None: ... -def parse_version(s: Any): ... +def _parse_version_parts(s: str) -> Iterator[str]: ... +def parse_version(s: str) -> tuple[str]: ... diff --git a/odoo-stubs/tools/pdf.pyi b/odoo-stubs/tools/pdf.pyi index 7ab3e2a..a1fa429 100644 --- a/odoo-stubs/tools/pdf.pyi +++ b/odoo-stubs/tools/pdf.pyi @@ -1,24 +1,36 @@ +from io import BytesIO +from re import Pattern +from typing import Any, BinaryIO, Iterable + from PyPDF2 import PdfFileReader, PdfFileWriter -from PyPDF2.generic import ArrayObject as ArrayObject +from PyPDF2.generic import ArrayObject as ArrayObject, IndirectObject from PyPDF2.utils import b_ as b_ -from typing import Any, Optional DEFAULT_PDF_DATETIME_FORMAT: str +REGEX_SUBTYPE_UNFORMATED: Pattern +REGEX_SUBTYPE_FORMATED: Pattern -def _unwrapping_get(self, key: Any, default: Optional[Any] = ...): ... +def _unwrapping_get(self, key, default: Any | None = ...): ... class BrandedFileWriter(PdfFileWriter): def __init__(self) -> None: ... PdfFileWriter = BrandedFileWriter -def merge_pdf(pdf_data: Any): ... -def rotate_pdf(pdf: Any): ... - -old_init: Any +def merge_pdf(pdf_data: Iterable[bytes]) -> bytes: ... +def rotate_pdf(pdf: bytes) -> bytes: ... class OdooPdfFileReader(PdfFileReader): - def getAttachments(self): ... + def getAttachments(self) -> Iterable[tuple[Any, Any]]: ... class OdooPdfFileWriter(PdfFileWriter): - def _create_attachment_object(self, attachment: Any): ... - def addAttachment(self, fname: Any, fdata: Any) -> None: ... + _reader: PdfFileReader | None + is_pdfa: bool + _header: bytes + _ID: Any + def __init__(self, *args, **kwargs): None + def addAttachment(self, fname: str, fdata, subtype: str | None = ...) -> None: ... + def embed_odoo_attachment(self, attachment: 'odoo.model.ir_attachment', subtype: str | None = ...) -> None: ... + def cloneReaderDocumentRoot(self, reader: PdfFileReader) -> None: ... + def convert_to_pdfa(self) -> None: ... + def add_file_metadata(self, metadata_content: bytes) -> None: ... + def _create_attachment_object(self, attachment: dict[str, Any]) -> IndirectObject: ... diff --git a/odoo-stubs/tools/populate.pyi b/odoo-stubs/tools/populate.pyi index 4067b5b..5a0b428 100644 --- a/odoo-stubs/tools/populate.pyi +++ b/odoo-stubs/tools/populate.pyi @@ -1,14 +1,20 @@ -from datetime import datetime as datetime, timedelta as timedelta -from odoo.tools import pycompat as pycompat -from typing import Any, Optional +import random +from typing import Any, Callable, Iterable, Iterator, Sequence, TypeVar -def Random(seed: Any): ... -def format_str(val: Any, counter: Any, values: Any): ... -def chain_factories(field_factories: Any, model_name: Any): ... -def root_factory() -> None: ... -def randomize(vals: Any, weights: Optional[Any] = ..., seed: bool = ..., formatter: Any = ..., counter_offset: int = ...): ... -def cartesian(vals: Any, weights: Optional[Any] = ..., seed: bool = ..., formatter: Any = ..., then: Optional[Any] = ...): ... -def iterate(vals: Any, weights: Optional[Any] = ..., seed: bool = ..., formatter: Any = ..., then: Optional[Any] = ...): ... -def constant(val: Any, formatter: Any = ...): ... -def compute(function: Any, seed: Optional[Any] = ...): ... -def randint(a: Any, b: Any, seed: Optional[Any] = ...): ... +from ..tools import pycompat as pycompat + +_T = TypeVar('_T') + +def Random(seed) -> random.Random: ... +def format_str(val: _T, counter, values) -> _T: ... +def chain_factories(field_factories: Iterable[tuple[str, Callable[..., Iterator]]], model_name: str) -> Iterator: ... +def root_factory() -> Iterator[dict]: ... +def randomize(vals: Sequence, weights: Sequence | None = ..., seed: Any = ..., formatter: Callable[[Any, Any, Any], Any] = ..., + counter_offset: int = ...) -> Callable[[Iterable, str, str], dict]: ... +def cartesian(vals: Sequence, weights: Sequence | None = ..., seed: Any = ..., formatter: Callable[[Any, Any, Any], Any] = ..., + then: Callable[[Iterable, str, str], dict] | None = ...) -> Callable[[Iterable, str, str], Iterator[dict]]: ... +def iterate(vals: Sequence, weights: Sequence | None = ..., seed: Any = ..., formatter: Callable[[Any, Any, Any], Any] = ..., + then: Callable[[Iterable, str, str], dict] | None = ...) -> Callable[[Iterable, str, str], Iterator[dict]]: ... +def constant(val: Sequence, formatter: Callable[[Any, Any, Any], Any] = ...) -> Callable[[Iterable, str, str], Iterator[dict]]: ... +def compute(function: Callable[[Any, Any, Any], Any], seed: Any | None = ...) -> Callable[[Iterable, str, str], Iterator[dict]]: ... +def randint(a: int, b: int, seed: Any | None = ...) -> Callable[[Iterable, str, str], Iterator[dict]]: ... diff --git a/odoo-stubs/tools/profiler.pyi b/odoo-stubs/tools/profiler.pyi index cbb1dea..004b1ed 100644 --- a/odoo-stubs/tools/profiler.pyi +++ b/odoo-stubs/tools/profiler.pyi @@ -1,15 +1,13 @@ -from typing import Any, Optional - -_logger: Any +from typing import Any class _LogTracer: - profiles: Any = ... - whitelist: Any = ... - blacklist: Any = ... - files: Any = ... - deep: Any = ... - first_frame: Any = ... - def __init__(self, whitelist: Optional[Any] = ..., blacklist: Optional[Any] = ..., files: Optional[Any] = ..., deep: bool = ...) -> None: ... - def tracer(self, frame: Any, event: Any, arg: Any): ... + profiles: dict + whitelist: Any + blacklist: Any + files: Any + deep: Any + first_frame: Any + def __init__(self, whitelist: Any | None = ..., blacklist: Any | None = ..., files: Any | None = ..., deep: bool = ...) -> None: ... + def tracer(self, frame, event, arg): ... -def profile(method: Optional[Any] = ..., whitelist: Optional[Any] = ..., blacklist: Any = ..., files: Optional[Any] = ..., minimum_time: int = ..., minimum_queries: int = ...): ... +def profile(method: Any | None = ..., whitelist: Any | None = ..., blacklist=..., files: Any | None = ..., minimum_time: int = ..., minimum_queries: int = ...): ... diff --git a/odoo-stubs/tools/pycompat.pyi b/odoo-stubs/tools/pycompat.pyi index b985461..7379288 100644 --- a/odoo-stubs/tools/pycompat.pyi +++ b/odoo-stubs/tools/pycompat.pyi @@ -1,8 +1,26 @@ -from typing import Any +from codecs import StreamReader, StreamWriter +from csv import Dialect +from typing import BinaryIO, Iterable, Iterator, Protocol -_reader: Any -_writer: Any +class _StreamReader(Protocol): + def __call__(self, stream: BinaryIO, errors: str = ...) -> StreamReader: ... -def csv_reader(stream: Any, **params: Any): ... -def csv_writer(stream: Any, **params: Any): ... -def to_text(source: Any): ... +class _StreamWriter(Protocol): + def __call__(self, stream: BinaryIO, errors: str = ...) -> StreamWriter: ... + +class _CsvReader(Iterator[list[str]]): + dialect: Dialect + line_num: int + def __next__(self) -> list[str]: ... + +class _CsvWriter: + dialect: Dialect + def writerow(self, row: Iterable): ... + def writerows(self, rows: Iterable[Iterable]) -> None: ... + +_reader: _StreamReader +_writer: _StreamWriter + +def csv_reader(stream: BinaryIO, **params) -> _CsvReader: ... +def csv_writer(stream: BinaryIO, **params) -> _CsvWriter: ... +def to_text(source) -> str: ... diff --git a/odoo-stubs/tools/safe_eval.pyi b/odoo-stubs/tools/safe_eval.pyi index 5849f04..cef7cdd 100644 --- a/odoo-stubs/tools/safe_eval.pyi +++ b/odoo-stubs/tools/safe_eval.pyi @@ -1,40 +1,41 @@ from opcode import HAVE_ARGUMENT as HAVE_ARGUMENT -from typing import Any, Optional +from types import CodeType +from typing import Any, Iterable, Iterator, Literal unsafe_eval = eval -__all__: Any -_ALLOWED_MODULES: Any -_UNSAFE_ATTRIBUTES: Any +_ALLOWED_MODULES: list[str] +_UNSAFE_ATTRIBUTES: list[str] -def to_opcodes(opnames: Any, _opmap: Any = ...) -> None: ... +def to_opcodes(opnames: Iterable[str], _opmap: dict[str, int] =...) -> Iterator[int]: ... -_BLACKLIST: Any -_CONST_OPCODES: Any -_operations: Any -_EXPR_OPCODES: Any -_SAFE_OPCODES: Any -_logger: Any +_BLACKLIST: set[int] +_CONST_OPCODES: set[int] +_operations: list[str] +_EXPR_OPCODES: set[int] +_SAFE_OPCODES: set[int] -def assert_no_dunder_name(code_obj: Any, expr: Any) -> None: ... -def assert_valid_codeobj(allowed_codes: Any, code_obj: Any, expr: Any) -> None: ... -def test_expr(expr: Any, allowed_codes: Any, mode: str = ...): ... -def const_eval(expr: Any): ... -def expr_eval(expr: Any): ... -def _import(name: Any, globals: Optional[Any] = ..., locals: Optional[Any] = ..., fromlist: Optional[Any] = ..., level: int = ...): ... +def assert_no_dunder_name(code_obj: CodeType, expr: str) -> None: ... +def assert_valid_codeobj(allowed_codes: set[int], code_obj: CodeType, expr: str) -> None: ... +def test_expr(expr: str, allowed_codes: set[int], mode: str = ...): ... +def const_eval(expr: str): ... +def expr_eval(expr: str): ... +def _import(name: str, globals: dict | None = ..., locals: dict | None = ..., fromlist: list | None = ..., level: int = ...): ... -_BUILTINS: Any +_BUILTINS: dict[str, Any] -def safe_eval(expr: Any, globals_dict: Optional[Any] = ..., locals_dict: Optional[Any] = ..., mode: str = ..., nocopy: bool = ..., locals_builtins: bool = ...): ... -def test_python_expr(expr: Any, mode: str = ...): ... -def check_values(d: Any): ... +def safe_eval(expr: str, globals_dict: dict | None = ..., locals_dict: dict | None = ..., mode: str = ..., + nocopy: bool = ..., locals_builtins: bool = ...): ... +def test_python_expr(expr: str, mode: str = ...) -> str | Literal[False]: ... +def check_values(d: dict): ... class wrap_module: - _repr: Any = ... - def __init__(self, module: Any, attributes: Any) -> None: ... - def __repr__(self): ... + _repr: str + def __init__(self, module, attributes) -> None: ... + def __repr__(self) -> str: ... + def __getattr__(self, item): ... -mods: Any -datetime: Any -json: Any -time: Any -pytz: Any +mods: list[str] +datetime: wrap_module +json: wrap_module +time: wrap_module +pytz: wrap_module diff --git a/odoo-stubs/tools/sql.pyi b/odoo-stubs/tools/sql.pyi index 9cee563..9222f3b 100644 --- a/odoo-stubs/tools/sql.pyi +++ b/odoo-stubs/tools/sql.pyi @@ -1,30 +1,33 @@ -from typing import Any, Optional +from typing import Iterable, Literal -_schema: Any -_CONFDELTYPES: Any +from ..models import BaseModel +from ..sql_db import Cursor -def existing_tables(cr: Any, tablenames: Any): ... -def table_exists(cr: Any, tablename: Any): ... -def table_kind(cr: Any, tablename: Any): ... -def create_model_table(cr: Any, tablename: Any, comment: Optional[Any] = ..., columns: Any = ...) -> None: ... -def table_columns(cr: Any, tablename: Any): ... -def column_exists(cr: Any, tablename: Any, columnname: Any): ... -def create_column(cr: Any, tablename: Any, columnname: Any, columntype: Any, comment: Optional[Any] = ...) -> None: ... -def rename_column(cr: Any, tablename: Any, columnname1: Any, columnname2: Any) -> None: ... -def convert_column(cr: Any, tablename: Any, columnname: Any, columntype: Any) -> None: ... -def set_not_null(cr: Any, tablename: Any, columnname: Any) -> None: ... -def drop_not_null(cr: Any, tablename: Any, columnname: Any) -> None: ... -def constraint_definition(cr: Any, tablename: Any, constraintname: Any): ... -def add_constraint(cr: Any, tablename: Any, constraintname: Any, definition: Any) -> None: ... -def drop_constraint(cr: Any, tablename: Any, constraintname: Any) -> None: ... -def add_foreign_key(cr: Any, tablename1: Any, columnname1: Any, tablename2: Any, columnname2: Any, ondelete: Any): ... -def fix_foreign_key(cr: Any, tablename1: Any, columnname1: Any, tablename2: Any, columnname2: Any, ondelete: Any): ... -def index_exists(cr: Any, indexname: Any): ... -def create_index(cr: Any, indexname: Any, tablename: Any, expressions: Any) -> None: ... -def create_unique_index(cr: Any, indexname: Any, tablename: Any, expressions: Any) -> None: ... -def drop_index(cr: Any, indexname: Any, tablename: Any) -> None: ... -def drop_view_if_exists(cr: Any, viewname: Any) -> None: ... -def escape_psql(to_escape: Any): ... -def pg_varchar(size: int = ...): ... -def reverse_order(order: Any): ... -def increment_field_skiplock(record: Any, field: Any): ... +_CONFDELTYPES: dict[str, str] + +def existing_tables(cr: Cursor, tablenames: Iterable[str]) -> list[str]: ... +def table_exists(cr: Cursor, tablename: str) -> bool: ... +def table_kind(cr: Cursor, tablename: str) -> str | None: ... +def create_model_table(cr: Cursor, tablename: str, comment: str | None = ..., columns: Iterable = ...) -> None: ... +def table_columns(cr: Cursor, tablename: str) -> dict: ... +def column_exists(cr: Cursor, tablename: str, columnname: str) -> int: ... +def create_column(cr: Cursor, tablename: str, columnname: str, columntype: str, comment: str | None = ...) -> None: ... +def rename_column(cr: Cursor, tablename: str, columnname1: str, columnname2: str) -> None: ... +def convert_column(cr: Cursor, tablename: str, columnname: str, columntype: str) -> None: ... +def set_not_null(cr: Cursor, tablename: str, columnname: str) -> None: ... +def drop_not_null(cr: Cursor, tablename: str, columnname: str) -> None: ... +def constraint_definition(cr: Cursor, tablename: str, constraintname: str) -> str | None: ... +def add_constraint(cr: Cursor, tablename: str, constraintname: str, definition: str) -> None: ... +def drop_constraint(cr: Cursor, tablename: str, constraintname: str) -> None: ... +def add_foreign_key(cr: Cursor, tablename1: str, columnname1: str, tablename2: str, columnname2: str, ondelete) -> Literal[True]: ... +def get_foreign_keys(cr: Cursor, tablename1: str, columnname1: str, tablename2: str, columnname2: str, ondelete) -> list[str]: ... +def fix_foreign_key(cr: Cursor, tablename1: str, columnname1: str, tablename2: str, columnname2: str, ondelete) -> list[str]: ... +def index_exists(cr: Cursor, indexname: str) -> int: ... +def create_index(cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str]) -> None: ... +def create_unique_index(cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str]) -> None: ... +def drop_index(cr: Cursor, indexname: str, tablename: str) -> None: ... +def drop_view_if_exists(cr: Cursor, viewname: str) -> None: ... +def escape_psql(to_escape: str) -> str: ... +def pg_varchar(size: int = ...) -> str: ... +def reverse_order(order: str) -> str: ... +def increment_field_skiplock(record: BaseModel, field: str) -> bool: ... diff --git a/odoo-stubs/tools/template_inheritance.pyi b/odoo-stubs/tools/template_inheritance.pyi index 2e6c1c1..7cbc797 100644 --- a/odoo-stubs/tools/template_inheritance.pyi +++ b/odoo-stubs/tools/template_inheritance.pyi @@ -1,9 +1,10 @@ -from typing import Any +from typing import Any, Callable -_logger: Any +from lxml.etree import _Element -def add_text_before(node: Any, text: Any) -> None: ... -def add_text_inside(node: Any, text: Any) -> None: ... -def remove_element(node: Any) -> None: ... -def locate_node(arch: Any, spec: Any): ... -def apply_inheritance_specs(source: Any, specs_tree: Any, inherit_branding: bool = ..., pre_locate: Any = ...): ... +def add_text_before(node: _Element, text: str | None) -> None: ... +def add_text_inside(node: _Element, text: str | None) -> None: ... +def remove_element(node: _Element) -> None: ... +def locate_node(arch: _Element, spec: _Element) -> _Element: ... +def apply_inheritance_specs(source: _Element, specs_tree: _Element, inherit_branding: bool = ..., + pre_locate: Callable[[_Element], Any] = ...) -> _Element: ... diff --git a/odoo-stubs/tools/test_reports.pyi b/odoo-stubs/tools/test_reports.pyi index a98da49..f0970f6 100644 --- a/odoo-stubs/tools/test_reports.pyi +++ b/odoo-stubs/tools/test_reports.pyi @@ -1,8 +1,10 @@ +from typing import Any, Literal + from . import config as config -from typing import Any, Optional +from ..sql_db import Cursor -_logger: Any -_test_logger: Any - -def try_report(cr: Any, uid: Any, rname: Any, ids: Any, data: Optional[Any] = ..., context: Optional[Any] = ..., our_module: Optional[Any] = ..., report_type: Optional[Any] = ...): ... -def try_report_action(cr: Any, uid: Any, action_id: Any, active_model: Optional[Any] = ..., active_ids: Optional[Any] = ..., wiz_data: Optional[Any] = ..., wiz_buttons: Optional[Any] = ..., context: Optional[Any] = ..., our_module: Optional[Any] = ...): ... +def try_report(cr: Cursor, uid: int, rname: str, ids, data: Any | None = ..., context: dict | None = ..., + our_module: Any | None = ..., report_type: Any | None = ...) -> bool: ... +def try_report_action(cr: Cursor, uid: int, action_id: int, active_model: str | None = ..., active_ids: list[int] | None = ..., + wiz_data: dict | None = ..., wiz_buttons: list[str] | None = ..., context: dict | None = ..., + our_module: str | None = ...) -> Literal[True]: ... diff --git a/odoo-stubs/tools/translate.pyi b/odoo-stubs/tools/translate.pyi index 7c970fb..8f637b4 100644 --- a/odoo-stubs/tools/translate.pyi +++ b/odoo-stubs/tools/translate.pyi @@ -1,127 +1,142 @@ import csv from collections import namedtuple -from typing import Any, Optional +from re import Match, Pattern +from tarfile import TarFile +from types import FrameType +from typing import Any, BinaryIO, Callable, Container, IO, Iterable, Iterator, NoReturn + +from lxml.etree import HTMLParser, _Element +from polib import POFile + +from .pycompat import _CsvWriter +from ..api import Environment +from ..models import BaseModel +from ..sql_db import Connection, Cursor -_logger: Any WEB_TRANSLATION_COMMENT: str -SKIPPED_ELEMENTS: Any -_LOCALE2WIN32: Any -ENGLISH_SMALL_WORDS: Any +SKIPPED_ELEMENTS: tuple[str, ...] +_LOCALE2WIN32: dict[str, str] +ENGLISH_SMALL_WORDS: set[str] class UNIX_LINE_TERMINATOR(csv.excel): - lineterminator: str = ... + lineterminator: str -def encode(s: Any): ... +def encode(s: str) -> str: ... -TRANSLATED_ELEMENTS: Any -TRANSLATED_ATTRS: Any -avoid_pattern: Any -node_pattern: Any +TRANSLATED_ELEMENTS: set[str] +TRANSLATED_ATTRS: dict[str, Any] +avoid_pattern: Pattern +node_pattern: Pattern -def translate_xml_node(node: Any, callback: Any, parse: Any, serialize: Any): ... -def parse_xml(text: Any): ... -def serialize_xml(node: Any): ... +def translate_xml_node(node: _Element, callback: Callable[[str], str | None], parse: Callable[[str], _Element], + serialize: Callable[[_Element], str]) -> _Element: ... +def parse_xml(text: str) -> _Element: ... +def serialize_xml(node: _Element) -> str: ... -_HTML_PARSER: Any +_HTML_PARSER: HTMLParser -def parse_html(text: Any): ... -def serialize_html(node: Any): ... -def xml_translate(callback: Any, value: Any): ... -def html_translate(callback: Any, value: Any): ... -def translate(cr: Any, name: Any, source_type: Any, lang: Any, source: Optional[Any] = ...): ... -def translate_sql_constraint(cr: Any, key: Any, lang: Any): ... +def parse_html(text: str) -> _Element: ... +def serialize_html(node: _Element) -> str: ... +def xml_translate(callback: Callable[[str], str | None], value: str) -> str: ... +def html_translate(callback: Callable[[str], str | None], value: str) -> str: ... +def translate(cr: Cursor, name: str, source_type: str, lang: str, source: str | None = ...) -> str: ... +def translate_sql_constraint(cr: Cursor, key: str, lang: str) -> str: ... class GettextAlias: - def _get_db(self): ... - def _get_cr(self, frame: Any, allow_create: bool = ...): ... - def _get_uid(self, frame: Any): ... - def _get_lang(self, frame: Any): ... - def __call__(self, source: Any, *args: Any, **kwargs: Any): ... - def _get_translation(self, source: Any): ... + def _get_db(self) -> Connection | None: ... + def _get_cr(self, frame: FrameType, allow_create: bool = ...) -> tuple[Cursor, bool]: ... + def _get_uid(self, frame: FrameType) -> int: ... + def _get_lang(self, frame: FrameType) -> str: ... + def __call__(self, source: str, *args, **kwargs) -> str: ... + def _get_translation(self, source: str) -> str: ... class _lt: - __slots__: Any = ... - _source: Any = ... - _args: Any = ... - def __init__(self, source: Any, *args: Any, **kwargs: Any) -> None: ... - def __str__(self): ... - def __eq__(self, other: Any) -> Any: ... - def __lt__(self, other: Any) -> Any: ... - def __add__(self, other: Any): ... - def __radd__(self, other: Any): ... + __slots__ = ['_source', '_args'] + _source: str + _args: tuple + def __init__(self, source: str, *args, **kwargs) -> None: ... + def __str__(self) -> str: ... + def __eq__(self, other) -> NoReturn: ... + def __lt__(self, other) -> NoReturn: ... + def __add__(self, other: str | _lt) -> str: ... + def __radd__(self, other: str) -> str: ... -_: Any +_: GettextAlias -def quote(s: Any): ... +def quote(s: str) -> str: ... -re_escaped_char: Any -re_escaped_replacements: Any +re_escaped_char: Pattern +re_escaped_replacements: dict[str, str] -def _sub_replacement(match_obj: Any): ... -def unquote(str: Any): ... -def TranslationFileReader(source: Any, fileformat: str = ...): ... +def _sub_replacement(match_obj: Match) -> str: ... +def unquote(str: str) -> str: ... +def TranslationFileReader(source: IO, fileformat: str = ...) -> CSVFileReader | PoFileReader: ... class CSVFileReader: - source: Any = ... - prev_code_src: str = ... - def __init__(self, source: Any) -> None: ... - def __iter__(self) -> Any: ... + source: csv.DictReader + prev_code_src: str + def __init__(self, source: IO) -> None: ... + def __iter__(self) -> Iterator[csv.DictReader]: ... class PoFileReader: - pofile: Any = ... - def __init__(self, source: Any): ... - def __iter__(self) -> Any: ... + pofile: POFile + def __init__(self, source: str | IO): ... + def __iter__(self) -> Iterator[dict[str, Any]]: ... -def TranslationFileWriter(target: Any, fileformat: str = ..., lang: Optional[Any] = ...): ... +def TranslationFileWriter(target, fileformat: str = ..., lang: str | None = ...) -> CSVFileWriter | PoFileWriter | TarFileWriter: ... class CSVFileWriter: - writer: Any = ... - def __init__(self, target: Any) -> None: ... - def write_rows(self, rows: Any) -> None: ... + writer: _CsvWriter + def __init__(self, target: BinaryIO) -> None: ... + def write_rows(self, rows: Iterable) -> None: ... class PoFileWriter: - buffer: Any = ... - lang: Any = ... - po: Any = ... - def __init__(self, target: Any, lang: Any) -> None: ... - def write_rows(self, rows: Any) -> None: ... - def add_entry(self, modules: Any, tnrs: Any, source: Any, trad: Any, comments: Optional[Any] = ...) -> None: ... + buffer: IO + lang: str + po: POFile + def __init__(self, target: IO, lang: str) -> None: ... + def write_rows(self, rows: Iterable) -> None: ... + def add_entry(self, modules, tnrs, source, trad, comments: Iterable[str] | None = ...) -> None: ... class TarFileWriter: - tar: Any = ... - lang: Any = ... - def __init__(self, target: Any, lang: Any) -> None: ... - def write_rows(self, rows: Any) -> None: ... + tar: TarFile + lang: str + def __init__(self, target: IO, lang: str) -> None: ... + def write_rows(self, rows: Iterable) -> None: ... -def trans_export(lang: Any, modules: Any, buffer: Any, format: Any, cr: Any) -> None: ... -def trans_parse_rml(de: Any): ... -def _push(callback: Any, term: Any, source_line: Any) -> None: ... -def in_modules(object_name: Any, modules: Any): ... -def _extract_translatable_qweb_terms(element: Any, callback: Any) -> None: ... -def babel_extract_qweb(fileobj: Any, keywords: Any, comment_tags: Any, options: Any): ... +def trans_export(lang: str, modules: list[str], buffer, format: str, cr: Cursor) -> None: ... +def trans_parse_rml(de: Iterable) -> list[bytes]: ... +def _push(callback: Callable[[str, int], Any], term: str, source_line: int) -> None: ... +def in_modules(object_name: str, modules: Container[str]) -> bool: ... +def _extract_translatable_qweb_terms(element: _Element, callback: Callable[[str, int], Any]) -> None: ... +def babel_extract_qweb(fileobj: IO, keywords, comment_tags, options) -> list[tuple]: ... ImdInfo = namedtuple('ExternalId', ['name', 'model', 'res_id', 'module']) class TranslationModuleReader: - _cr: Any = ... - _modules: Any = ... - _lang: Any = ... - env: Any = ... - _to_translate: Any = ... - _path_list: Any = ... - _installed_modules: Any = ... - def __init__(self, cr: Any, modules: Optional[Any] = ..., lang: Optional[Any] = ...) -> None: ... - def __iter__(self) -> Any: ... - def _push_translation(self, module: Any, ttype: Any, name: Any, res_id: Any, source: Any, comments: Optional[Any] = ..., record_id: Optional[Any] = ...) -> None: ... - def _get_translatable_records(self, records: Any): ... + _cr: Cursor + _modules: list[str] + _lang: str | None + env: Environment + _to_translate: list[tuple] + _path_list: list[tuple[str, Any]] + _installed_modules: list[str] + def __init__(self, cr: Cursor, modules: list[str] | None = ..., lang: str | None = ...) -> None: ... + def __iter__(self) -> Iterable[tuple]: ... + def _push_translation(self, module: str, ttype: str, name: str, res_id: str, source: str, + comments: Iterable[str] | None = ..., record_id: int | None = ...) -> None: ... + def _get_translatable_records(self, imd_records: Iterable[ImdInfo]) -> BaseModel: ... def _export_translatable_records(self) -> None: ... - def _get_module_from_path(self, path: Any): ... - def _verified_module_filepaths(self, fname: Any, path: Any, root: Any): ... - def _babel_extract_terms(self, fname: Any, path: Any, root: Any, extract_method: str = ..., trans_type: str = ..., extra_comments: Optional[Any] = ..., extract_keywords: Any = ...) -> None: ... + def _get_module_from_path(self, path: str) -> str: ... + def _verified_module_filepaths(self, fname: str, path: str, root: str) -> tuple[str | None, str | None, str | None, str | None]: ... + def _babel_extract_terms(self, fname: str, path: str, root: str, extract_method: str = ..., trans_type: str = ..., + extra_comments: list[str] | None = ..., extract_keywords: dict = ...) -> None: ... def _export_translatable_resources(self) -> None: ... -def trans_load(cr: Any, filename: Any, lang: Any, verbose: bool = ..., create_empty_translation: bool = ..., overwrite: bool = ...): ... -def trans_load_data(cr: Any, fileobj: Any, fileformat: Any, lang: Any, verbose: bool = ..., create_empty_translation: bool = ..., overwrite: bool = ...) -> None: ... -def get_locales(lang: Optional[Any] = ...) -> None: ... -def resetlocale(): ... -def load_language(cr: Any, lang: Any) -> None: ... +def trans_load(cr: Cursor, filename: str, lang: str, verbose: bool = ..., create_empty_translation: bool = ..., + overwrite: bool = ...) -> None: ... +def trans_load_data(cr: Cursor, fileobj: IO, fileformat: str, lang: str, verbose: bool = ..., + create_empty_translation: bool = ..., overwrite: bool = ...) -> None: ... +def get_locales(lang: str | None = ...) -> None: ... +def resetlocale() -> str: ... +def load_language(cr: Cursor, lang: str) -> None: ... diff --git a/odoo-stubs/tools/view_validation.pyi b/odoo-stubs/tools/view_validation.pyi index 413cabb..f248c7f 100644 --- a/odoo-stubs/tools/view_validation.pyi +++ b/odoo-stubs/tools/view_validation.pyi @@ -1,16 +1,22 @@ -from typing import Any +from ast import expr as _expr +from collections import defaultdict +from re import Pattern +from typing import Callable, TypeVar -_logger: Any -_validators: Any -_relaxng_cache: Any -READONLY: Any +from lxml.etree import RelaxNG, _Element -def _get_attrs_symbols(): ... -def get_variable_names(expr: Any): ... -def get_dict_asts(expr: Any): ... -def _check(condition: Any, explanation: Any) -> None: ... -def get_domain_identifiers(expr: Any): ... -def valid_view(arch: Any, **kwargs: Any): ... -def validate(*view_types: Any): ... -def relaxng(view_type: Any): ... -def schema_valid(arch: Any, **kwargs: Any): ... +_CallableT = TypeVar('_CallableT', bound=Callable) + +_validators: defaultdict[str, list[Callable]] +_relaxng_cache: dict[str, RelaxNG | None] +READONLY: Pattern + +def _get_attrs_symbols() -> set[str]: ... +def get_variable_names(expr: str | _expr) -> set[str]: ... +def get_dict_asts(expr: str | _expr) -> dict: ... +def _check(condition: bool, explanation: str) -> None: ... +def get_domain_identifiers(expr: str | _expr) -> tuple[set[str], set[str]]: ... +def valid_view(arch: _Element, **kwargs) -> bool: ... +def validate(*view_types: str) -> Callable[[_CallableT], _CallableT]: ... +def relaxng(view_type: str) -> RelaxNG: ... +def schema_valid(arch: _Element, **kwargs) -> bool: ... diff --git a/odoo-stubs/tools/which.pyi b/odoo-stubs/tools/which.pyi index d81ee28..a873fe2 100644 --- a/odoo-stubs/tools/which.pyi +++ b/odoo-stubs/tools/which.pyi @@ -1,13 +1,12 @@ from os import R_OK as R_OK, W_OK as W_OK from os.path import dirname as dirname -from typing import Any, Optional +from typing import Iterator __docformat__: str -__all__: Any ENOENT: int -windows: Any -seen: Any -defpathext: Any +windows: bool +seen: set +defpathext: list[str] -def which_files(file: Any, mode: Any = ..., path: Optional[Any] = ..., pathext: Optional[Any] = ...) -> None: ... -def which(file: Any, mode: Any = ..., path: Optional[Any] = ..., pathext: Optional[Any] = ...): ... +def which_files(file: str, mode: int = ..., path: str | None = ..., pathext: str | None = ...) -> Iterator[str]: ... +def which(file: str, mode: int = ..., path: str | None = ..., pathext: str | None = ...) -> str: ... diff --git a/odoo-stubs/tools/win32.pyi b/odoo-stubs/tools/win32.pyi index 784aa6d..dc78c10 100644 --- a/odoo-stubs/tools/win32.pyi +++ b/odoo-stubs/tools/win32.pyi @@ -1,3 +1 @@ -from typing import Any - -def nl_langinfo(param: Any): ... +def nl_langinfo(param) -> str: ... diff --git a/odoo-stubs/tools/xml_utils.pyi b/odoo-stubs/tools/xml_utils.pyi index 08759a7..de765fb 100644 --- a/odoo-stubs/tools/xml_utils.pyi +++ b/odoo-stubs/tools/xml_utils.pyi @@ -1,11 +1,16 @@ from lxml import etree -from typing import Any, Optional +from lxml.etree import _Element +from typing import IO, Iterable + +from ..api import Environment class odoo_resolver(etree.Resolver): - env: Any = ... - def __init__(self, env: Any) -> None: ... - def resolve(self, url: Any, id: Any, context: Any): ... + env: Environment + def __init__(self, env: Environment) -> None: ... + def resolve(self, url: str, id: str, context) -> str: ... -def _check_with_xsd(tree_or_str: Any, stream: Any, env: Optional[Any] = ...) -> None: ... -def create_xml_node_chain(first_parent_node: Any, nodes_list: Any, last_node_value: Optional[Any] = ...): ... -def create_xml_node(parent_node: Any, node_name: Any, node_value: Optional[Any] = ...): ... +def _check_with_xsd(tree_or_str: str | _Element, stream: str | IO, env: Environment | None = ...) -> None: ... +def create_xml_node_chain(first_parent_node: _Element, nodes_list: Iterable[str], last_node_value: str | None = ...) -> list[_Element]: ... +def create_xml_node(parent_node: _Element, node_name: str, node_value: str | None = ...) -> _Element: ... +def cleanup_xml_node(xml_node_or_string: _Element | str, remove_blank_text: bool = ..., remove_blank_nodes: bool = ..., + indent_level: int = ..., indent_space: str = ...) -> _Element: ...