diff --git a/odoo-stubs/modules/__init__.pyi b/odoo-stubs/modules/__init__.pyi index 3e87be7..8fe50ad 100644 --- a/odoo-stubs/modules/__init__.pyi +++ b/odoo-stubs/modules/__init__.pyi @@ -1,3 +1,24 @@ -from . import db as db, graph as graph, loading as loading, migration as migration, module as module, registry as registry -from odoo.modules.loading import load_modules as load_modules, reset_modules_state as reset_modules_state -from odoo.modules.module import adapt_version as adapt_version, get_module_path as get_module_path, get_module_resource as get_module_resource, get_modules as get_modules, get_modules_with_version as get_modules_with_version, get_resource_from_path as get_resource_from_path, get_resource_path as get_resource_path, initialize_sys_path as initialize_sys_path, load_information_from_description_file as load_information_from_description_file, load_openerp_module as load_openerp_module +from . import ( + db as db, + graph as graph, + loading as loading, + migration as migration, + module as module, + registry as registry +) +from .loading import ( + load_modules as load_modules, + reset_modules_state as reset_modules_state +) +from .module import ( + adapt_version as adapt_version, + get_module_path as get_module_path, + get_module_resource as get_module_resource, + get_modules as get_modules, + get_modules_with_version as get_modules_with_version, + get_resource_from_path as get_resource_from_path, + get_resource_path as get_resource_path, + initialize_sys_path as initialize_sys_path, + load_information_from_description_file as load_information_from_description_file, + load_openerp_module as load_openerp_module +) diff --git a/odoo-stubs/modules/db.pyi b/odoo-stubs/modules/db.pyi index ef896c9..015e3a9 100644 --- a/odoo-stubs/modules/db.pyi +++ b/odoo-stubs/modules/db.pyi @@ -1,8 +1,6 @@ -from typing import Any +from ..sql_db import Cursor -_logger: Any - -def is_initialized(cr: Any): ... -def initialize(cr: Any) -> None: ... -def create_categories(cr: Any, categories: Any): ... -def has_unaccent(cr: Any): ... +def is_initialized(cr: Cursor) -> bool: ... +def initialize(cr: Cursor) -> None: ... +def create_categories(cr: Cursor, categories: list[str]) -> int | None: ... +def has_unaccent(cr: Cursor) -> bool: ... diff --git a/odoo-stubs/modules/graph.pyi b/odoo-stubs/modules/graph.pyi index 20a9621..fdc1933 100644 --- a/odoo-stubs/modules/graph.pyi +++ b/odoo-stubs/modules/graph.pyi @@ -1,30 +1,34 @@ -from typing import Any, Optional +from typing import Any, Iterable, Iterator -_logger: Any +from ..sql_db import Cursor -class Graph(dict): - def add_node(self, name: Any, info: Any): ... - def update_from_db(self, cr: Any) -> None: ... - def add_module(self, cr: Any, module: Any, force: Optional[Any] = ...) -> None: ... - def add_modules(self, cr: Any, module_list: Any, force: Optional[Any] = ...): ... - def __iter__(self) -> Any: ... - def __str__(self): ... +class Graph(dict[str, Node]): + def add_node(self, name: str, info: dict[str, Any]) -> Node: ... + def update_from_db(self, cr: Cursor) -> None: ... + def add_module(self, cr: Cursor, module: str, force: list | None = ...) -> None: ... + def add_modules(self, cr: Cursor, module_list: list[str], force: list | None = ...): ... + def __iter__(self) -> Iterator[Node]: ... + def __str__(self) -> str: ... class Node: - def __new__(cls, name: Any, graph: Any, info: Any): ... - name: Any = ... - graph: Any = ... - info: Any = ... - children: Any = ... - depth: int = ... - def __init__(self, name: Any, graph: Any, info: Any) -> None: ... + def __new__(cls, name: str, graph: Graph, info: dict[str, Any]) -> Node: ... + id: int + name: str + graph: Graph + info: dict[str, Any] + children: list[Node] + depth: int + dbdemo: bool + state: str + installed_version: str + def __init__(self, name: str, graph: Graph, info: dict[str, Any] | None) -> None: ... @property - def data(self): ... - def add_child(self, name: Any, info: Any): ... - def __setattr__(self, name: Any, value: Any) -> None: ... - def __iter__(self) -> Any: ... - def __str__(self): ... - def _pprint(self, depth: int = ...): ... - def should_have_demo(self): ... + def data(self) -> dict[str, Any]: ... + def add_child(self, name: str, info: dict[str, Any]): ... + def __setattr__(self, name: str, value) -> None: ... + def __iter__(self) -> Iterator[Node]: ... + def __str__(self) -> str: ... + def _pprint(self, depth: int = ...) -> str: ... + def should_have_demo(self) -> bool: ... @property - def parents(self): ... + def parents(self) -> Iterable[Node]: ... diff --git a/odoo-stubs/modules/loading.pyi b/odoo-stubs/modules/loading.pyi index 334f18e..9e0e2c4 100644 --- a/odoo-stubs/modules/loading.pyi +++ b/odoo-stubs/modules/loading.pyi @@ -1,13 +1,17 @@ -from typing import Any, Optional +from typing import Any, Iterable -_logger: Any -_test_logger: Any +from .graph import Graph, Node +from .registry import Registry +from ..sql_db import Cursor +from ..tests.runner import OdooTestResult -def load_data(cr: Any, idref: Any, mode: Any, kind: Any, package: Any): ... -def load_demo(cr: Any, package: Any, idref: Any, mode: Any): ... -def force_demo(cr: Any) -> None: ... -def load_module_graph(cr: Any, graph: Any, status: Optional[Any] = ..., perform_checks: bool = ..., skip_modules: Optional[Any] = ..., report: Optional[Any] = ..., models_to_check: Optional[Any] = ...): ... -def _check_module_names(cr: Any, module_names: Any) -> None: ... -def load_marked_modules(cr: Any, graph: Any, states: Any, force: Any, progressdict: Any, report: Any, loaded_modules: Any, perform_checks: Any, models_to_check: Optional[Any] = ...): ... -def load_modules(db: Any, force_demo: bool = ..., status: Optional[Any] = ..., update_module: bool = ...): ... -def reset_modules_state(db_name: Any) -> None: ... +def load_data(cr: Cursor, idref: dict, mode: str, kind: str, package: Node) -> bool: ... +def load_demo(cr: Cursor, package: Node, idref: dict, mode: str) -> bool: ... +def force_demo(cr: Cursor) -> None: ... +def load_module_graph(cr: Cursor, graph: Graph, status: Any | None = ..., perform_checks: Any = ..., skip_modules: list[str] | None = ..., + report: OdooTestResult | None = ..., models_to_check: set[str] | None = ...) -> tuple[list[str], list[str]]: ... +def _check_module_names(cr: Cursor, module_names: Iterable[str]) -> None: ... +def load_marked_modules(cr: Cursor, graph: Graph, states: list[str], force: list[str], progressdict, report: OdooTestResult, + loaded_modules: list[str], perform_checks: Any, models_to_check: set[str] | None = ...) -> list[str]: ... +def load_modules(db: Registry, force_demo: bool = ..., status: Any | None = ..., update_module: Any = ...) -> Registry | None: ... +def reset_modules_state(db_name: str) -> None: ... diff --git a/odoo-stubs/modules/migration.pyi b/odoo-stubs/modules/migration.pyi index ef8e705..22b1740 100644 --- a/odoo-stubs/modules/migration.pyi +++ b/odoo-stubs/modules/migration.pyi @@ -1,13 +1,14 @@ -from typing import Any +from types import ModuleType -_logger: Any +from .graph import Graph, Node +from ..sql_db import Cursor -def load_script(path: Any, module_name: Any): ... +def load_script(path: str, module_name: str) -> ModuleType: ... class MigrationManager: - cr: Any = ... - graph: Any = ... - migrations: Any = ... - def __init__(self, cr: Any, graph: Any) -> None: ... - def _get_files(self): ... - def migrate_module(self, pkg: Any, stage: Any): ... + cr: Cursor + graph: Graph + migrations: dict + def __init__(self, cr: Cursor, graph: Graph) -> None: ... + def _get_files(self) -> None: ... + def migrate_module(self, pkg: Node, stage: str) -> None: ... diff --git a/odoo-stubs/modules/module.pyi b/odoo-stubs/modules/module.pyi index 5226426..4bb0243 100644 --- a/odoo-stubs/modules/module.pyi +++ b/odoo-stubs/modules/module.pyi @@ -1,35 +1,39 @@ -from typing import Any, Optional +from types import ModuleType +from typing import Any, Literal, MutableSequence -MANIFEST_NAMES: Any -README: Any -_logger: Any +MANIFEST_NAMES: tuple[str, ...] +README: list[str] -def ad_paths(): ... +def ad_paths() -> MutableSequence[str]: ... -loaded: Any +loaded: list class AddonsHook: - def find_module(self, name: Any, path: Optional[Any] = ...): ... - def load_module(self, name: Any): ... + def find_module(self, name: str, path: Any | None = ...) -> AddonsHook | None: ... + def load_module(self, name: str) -> ModuleType | None: ... class OdooHook: - def find_module(self, name: Any, path: Optional[Any] = ...): ... - def load_module(self, name: Any): ... + def find_module(self, name: str, path: Any | None = ...) -> OdooHook | None: ... + def load_module(self, name: str) -> ModuleType | None: ... + +class UpgradeHook: + def find_module(self, name: str, path: Any | None = ...) -> UpgradeHook | None: ... + def load_module(self, name: str) -> ModuleType | None: ... def initialize_sys_path() -> None: ... -def get_module_path(module: Any, downloaded: bool = ..., display_warning: bool = ...): ... -def get_module_filetree(module: Any, dir: str = ...): ... -def get_resource_path(module: Any, *args: Any): ... +def get_module_path(module: str, downloaded: bool = ..., display_warning: bool = ...) -> str | Literal[False]: ... +def get_module_filetree(module: str, dir: str = ...) -> dict: ... +def get_resource_path(module: str, *args) -> str | Literal[False]: ... get_module_resource = get_resource_path -def get_resource_from_path(path: Any): ... -def get_module_icon(module: Any): ... -def module_manifest(path: Any): ... -def get_module_root(path: Any): ... -def load_information_from_description_file(module: Any, mod_path: Optional[Any] = ...): ... -def load_openerp_module(module_name: Any) -> None: ... -def get_modules(): ... -def get_modules_with_version(): ... -def adapt_version(version: Any): ... +def get_resource_from_path(path: str) -> tuple[str, str, str] | None: ... +def get_module_icon(module: str) -> str: ... +def module_manifest(path: str) -> str | None: ... +def get_module_root(path: str) -> str | None: ... +def load_information_from_description_file(module: str, mod_path: str | None = ...) -> dict: ... +def load_openerp_module(module_name: str) -> None: ... +def get_modules() -> list[str]: ... +def get_modules_with_version() -> dict[str, Any]: ... +def adapt_version(version: str) -> str: ... current_test: Any diff --git a/odoo-stubs/modules/registry.pyi b/odoo-stubs/modules/registry.pyi index 6e85ba7..dc2e7d3 100644 --- a/odoo-stubs/modules/registry.pyi +++ b/odoo-stubs/modules/registry.pyi @@ -1,79 +1,95 @@ +import threading +from collections import defaultdict, deque from collections.abc import Mapping -from typing import Any, Optional +from threading import RLock +from typing import Any, Callable, ClassVar, Iterable, Iterator +from weakref import WeakValueDictionary -from ..sql_db import Cursor +from .graph import Node +from ..models import BaseModel +from ..fields import Field +from ..sql_db import Connection, Cursor +from ..tests.runner import OdooTestResult +from ..tools.lru import LRU -_logger: Any -_schema: Any - -class Registry(Mapping): - _lock: Any = ... - _saved_lock: Any = ... - model_cache: Any = ... - def registries(cls): ... - def __new__(cls, db_name: Any): ... +class Registry(Mapping[str, type[BaseModel]]): + _lock: RLock + _saved_lock: RLock | None + model_cache: WeakValueDictionary + registries: ClassVar[LRU] + def __new__(cls, db_name: str) -> Registry: ... @classmethod - def new(cls, db_name: Any, force_demo: bool = ..., status: Optional[Any] = ..., update_module: bool = ...): ... - models: Any = ... - _sql_constraints: Any = ... - _init: bool = ... - _assertion_report: Any = ... - _fields_by_model: Any = ... - _ordinary_tables: Any = ... - _constraint_queue: Any = ... - __cache: Any = ... - _init_modules: Any = ... - updated_modules: Any = ... - loaded_xmlids: Any = ... - db_name: Any = ... - _db: Any = ... - test_cr: Any = ... - test_lock: Any = ... - loaded: bool = ... - ready: bool = ... - registry_sequence: Any = ... - cache_sequence: Any = ... - registry_invalidated: bool = ... - cache_invalidated: bool = ... - has_unaccent: Any = ... - def init(self, db_name: Any) -> None: ... + def new(cls, db_name: str, force_demo: bool = ..., status: Any | None = ..., update_module: bool = ...) -> Registry: ... + models: dict[str, type[BaseModel]] + _sql_constraints: set + _init: bool + _assertion_report: OdooTestResult + _fields_by_model: Any + _ordinary_tables: set[str] | None + _constraint_queue: deque + __cache: LRU + _init_modules: set[str] + updated_modules: list[str] + loaded_xmlids: set + db_name: str + _db: Connection + test_cr: Cursor | None + test_lock: RLock | None + loaded: bool + ready: bool + registry_sequence: int | None + cache_sequence: int | None + _invalidation_flags: threading.local + has_unaccent: bool + populated_models: dict[str, list[int]] + def init(self, db_name: str) -> None: ... @classmethod - def delete(cls, db_name: Any) -> None: ... + def delete(cls, db_name: str) -> None: ... @classmethod def delete_all(cls) -> None: ... - def __len__(self): ... - def __iter__(self) -> Any: ... - def __getitem__(self, model_name: Any): ... - def __call__(self, model_name: Any): ... - def __setitem__(self, model_name: Any, model: Any) -> None: ... - def __delitem__(self, model_name: Any) -> None: ... - def descendants(self, model_names: Any, *kinds: Any): ... - def load(self, cr: Any, module: Any): ... - _m2m: Any = ... - def setup_models(self, cr: Any) -> None: ... - def field_computed(self): ... - def field_triggers(self): ... - def post_init(self, func: Any, *args: Any, **kwargs: Any) -> None: ... - def post_constraint(self, func: Any, *args: Any, **kwargs: Any) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[str]: ... + def __getitem__(self, model_name: str) -> type[BaseModel]: ... + def __call__(self, model_name: str) -> type[BaseModel]: ... + def __setitem__(self, model_name: str, model: type[BaseModel]) -> None: ... + def __delitem__(self, model_name: str) -> None: ... + def descendants(self, model_names: Iterable[str], *kinds) -> set[str]: ... + def load(self, cr: Cursor, module: Node) -> set[str]: ... + _m2m: defaultdict[Any, list] + def setup_models(self, cr: Cursor) -> None: ... + @property + def field_computed(self) -> dict[Field, list[Field]]: ... + @property + def field_triggers(self) -> dict[Field, Any]: ... + def post_init(self, func: Callable, *args, **kwargs) -> None: ... + def post_constraint(self, func: Callable, *args, **kwargs) -> None: ... def finalize_constraints(self) -> None: ... - _post_init_queue: Any = ... - _foreign_keys: Any = ... - _is_install: Any = ... - def init_models(self, cr: Any, model_names: Any, context: Any, install: bool = ...) -> None: ... - def check_indexes(self, cr: Any, model_names: Any) -> None: ... - def add_foreign_key(self, table1: Any, column1: Any, table2: Any, column2: Any, ondelete: Any, model: Any, module: Any, force: bool = ...) -> None: ... - def check_foreign_keys(self, cr: Any) -> None: ... - def check_tables_exist(self, cr: Any) -> None: ... + _post_init_queue: deque + _foreign_keys: Any + _is_install: bool + def init_models(self, cr: Cursor, model_names: Iterable[str], context: dict, install: bool = ...) -> None: ... + def check_indexes(self, cr: Cursor, model_names: Iterable[str]) -> None: ... + def add_foreign_key(self, table1, column1, table2, column2, ondelete, model, module, force: bool = ...) -> None: ... + def check_foreign_keys(self, cr: Cursor) -> None: ... + def check_tables_exist(self, cr: Cursor) -> None: ... def _clear_cache(self) -> None: ... def clear_caches(self) -> None: ... - def is_an_ordinary_table(self, model: Any): ... + def is_an_ordinary_table(self, model: BaseModel) -> bool: ... + @property + def registry_invalidated(self) -> bool: ... + @registry_invalidated.setter + def registry_invalidated(self, value: bool) -> None: ... + @property + def cache_invalidated(self) -> bool: ... + @cache_invalidated.setter + def cache_invalidated(self, value: bool) -> None: ... def setup_signaling(self) -> None: ... - def check_signaling(self): ... + def check_signaling(self) -> Registry: ... def signal_changes(self) -> None: ... def reset_changes(self) -> None: ... def manage_changes(self) -> None: ... - def in_test_mode(self): ... - def enter_test_mode(self, cr: Any) -> None: ... + def in_test_mode(self) -> bool: ... + def enter_test_mode(self, cr: Cursor) -> None: ... def leave_test_mode(self) -> None: ... def cursor(self) -> Cursor: ... @@ -81,4 +97,4 @@ class DummyRLock: def acquire(self) -> None: ... def release(self) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... + def __exit__(self, type, value, traceback) -> None: ...