diff --git a/odoo-stubs/__init__.pyi b/odoo-stubs/__init__.pyi index b45557d..d0db2f0 100644 --- a/odoo-stubs/__init__.pyi +++ b/odoo-stubs/__init__.pyi @@ -1,23 +1,22 @@ from psycopg2 import connection -from . import ( - addons as addons, - api as api, - conf as conf, - fields as fields, - http as http, - loglevels as loglevels, - models as models, - netsvc as netsvc, - osv as osv, - release as release, - service as service, - sql_db as sql_db, - tools as tools -) +from . import addons as addons +from . import api as api +from . import conf as conf +from . import fields as fields +from . import http as http +from . import loglevels as loglevels +from . import models as models +from . import netsvc as netsvc +from . import osv as osv +from . import release as release +from . import service as service +from . import sql_db as sql_db +from . import tools as tools from .api import Registry from .fields import Command as Command -from .tools.translate import _ as _, _lt as _lt +from .tools.translate import _ as _ +from .tools.translate import _lt as _lt evented: bool diff --git a/odoo-stubs/api.pyi b/odoo-stubs/api.pyi index 480f888..ba3895f 100644 --- a/odoo-stubs/api.pyi +++ b/odoo-stubs/api.pyi @@ -1,16 +1,30 @@ from collections import defaultdict -from typing import Any, Callable, Collection, Generator, Iterable, Iterator, KeysView, Literal, Mapping, Optional, Sequence, TypeVar, Union +from typing import ( + Any, + Callable, + Collection, + Generator, + Iterable, + Iterator, + KeysView, + Literal, + Mapping, + Optional, + Sequence, + TypeVar, + Union, +) from weakref import WeakSet from .fields import Field from .models import BaseModel from .modules.registry import Registry from .sql_db import Cursor -from .tools import OrderedSet, frozendict, StackMap +from .tools import OrderedSet, StackMap, frozendict -_T = TypeVar('_T') -_ModelT = TypeVar('_ModelT', bound=BaseModel) -_CallableT = TypeVar('_CallableT', bound=Callable) +_T = TypeVar("_T") +_ModelT = TypeVar("_ModelT", bound=BaseModel) +_CallableT = TypeVar("_CallableT", bound=Callable) INHERITED_ATTRS: tuple[str, ...] @@ -25,23 +39,32 @@ class Meta(type): def attrsetter(attr, value) -> Callable[[_T], _T]: ... def propagate(method1: Callable, method2: _CallableT) -> _CallableT: ... -def constrains(*args: str | Callable[[_ModelT], Sequence[str]]) -> Callable[[_T], _T]: ... +def constrains( + *args: str | Callable[[_ModelT], Sequence[str]] +) -> Callable[[_T], _T]: ... def ondelete(*, at_uninstall: bool) -> Callable[[_T], _T]: ... def onchange(*args: str) -> Callable[[_T], _T]: ... def depends(*args: str | Callable[[_ModelT], Sequence[str]]) -> Callable[[_T], _T]: ... def depends_context(*args: str) -> Callable[[_T], _T]: ... -def returns(model: str | None, downgrade: Callable | None = ..., upgrade: Callable | None = ...) -> Callable[[_T], _T]: ... +def returns( + model: str | None, downgrade: Callable | None = ..., upgrade: Callable | None = ... +) -> Callable[[_T], _T]: ... def downgrade(method: Callable, value, self, args, kwargs): ... def split_context(method: Callable, args, kwargs) -> tuple: ... def autovacuum(method: _CallableT) -> _CallableT: ... def model(method: _CallableT) -> _CallableT: ... - -def _model_create_single(create: Callable[..., _ModelT], self: _ModelT, arg) -> _ModelT: ... +def _model_create_single( + create: Callable[..., _ModelT], self: _ModelT, arg +) -> _ModelT: ... def model_create_single(method: _CallableT) -> _CallableT: ... -def _model_create_multi(create: Callable[..., _ModelT], self: _ModelT, arg) -> _ModelT: ... +def _model_create_multi( + create: Callable[..., _ModelT], self: _ModelT, arg +) -> _ModelT: ... def model_create_multi(method: _CallableT) -> _CallableT: ... def _call_kw_model(method: Callable[..., _ModelT], self: _ModelT, args, kwargs): ... -def _call_kw_model_create(method: Callable[..., _ModelT], self: _ModelT, args, kwargs) -> list[int] | int | Literal[False]: ... +def _call_kw_model_create( + method: Callable[..., _ModelT], self: _ModelT, args, kwargs +) -> list[int] | int | Literal[False]: ... def _call_kw_multi(method: Callable[..., _ModelT], self: _ModelT, args, kwargs): ... def call_kw(model: BaseModel, name: str, args, kwargs): ... @@ -61,7 +84,9 @@ class Environment(Mapping[str, BaseModel]): cache: Cache _cache_key: dict[Field, Any] _protected: StackMap[Field, set[int]] - def __new__(cls, cr: Cursor, uid: int | None, context: dict, su: bool = ...) -> Environment: ... + def __new__( + cls, cr: Cursor, uid: int | None, context: dict, su: bool = ... + ) -> Environment: ... def __contains__(self, model_name: str) -> bool: ... def __getitem__(self, model_name: str) -> BaseModel: ... def __iter__(self) -> Iterator[str]: ... @@ -69,17 +94,25 @@ class Environment(Mapping[str, BaseModel]): def __eq__(self, other) -> bool: ... def __ne__(self, other) -> bool: ... def __hash__(self) -> int: ... - def __call__(self, cr: Cursor | None = ..., user: Union['odoo.model.res_users', int, None] = ..., context: dict | None = ..., su: bool | None = ...) -> Environment: ... - def ref(self, xml_id: str, raise_if_not_found: bool = ...) -> Optional[BaseModel]: ... + def __call__( + self, + cr: Cursor | None = ..., + user: Union["odoo.model.res_users", int, None] = ..., + context: dict | None = ..., + su: bool | None = ..., + ) -> Environment: ... + def ref( + self, xml_id: str, raise_if_not_found: bool = ... + ) -> Optional[BaseModel]: ... def is_superuser(self) -> bool: ... def is_admin(self) -> bool: ... def is_system(self) -> bool: ... @property - def user(self) -> 'odoo.model.res_users': ... + def user(self) -> "odoo.model.res_users": ... @property - def company(self) -> 'odoo.model.res_company': ... + def company(self) -> "odoo.model.res_company": ... @property - def companies(self) -> 'odoo.model.res_company': ... + def companies(self) -> "odoo.model.res_company": ... @property def lang(self) -> str: ... def clear(self) -> None: ... @@ -89,7 +122,9 @@ class Environment(Mapping[str, BaseModel]): def flush_all(self) -> None: ... def is_protected(self, field: Field, record: BaseModel) -> bool: ... def protected(self, field: Field) -> BaseModel: ... - def protecting(self, what, records: Optional[BaseModel] = ...) -> Generator[None, None, None]: ... + def protecting( + self, what, records: Optional[BaseModel] = ... + ) -> Generator[None, None, None]: ... def fields_to_compute(self) -> KeysView[Field]: ... def records_to_compute(self, field: Field) -> BaseModel: ... def is_to_compute(self, field: Field, record: BaseModel) -> bool: ... @@ -123,27 +158,54 @@ class Cache: def contains(self, record: BaseModel, field: Field) -> bool: ... def contains_field(self, field: Field) -> bool: ... def get(self, record: BaseModel, field: Field, default=...): ... - def set(self, record: BaseModel, field: Field, value, dirty: bool = ..., check_dirty: bool = ...) -> None: ... - def update(self, records: BaseModel, field: Field, values, dirty: bool = ..., check_dirty: bool = ...) -> None: ... - def update_raw(self, records: BaseModel, field: Field, values, dirty: bool = ..., check_dirty: bool = ...) -> None: ... + def set( + self, + record: BaseModel, + field: Field, + value, + dirty: bool = ..., + check_dirty: bool = ..., + ) -> None: ... + def update( + self, + records: BaseModel, + field: Field, + values, + dirty: bool = ..., + check_dirty: bool = ..., + ) -> None: ... + def update_raw( + self, + records: BaseModel, + field: Field, + values, + dirty: bool = ..., + check_dirty: bool = ..., + ) -> None: ... def insert_missing(self, records: BaseModel, field: Field, values) -> None: ... def remove(self, record: BaseModel, field: Field) -> None: ... def get_values(self, records: BaseModel, field: Field) -> Iterator: ... def get_until_miss(self, records: BaseModel, field: Field) -> list: ... - def get_records_different_from(self, records: _ModelT, field: Field, value) -> _ModelT: ... + def get_records_different_from( + self, records: _ModelT, field: Field, value + ) -> _ModelT: ... def get_fields(self, record: BaseModel) -> Iterator[Field]: ... def get_records(self, model: _ModelT, field: Field) -> _ModelT: ... def get_missing_ids(self, records: BaseModel, field: Field) -> Iterator[int]: ... - def get_dirty_fields(self) -> 'set[Field]': ... + def get_dirty_fields(self) -> "set[Field]": ... def get_dirty_records(self, model: _ModelT, field: Field) -> _ModelT: ... - def has_dirty_fields(self, records: BaseModel, fields: Iterable[Field] | None = ...) -> bool: ... + def has_dirty_fields( + self, records: BaseModel, fields: Iterable[Field] | None = ... + ) -> bool: ... def clear_dirty_field(self, field: Field) -> Collection[int]: ... - def invalidate(self, spec: list[tuple[Field, Iterable | None]] | None = ...) -> None: ... + def invalidate( + self, spec: list[tuple[Field, Iterable | None]] | None = ... + ) -> None: ... def clear(self) -> None: ... def check(self, env: Environment) -> None: ... class Starred: - __slots__ = ['value'] + __slots__ = ["value"] value: Any def __init__(self, value) -> None: ... def __repr__(self) -> str: ... diff --git a/odoo-stubs/exceptions.pyi b/odoo-stubs/exceptions.pyi index a7e9cb0..665af30 100644 --- a/odoo-stubs/exceptions.pyi +++ b/odoo-stubs/exceptions.pyi @@ -9,7 +9,13 @@ class UserError(Exception): def name(self): ... class RedirectWarning(Exception): - def __init__(self, message: str, action: int, button_text: str, additional_context: dict | None = ...) -> None: ... + def __init__( + self, + message: str, + action: int, + button_text: str, + additional_context: dict | None = ..., + ) -> None: ... @property def name(self): ... diff --git a/odoo-stubs/fields.pyi b/odoo-stubs/fields.pyi index 4eef83a..73a843b 100644 --- a/odoo-stubs/fields.pyi +++ b/odoo-stubs/fields.pyi @@ -1,6 +1,18 @@ import datetime import enum -from typing import Any, Callable, Container, Collection, Generic, Iterator, Sequence, Type, TypeVar, Union, overload +from typing import ( + Any, + Callable, + Collection, + Container, + Generic, + Iterator, + Sequence, + Type, + TypeVar, + Union, + overload, +) import psycopg2 from markupsafe import Markup @@ -9,15 +21,15 @@ from .api import Environment, Registry from .models import BaseModel from .tools import date_utils, float_utils -_FieldT = TypeVar('_FieldT', bound=Field) -_FieldValueT = TypeVar('_FieldValueT') -_ModelT = TypeVar('_ModelT', bound=BaseModel) +_FieldT = TypeVar("_FieldT", bound=Field) +_FieldValueT = TypeVar("_FieldValueT") +_ModelT = TypeVar("_ModelT", bound=BaseModel) _Selection = list[tuple[str, str]] _SelectionRaw = _Selection | Callable[..., _Selection] | str _Domain = list _DomainRaw = _Domain | Callable[..., _Domain] _CommandList = list[tuple[BaseModel, list]] -_SeqIntT = TypeVar('_SeqIntT', bound=Sequence[int]) +_SeqIntT = TypeVar("_SeqIntT", bound=Sequence[int]) DATE_LENGTH: int DATETIME_LENGTH: int @@ -116,7 +128,9 @@ class Field(Generic[_FieldValueT], metaclass=MetaField): def _inverse_company_dependent(self, records: BaseModel) -> None: ... def _search_company_dependent(self, records: BaseModel, operator: str, value): ... def resolve_depends(self, registry: Registry) -> Iterator[tuple]: ... - def get_description(self, env: Environment, attributes: Container[str] | None = ...) -> dict[str, Any]: ... + def get_description( + self, env: Environment, attributes: Container[str] | None = ... + ) -> dict[str, Any]: ... _description_name: str _description_type: str _description_store: bool | None @@ -140,7 +154,9 @@ class Field(Generic[_FieldValueT], metaclass=MetaField): def _description_help(self, env: Environment) -> str | None: ... def is_editable(self) -> bool: ... def null(self, record: BaseModel) -> bool: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_record_multi(self, values, records: BaseModel): ... @@ -173,16 +189,24 @@ class Field(Generic[_FieldValueT], metaclass=MetaField): class Boolean(Field[bool]): type: str column_type: tuple[str, str] - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> bool: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> bool: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> bool: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> bool: ... def convert_to_export(self, value, record: BaseModel): ... class Integer(Field[int]): type: str column_type: tuple[str, str] group_operator: str - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> int: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> int | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> int: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> int | None: ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... def _update(self, records: BaseModel, value) -> None: ... @@ -192,14 +216,20 @@ class Float(Field[float]): type: str _digits: tuple[int, int] | str | None group_operator: str - def __init__(self, string: str = ..., digits: tuple[int, int] | str | None =..., **kwargs) -> None: ... + def __init__( + self, string: str = ..., digits: tuple[int, int] | str | None = ..., **kwargs + ) -> None: ... @property def column_type(self): ... def get_digits(self, env: Environment) -> tuple[int, int]: ... _related__digits: Any def _description_digits(self, env: Environment) -> tuple[int, int]: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> float: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> float: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> float: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> float: ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_export(self, value, record: BaseModel): ... round = float_utils.float_round @@ -212,13 +242,19 @@ class Monetary(Field[float]): column_type: tuple[str, str] currency_field: str | None group_operator: str - def __init__(self, string: str = ..., currency_field : str =..., **kwargs) -> None: ... + def __init__( + self, string: str = ..., currency_field: str = ..., **kwargs + ) -> None: ... def _description_currency_field(self, env: Environment) -> str: ... def get_currency_field(self, model: BaseModel) -> str: ... def setup_nonrelated(self, model: BaseModel) -> None: ... def setup_related(self, model: BaseModel) -> None: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> float: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> float: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> float: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> float: ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... def convert_to_write(self, value, record: BaseModel): ... @@ -232,12 +268,16 @@ class _String(Field[str]): def _convert_db_column(self, model: BaseModel, column: dict) -> None: ... def get_trans_terms(self, value) -> list: ... def get_text_content(self, term): ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def _convert_from_cache_to_column(self, value): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_write(self, value, record: BaseModel): ... - def get_translation_dictionary(self, from_lang_value: str, to_lang_values: dict) -> dict: ... + def get_translation_dictionary( + self, from_lang_value: str, to_lang_values: dict + ) -> dict: ... def _get_stored_translations(self, record: BaseModel) -> dict[str, str]: ... def write(self, records: _ModelT, value) -> _ModelT: ... @@ -253,8 +293,12 @@ class Char(_String): _related_trim: bool _description_size: int | None _description_trim: bool - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> str | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> str | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> str | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> str | None: ... class Text(_String): type: str @@ -287,11 +331,17 @@ class Html(_String): _description_sanitize_style: bool _description_strip_style: bool _description_strip_classes: bool - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> Markup | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> Markup | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> Markup | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> Markup | None: ... def _convert(self, value, record: BaseModel, validate: bool) -> Markup | None: ... def convert_to_record(self, value, record: BaseModel) -> Markup | None: ... - def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...) -> Markup | None: ... + def convert_to_read( + self, value, record: BaseModel, use_name_get: bool = ... + ) -> Markup | None: ... def get_trans_terms(self, value) -> list: ... class Date(Field[datetime.date]): @@ -304,13 +354,17 @@ class Date(Field[datetime.date]): @staticmethod def today(*args) -> datetime.date: ... @staticmethod - def context_today(record: BaseModel, timestamp: datetime.datetime | None = ...) -> datetime.date: ... + def context_today( + record: BaseModel, timestamp: datetime.datetime | None = ... + ) -> datetime.date: ... @staticmethod def to_date(value) -> datetime.date | None: ... from_string = to_date @staticmethod def to_string(value: datetime.datetime | datetime.date) -> str: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> datetime.date | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> datetime.date | None: ... def convert_to_export(self, value, record: BaseModel): ... class Datetime(Field[datetime.datetime]): @@ -325,13 +379,17 @@ class Datetime(Field[datetime.datetime]): @staticmethod def today(*args) -> datetime.datetime: ... @staticmethod - def context_timestamp(record: BaseModel, timestamp: datetime.datetime) -> datetime.datetime: ... + def context_timestamp( + record: BaseModel, timestamp: datetime.datetime + ) -> datetime.datetime: ... @staticmethod def to_datetime(value) -> datetime.datetime | None: ... from_string = to_datetime @staticmethod def to_string(value: datetime.datetime | datetime.date) -> str: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> datetime.datetime | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> datetime.datetime | None: ... def convert_to_export(self, value, record: BaseModel): ... def convert_to_display_name(self, value, record: BaseModel) -> str: ... @@ -346,8 +404,12 @@ class Binary(Field[bytes]): def column_type(self) -> tuple[str, str] | None: ... def _get_attrs(self, model_class: Type[BaseModel], name: str) -> dict[str, Any]: ... _description_attachment: bool - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> psycopg2.Binary | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> bytes | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> psycopg2.Binary | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> bytes | None: ... def convert_to_record(self, value, record: BaseModel) -> bytes: ... def compute_value(self, records: BaseModel) -> None: ... def read(self, records: BaseModel) -> None: ... @@ -369,16 +431,22 @@ class Selection(Field[str]): selection: _SelectionRaw validate: bool ondelete: dict[str, Any] | None - def __init__(self, selection: _SelectionRaw = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, selection: _SelectionRaw = ..., string: str = ..., **kwargs + ) -> None: ... def setup_nonrelated(self, model: BaseModel) -> None: ... def setup_related(self, model: BaseModel): ... def _get_attrs(self, model_class: Type[BaseModel], name: str) -> dict[str, Any]: ... def _setup_attrs(self, model_class: Type[BaseModel], name: str) -> None: ... def _selection_modules(self, model: BaseModel) -> dict[str, set[str, str]]: ... def _description_selection(self, env: Environment) -> _Selection: ... - def _default_group_expand(self, records: BaseModel, groups, domain, order) -> list[str]: ... + def _default_group_expand( + self, records: BaseModel, groups, domain, order + ) -> list[str]: ... def get_values(self, env: Environment) -> list[str]: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_export(self, value, record: BaseModel): ... @@ -386,10 +454,16 @@ class Reference(Selection): type: str @property def column_type(self) -> tuple[str, str]: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> str | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> str | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> str | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> str | None: ... def convert_to_record(self, value, record: BaseModel) -> Union[BaseModel, None]: ... - def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...) -> str | bool: ... + def convert_to_read( + self, value, record: BaseModel, use_name_get: bool = ... + ) -> str | bool: ... def convert_to_export(self, value, record: BaseModel) -> str: ... def convert_to_display_name(self, value, record: BaseModel) -> str: ... @@ -415,14 +489,18 @@ class Many2one(_Relational): ondelete: str | None auto_join: bool delegate: bool - def __init__(self, comodel_name: str = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, comodel_name: str = ..., string: str = ..., **kwargs + ) -> None: ... def _setup_attrs(self, model_class: Type[BaseModel], name: str) -> None: ... def setup_nonrelated(self, model: BaseModel) -> None: ... def update_db(self, model: BaseModel, columns): ... def update_db_column(self, model: BaseModel, column) -> None: ... def update_db_foreign_key(self, model: BaseModel, column) -> None: ... def _update(self, records: BaseModel, value) -> None: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_record_multi(self, values, records: BaseModel): ... @@ -449,7 +527,9 @@ class Json(Field): column_type: tuple[str, str] def convert_to_record(self, value, record: BaseModel): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_export(self, value, record: BaseModel): ... class Properties(Field): @@ -470,7 +550,9 @@ class Properties(Field): _depends: tuple[str, ...] compute: Callable def _setup_attrs(self, model_class: Type[BaseModel], name: str) -> None: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... @@ -482,9 +564,13 @@ class Properties(Field): def _add_default_values(self, env: Environment, values: dict[str, Any]): ... def _get_properties_definition(self, record: BaseModel): ... @classmethod - def _add_display_name(cls, values_list: list[dict], env: Environment, value_keys: tuple[str] = ...) -> None: ... + def _add_display_name( + cls, values_list: list[dict], env: Environment, value_keys: tuple[str] = ... + ) -> None: ... @classmethod - def _remove_display_name(cls, values_list: list[dict], value_key: str = ...) -> None: ... + def _remove_display_name( + cls, values_list: list[dict], value_key: str = ... + ) -> None: ... @classmethod def _add_missing_names(cls, values_list: list[dict]) -> None: ... @classmethod @@ -492,7 +578,9 @@ class Properties(Field): @classmethod def _list_to_dict(cls, values_list: list[dict]) -> dict: ... @classmethod - def _dict_to_list(cls, values_dict: dict, properties_definition: Sequence[dict]) -> Sequence[dict]: ... + def _dict_to_list( + cls, values_dict: dict, properties_definition: Sequence[dict] + ) -> Sequence[dict]: ... class PropertiesDefinition(Field): type: str @@ -502,12 +590,16 @@ class PropertiesDefinition(Field): prefetch: bool REQUIRED_KEYS: tuple[str, ...] ALLOWED_KEYS: tuple[str, ...] - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... @classmethod - def _validate_properties_definition(cls, properties_definition: Sequence[dict], env): ... + def _validate_properties_definition( + cls, properties_definition: Sequence[dict], env + ): ... class Command(enum.IntEnum): CREATE: int @@ -552,7 +644,13 @@ class One2many(_RelationalMulti): inverse_name: str | None auto_join: bool copy: bool - def __init__(self, comodel_name: str = ..., inverse_name: str = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, + comodel_name: str = ..., + inverse_name: str = ..., + string: str = ..., + **kwargs + ) -> None: ... def setup_nonrelated(self, model: BaseModel) -> None: ... _description_relation_field: str | None def update_db(self, model: BaseModel, columns) -> None: ... @@ -569,7 +667,15 @@ class Many2many(_RelationalMulti): column2: str | None auto_join: bool ondelete: str - def __init__(self, comodel_name: str =..., relation: str = ..., column1: str = ..., column2: str = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, + comodel_name: str = ..., + relation: str = ..., + column1: str = ..., + column2: str = ..., + string: str = ..., + **kwargs + ) -> None: ... def setup_nonrelated(self, model: BaseModel) -> None: ... def update_db(self, model: BaseModel, columns) -> None: ... def update_db_foreign_keys(self, model: BaseModel) -> None: ... @@ -590,7 +696,7 @@ class Id(Field[int]): def __set__(self, record: BaseModel, value) -> None: ... class PrefetchMany2one: - __slots__ = 'record', 'field' + __slots__ = "record", "field" record: BaseModel field: Field def __init__(self, record: BaseModel, field: Field) -> None: ... @@ -598,7 +704,7 @@ class PrefetchMany2one: def __reversed__(self) -> Iterator[int]: ... class PrefetchX2many: - __slots__ = 'record', 'field' + __slots__ = "record", "field" record: BaseModel field: Field def __init__(self, record: BaseModel, field: Field) -> None: ... diff --git a/odoo-stubs/http.pyi b/odoo-stubs/http.pyi index a654bbb..b1ff992 100644 --- a/odoo-stubs/http.pyi +++ b/odoo-stubs/http.pyi @@ -2,7 +2,16 @@ from abc import ABC, abstractmethod from collections import defaultdict from collections.abc import MutableMapping from contextlib import nullcontext -from typing import Any, Callable, Collection, Generator, Iterable, Literal, Mapping, TypeVar +from typing import ( + Any, + Callable, + Collection, + Generator, + Iterable, + Literal, + Mapping, + TypeVar, +) import werkzeug from werkzeug.datastructures import Headers @@ -20,7 +29,7 @@ from .tools._vendor import sessions from .tools.geoipresolver import GeoIPResolver from .tools.profiler import Profiler -_T = TypeVar('_T') +_T = TypeVar("_T") ProxyFix: Callable[..., ProxyFix_] CORS_MAX_AGE: int @@ -45,8 +54,16 @@ def db_filter(dbs: Iterable[str], host: str | None = ...) -> list[str]: ... def dispatch_rpc(service_name: str, method: str, params: Mapping): ... def is_cors_preflight(request: Request, endpoint) -> bool: ... def serialize_exception(exception: Exception): ... -def send_file(filepath_or_fp, mimetype: str | None = ..., as_attachment: bool = ..., filename: str | None = ..., - mtime: str | None = ..., add_etags: bool = ..., cache_timeout: int = ..., conditional: bool = ...) -> werkzeug.Response: ... +def send_file( + filepath_or_fp, + mimetype: str | None = ..., + as_attachment: bool = ..., + filename: str | None = ..., + mtime: str | None = ..., + add_etags: bool = ..., + cache_timeout: int = ..., + conditional: bool = ..., +) -> werkzeug.Response: ... class Stream: type: str @@ -66,25 +83,34 @@ class Stream: @classmethod def from_path(cls, path: str, filter_ext: tuple[str, ...] = ...) -> Stream: ... @classmethod - def from_attachment(cls, attachment: 'odoo.model.ir_attachment') -> Stream: ... + def from_attachment(cls, attachment: "odoo.model.ir_attachment") -> Stream: ... @classmethod def from_binary_field(cls, record: BaseModel, field_name: str) -> Stream: ... def read(self) -> bytes: ... - def get_response(self, as_attachment: bool | None = ..., immutable: bool | None = ..., **send_file_kwargs) -> werkzeug.Response: ... + def get_response( + self, + as_attachment: bool | None = ..., + immutable: bool | None = ..., + **send_file_kwargs + ) -> werkzeug.Response: ... class Controller: children_classes: defaultdict[Any, list] @classmethod def __init_subclass__(cls) -> None: ... -def route(route: str | list[str] | None = ..., - type: str = ..., - auth: str = ..., - methods: list[str] = ..., - cors: str = ..., - csrf: bool = ..., - **kw): ... -def _generate_routing_rules(modules: Collection[str], nodb_only: bool, converters: Any | None = ...) -> Generator[tuple[str, Any], None, None]: ... +def route( + route: str | list[str] | None = ..., + type: str = ..., + auth: str = ..., + methods: list[str] = ..., + cors: str = ..., + csrf: bool = ..., + **kw +): ... +def _generate_routing_rules( + modules: Collection[str], nodb_only: bool, converters: Any | None = ... +) -> Generator[tuple[str, Any], None, None]: ... class FilesystemSessionStore(sessions.FilesystemSessionStore): def get_session_filename(self, sid: str) -> str: ... @@ -94,7 +120,15 @@ class FilesystemSessionStore(sessions.FilesystemSessionStore): def vacuum(self) -> None: ... class Session(MutableMapping): - __slots__ = ('can_save', '_Session__data', 'is_dirty', 'is_explicit', 'is_new', 'should_rotate', 'sid') + __slots__ = ( + "can_save", + "_Session__data", + "is_dirty", + "is_explicit", + "is_new", + "should_rotate", + "sid", + ) can_save: bool __data: dict is_dirty: bool @@ -114,7 +148,9 @@ class Session(MutableMapping): uid: int | None pre_login: str | None pre_uid: int - def authenticate(self, dbname: str, login: str | None = ..., password: str | None = ...) -> int: ... + def authenticate( + self, dbname: str, login: str | None = ..., password: str | None = ... + ) -> int: ... def finalize(self, env: Environment) -> None: ... def logout(self, keep_db: bool = ...) -> None: ... def touch(self) -> None: ... @@ -132,23 +168,48 @@ class Response(werkzeug.Response): template: Any qcontext: dict uid: int - def set_default(self, template: Any | None = ..., qcontext: dict | None = ..., uid: int | None = ...) -> None: ... + def set_default( + self, + template: Any | None = ..., + qcontext: dict | None = ..., + uid: int | None = ..., + ) -> None: ... @property def is_qweb(self) -> bool: ... def render(self): ... def flatten(self) -> None: ... - def set_cookie(self, key: str, value: str = ..., max_age: Any | None = ..., expires: Any | None = ..., - path: str = ..., domain: str | None = ..., secure: bool = ..., httponly: bool = ..., - samesite: str | None = ..., cookie_type: str = ...) -> None: ... + def set_cookie( + self, + key: str, + value: str = ..., + max_age: Any | None = ..., + expires: Any | None = ..., + path: str = ..., + domain: str | None = ..., + secure: bool = ..., + httponly: bool = ..., + samesite: str | None = ..., + cookie_type: str = ..., + ) -> None: ... class FutureResponse: charset: str max_cookie_size: int headers: Headers def __init__(self) -> None: ... - def set_cookie(self, key: str, value: str = ..., max_age: Any | None = ..., expires: Any | None = ..., - path: str = ..., domain: str | None = ..., secure: bool = ..., httponly: bool = ..., - samesite: str | None = ..., cookie_type: str = ...) -> None: ... + def set_cookie( + self, + key: str, + value: str = ..., + max_age: Any | None = ..., + expires: Any | None = ..., + path: str = ..., + domain: str | None = ..., + secure: bool = ..., + httponly: bool = ..., + samesite: str | None = ..., + cookie_type: str = ..., + ) -> None: ... class Request: httprequest: werkzeug.Request @@ -158,16 +219,20 @@ class Request: session: Session db: str | None env: Environment | None - website: 'odoo.model.website' + website: "odoo.model.website" website_routing: int is_frontend: bool is_frontend_multilang: bool - lang: 'odoo.model.res_lang' + lang: "odoo.model.res_lang" def __init__(self, httprequest: werkzeug.Request) -> None: ... def _post_init(self) -> None: ... def _get_session_and_dbname(self) -> tuple[Session, str]: ... - def update_env(self, user: 'odoo.model.res_users | int | None' = ..., context: dict[str, Any] | None = ..., - su: bool | None = ...) -> None: ... + def update_env( + self, + user: "odoo.model.res_users | int | None" = ..., + context: dict[str, Any] | None = ..., + su: bool | None = ..., + ) -> None: ... def update_context(self, **overrides) -> None: ... @property def context(self) -> dict[str, Any]: ... @@ -195,15 +260,34 @@ class Request: def get_json_data(self): ... def _get_profiler_context_manager(self) -> Profiler | nullcontext: ... def _inject_future_response(self, response: werkzeug.Response): ... - def make_response(self, data: str, headers: list[tuple[str, Any]] | None = ..., cookies: Mapping | None = ..., - status: int = ...) -> Response: ... - def make_json_response(self, data, headers: list[tuple[str, Any]] | None = ..., cookies: Mapping | None = ..., - status: int = ...) -> Response: ... + def make_response( + self, + data: str, + headers: list[tuple[str, Any]] | None = ..., + cookies: Mapping | None = ..., + status: int = ..., + ) -> Response: ... + def make_json_response( + self, + data, + headers: list[tuple[str, Any]] | None = ..., + cookies: Mapping | None = ..., + status: int = ..., + ) -> Response: ... def not_found(self, description: str | None = ...) -> NotFound: ... - def redirect(self, location: URL | str, code: int = ..., local: bool = ...) -> werkzeug.Response: ... - def redirect_query(self, location: str, query: Mapping[str, str] | Iterable[tuple[str, str]] | None = ..., - code: int = ..., local: bool = ...) -> werkzeug.Response: ... - def render(self, template: str, qcontext: dict | None = ..., lazy: bool = ..., **kw): ... + def redirect( + self, location: URL | str, code: int = ..., local: bool = ... + ) -> werkzeug.Response: ... + def redirect_query( + self, + location: str, + query: Mapping[str, str] | Iterable[tuple[str, str]] | None = ..., + code: int = ..., + local: bool = ..., + ) -> werkzeug.Response: ... + def render( + self, template: str, qcontext: dict | None = ..., lazy: bool = ..., **kw + ): ... def _save_session(self) -> None: ... def _set_request_dispatcher(self, rule: Rule) -> None: ... def _serve_static(self) -> werkzeug.Response: ... @@ -245,7 +329,9 @@ class JsonRPCDispatcher(Dispatcher): def is_compatible_with(cls, request: Request) -> bool: ... def dispatch(self, endpoint, args): ... def handle_error(self, exc: Exception) -> Callable: ... - def _response(self, result: Any | None = ..., error: Any | None = ...) -> Response: ... + def _response( + self, result: Any | None = ..., error: Any | None = ... + ) -> Response: ... class Application: @property diff --git a/odoo-stubs/models.pyi b/odoo-stubs/models.pyi index c90eec8..ba3b338 100644 --- a/odoo-stubs/models.pyi +++ b/odoo-stubs/models.pyi @@ -1,6 +1,19 @@ from collections import defaultdict from re import Pattern -from typing import Any, Callable, Collection, Container, Iterable, Iterator, Literal, MutableMapping, Sequence, TypeVar, Union, overload +from typing import ( + Any, + Callable, + Collection, + Container, + Iterable, + Iterator, + Literal, + MutableMapping, + Sequence, + TypeVar, + Union, + overload, +) import psycopg2 @@ -11,8 +24,8 @@ from .modules.registry import Registry from .sql_db import Cursor from .tools.query import Query -_T = TypeVar('_T') -_ModelT = TypeVar('_ModelT', bound=BaseModel) +_T = TypeVar("_T") +_ModelT = TypeVar("_ModelT", bound=BaseModel) _Domain = list regex_order: Pattern[str] @@ -35,7 +48,9 @@ def fix_import_export_id_paths(fieldname: str) -> list[str]: ... class MetaModel(api.Meta): module_to_models: defaultdict[str, list[type[BaseModel]]] def __new__(meta, name: str, bases: tuple, attrs: dict): ... - def __init__(self: type[BaseModel], name: str, bases: tuple, attrs: dict) -> None: ... + def __init__( + self: type[BaseModel], name: str, bases: tuple, attrs: dict + ) -> None: ... class NewId: __slots__: list[str] @@ -51,7 +66,7 @@ class NewId: def origin_ids(ids: Iterable) -> Iterator[int]: ... class OriginIds: - __slots__ = ['ids'] + __slots__ = ["ids"] ids: Sequence[int] def __init__(self, ids: Sequence[int]) -> None: ... def __iter__(self) -> Iterator[int]: ... @@ -108,11 +123,11 @@ class BaseModel(metaclass=MetaModel): env: Environment = ... pool: Registry id = fields.Id() - display_name = fields.Char(string='Display Name') - create_uid = fields.Many2one('res.users', string='Created by') - create_date = fields.Datetime(string='Created on') - write_uid = fields.Many2one('res.users', string='Last Updated by') - write_date = fields.Datetime(string='Last Updated on') + display_name = fields.Char(string="Display Name") + create_uid = fields.Many2one("res.users", string="Created by") + create_date = fields.Datetime(string="Created on") + write_uid = fields.Many2one("res.users", string="Last Updated by") + write_date = fields.Datetime(string="Last Updated on") CONCURRENCY_CHECK_FIELD: str def _valid_field_parameter(self, field: Field, name: str) -> bool: ... def _add_field(self, name: str, field: Field) -> None: ... @@ -123,7 +138,9 @@ class BaseModel(metaclass=MetaModel): @classmethod def _build_model_check_base(model_class, cls: type[BaseModel]) -> None: ... @classmethod - def _build_model_check_parent(model_class, cls: type[BaseModel], parent_class: type[BaseModel]) -> None: ... + def _build_model_check_parent( + model_class, cls: type[BaseModel], parent_class: type[BaseModel] + ) -> None: ... @classmethod def _build_model_attributes(cls, pool: Registry) -> None: ... @classmethod @@ -135,43 +152,147 @@ class BaseModel(metaclass=MetaModel): @property def _onchange_methods(self) -> dict[str, list]: ... def _is_an_ordinary_table(self) -> bool: ... - def __ensure_xml_id(self: _ModelT, skip: bool = ...) -> Iterator[tuple[_ModelT, str | None]]: ... - def _export_rows(self, fields: list[list[str]], *, _is_toplevel_call: bool = ...) -> list[list]: ... + def __ensure_xml_id( + self: _ModelT, skip: bool = ... + ) -> Iterator[tuple[_ModelT, str | None]]: ... + def _export_rows( + self, fields: list[list[str]], *, _is_toplevel_call: bool = ... + ) -> list[list]: ... def export_data(self, fields_to_export: list[str]) -> dict[str, list[list]]: ... def load(self, fields: list[str], data: list[list[str]]) -> dict[str, Any]: ... - def _add_fake_fields(self, fields: dict[str | None, Field]) -> dict[str | None, Field]: ... - def _extract_records(self, fields_: Iterable[Sequence[str]], data, log: Callable = ..., limit: float = ...) -> Iterator[tuple[BaseModel, dict[str, dict[str, int]]]]: ... - def _convert_records(self, records, log: Callable = ...) -> Iterator[tuple[Any, Any, Any, dict]]: ... - def _validate_fields(self, field_names: Iterable[str], excluded_names: Iterable[str] = ...) -> None: ... + def _add_fake_fields( + self, fields: dict[str | None, Field] + ) -> dict[str | None, Field]: ... + def _extract_records( + self, + fields_: Iterable[Sequence[str]], + data, + log: Callable = ..., + limit: float = ..., + ) -> Iterator[tuple[BaseModel, dict[str, dict[str, int]]]]: ... + def _convert_records( + self, records, log: Callable = ... + ) -> Iterator[tuple[Any, Any, Any, dict]]: ... + def _validate_fields( + self, field_names: Iterable[str], excluded_names: Iterable[str] = ... + ) -> None: ... def default_get(self, fields_list: list[str]) -> dict[str, Any]: ... def fields_get_keys(self) -> list[str]: ... def _rec_name_fallback(self) -> str: ... def user_has_groups(self, groups: str) -> bool: ... def search_count(self, domain: _Domain, limit: int | None = ...) -> int: ... @overload - def search(self: _ModelT, domain: _Domain, offset: int = ..., limit: int | None = ..., order: str | None = ..., count: Literal[False] = ...) -> _ModelT: ... + def search( + self: _ModelT, + domain: _Domain, + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + count: Literal[False] = ..., + ) -> _ModelT: ... @overload - def search(self: _ModelT, domain: _Domain, offset: int = ..., limit: int | None = ..., order: str | None = ..., count: Literal[True] = ...) -> int: ... + def search( + self: _ModelT, + domain: _Domain, + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + count: Literal[True] = ..., + ) -> int: ... def _compute_display_name(self) -> None: ... def name_get(self) -> list[tuple[int, str]]: ... def name_create(self, name: str) -> tuple[int, str]: ... - def name_search(self, name: str = ..., args: _Domain | None = ..., operator: str = ..., limit: int = ...) -> list[tuple[int, str]]: ... - def _name_search(self, name: str = ..., args: _Domain | None = ..., operator: str = ..., limit: int = ..., name_get_uid: int | None = ...) -> list[int]: ... + def name_search( + self, + name: str = ..., + args: _Domain | None = ..., + operator: str = ..., + limit: int = ..., + ) -> list[tuple[int, str]]: ... + def _name_search( + self, + name: str = ..., + args: _Domain | None = ..., + operator: str = ..., + limit: int = ..., + name_get_uid: int | None = ..., + ) -> list[int]: ... def _add_missing_default_values(self, values: dict[str, Any]) -> dict[str, Any]: ... @classmethod def clear_caches(cls) -> None: ... - def _read_group_expand_full(self, groups: _ModelT, domain: _Domain | None, order: str | None) -> _ModelT: ... - def _read_group_fill_results(self, domain: _Domain, groupby: str, remaining_groupbys: list[str], aggregated_fields: list[str], count_field: str, read_group_result, read_group_order: str | None = ...) -> list: ... - def _read_group_fill_temporal(self, data: list, groupby: list[str], aggregated_fields: list[str], annotated_groupbys: list[dict], fill_from: str | None = ..., fill_to: str | None = ..., min_groups: int | None = ...) -> list: ... - def _read_group_prepare(self, orderby: str, aggregated_fields: list[str], annotated_groupbys: list[dict], query: Query) -> tuple[list, list]: ... + def _read_group_expand_full( + self, groups: _ModelT, domain: _Domain | None, order: str | None + ) -> _ModelT: ... + def _read_group_fill_results( + self, + domain: _Domain, + groupby: str, + remaining_groupbys: list[str], + aggregated_fields: list[str], + count_field: str, + read_group_result, + read_group_order: str | None = ..., + ) -> list: ... + def _read_group_fill_temporal( + self, + data: list, + groupby: list[str], + aggregated_fields: list[str], + annotated_groupbys: list[dict], + fill_from: str | None = ..., + fill_to: str | None = ..., + min_groups: int | None = ..., + ) -> list: ... + def _read_group_prepare( + self, + orderby: str, + aggregated_fields: list[str], + annotated_groupbys: list[dict], + query: Query, + ) -> tuple[list, list]: ... def _read_group_process_groupby(self, gb: str, query: Query) -> dict[str, Any]: ... - def _read_group_prepare_data(self, key, value, groupby_dict: dict[str, dict[str, Any]]) -> Any: ... - def _read_group_format_result(self, data: dict, annotated_groupbys: list[dict], groupby: list, domain: _Domain) -> dict: ... - def _read_group(self, domain: _Domain, fields: list[str], groupby: str | list[str], offset: int = ..., limit: int | None = ..., orderby: str | None = ..., lazy: bool = ...) -> list[dict[str, Any]]: ... - def read_group(self, domain: _Domain, fields: list[str], groupby: str | list[str], offset: int = ..., limit: int | None = ..., orderby: str | None = ..., lazy: bool = ...) -> list[dict[str, Any]]: ... - def _read_group_raw(self, domain: _Domain, fields: list[str], groupby: str | list[str], offset: int = ..., limit: int | None = ..., orderby: str | None = ..., lazy: bool = ...) -> list[dict[str, Any]]: ... - def _read_group_resolve_many2x_fields(self, data: list[dict[str, Any]], fields: list[dict[str, Any]]) -> None: ... - def _inherits_join_add(self, current_model: BaseModel, parent_model_name: str, query: Query) -> str: ... + def _read_group_prepare_data( + self, key, value, groupby_dict: dict[str, dict[str, Any]] + ) -> Any: ... + def _read_group_format_result( + self, data: dict, annotated_groupbys: list[dict], groupby: list, domain: _Domain + ) -> dict: ... + def _read_group( + self, + domain: _Domain, + fields: list[str], + groupby: str | list[str], + offset: int = ..., + limit: int | None = ..., + orderby: str | None = ..., + lazy: bool = ..., + ) -> list[dict[str, Any]]: ... + def read_group( + self, + domain: _Domain, + fields: list[str], + groupby: str | list[str], + offset: int = ..., + limit: int | None = ..., + orderby: str | None = ..., + lazy: bool = ..., + ) -> list[dict[str, Any]]: ... + def _read_group_raw( + self, + domain: _Domain, + fields: list[str], + groupby: str | list[str], + offset: int = ..., + limit: int | None = ..., + orderby: str | None = ..., + lazy: bool = ..., + ) -> list[dict[str, Any]]: ... + def _read_group_resolve_many2x_fields( + self, data: list[dict[str, Any]], fields: list[dict[str, Any]] + ) -> None: ... + def _inherits_join_add( + self, current_model: BaseModel, parent_model_name: str, query: Query + ) -> str: ... def _inherits_join_calc(self, alias: str, fname: str, query: Query) -> str: ... def _parent_store_compute(self): ... def _check_removed_columns(self, log: bool = ...) -> None: ... @@ -187,27 +308,48 @@ class BaseModel(metaclass=MetaModel): def _setup_base(self) -> None: ... def _setup_fields(self) -> None: ... def _setup_complete(self) -> None: ... - def fields_get(self, allfields: list[str] | None = ..., attributes: list[str] | None = ...) -> dict[str, dict[str, Any]]: ... + def fields_get( + self, allfields: list[str] | None = ..., attributes: list[str] | None = ... + ) -> dict[str, dict[str, Any]]: ... def check_field_access_rights(self, operation: str, fields: Collection[str]): ... - def read(self, fields: Collection[str] | None = ..., load: str = ...) -> list[dict[str, Any]]: ... - def update_field_translations(self, field_name: str, translations: dict[str, Any]) -> bool: ... - def _update_field_translations(self, field_name: str, translations: dict[str, Any], digest: Callable | None = ...) ->bool: ... - def get_field_translations(self, field_name: str, langs: list[str] | None = ...) -> tuple[list[dict[str, Any]], dict[str, Any]]: ... - def _read_format(self, fnames: Collection[str], load: str = ...) -> list[dict[str, Any]]: ... + def read( + self, fields: Collection[str] | None = ..., load: str = ... + ) -> list[dict[str, Any]]: ... + def update_field_translations( + self, field_name: str, translations: dict[str, Any] + ) -> bool: ... + def _update_field_translations( + self, + field_name: str, + translations: dict[str, Any], + digest: Callable | None = ..., + ) -> bool: ... + def get_field_translations( + self, field_name: str, langs: list[str] | None = ... + ) -> tuple[list[dict[str, Any]], dict[str, Any]]: ... + def _read_format( + self, fnames: Collection[str], load: str = ... + ) -> list[dict[str, Any]]: ... def _fetch_field(self, field: Field) -> None: ... def _read(self, field_names: Collection[str]): ... def get_metadata(self) -> list[dict[str, Any]]: ... def get_base_url(self) -> str: ... def _check_company(self, fnames: Collection[str] | None = ...) -> None: ... - def check_access_rights(self, operation: str, raise_exception: bool = ...) -> bool: ... + def check_access_rights( + self, operation: str, raise_exception: bool = ... + ) -> bool: ... def check_access_rule(self, operation: str) -> None: ... def _filter_access_rules(self: _ModelT, operation: str) -> _ModelT: ... def _filter_access_rules_python(self, operation: str) -> _ModelT: ... def unlink(self): ... def write(self, vals: dict[str, Any]): ... def _write(self, vals: dict[str, Any]) -> None: ... - def create(self: _ModelT, vals_list: list[dict[str, Any]] | dict[str, Any]) -> _ModelT: ... - def _prepare_create_values(self, vals_list: list[dict[str, Any]]) -> list[dict[str, Any]]: ... + def create( + self: _ModelT, vals_list: list[dict[str, Any]] | dict[str, Any] + ) -> _ModelT: ... + def _prepare_create_values( + self, vals_list: list[dict[str, Any]] + ) -> list[dict[str, Any]]: ... def _add_precomputed_values(self, vals_list: list[dict[str, Any]]) -> None: ... def _create(self: _ModelT, data_list: list[dict[str, Any]]) -> _ModelT: ... def _compute_field_value(self, field: Field) -> None: ... @@ -220,13 +362,45 @@ class BaseModel(metaclass=MetaModel): def _where_calc(self, domain: _Domain, active_test: bool = ...) -> Query: ... def _check_qorder(self, word: str) -> bool: ... def _apply_ir_rules(self, query: Query, mode: str = ...) -> None: ... - def _generate_m2o_order_by(self, alias: str, order_field: str, query: Query, reverse_direction: bool, seen: set | None) -> list[str]: ... - def _generate_order_by_inner(self, alias: str, order_spec: str, query: Query, reverse_direction: bool = ..., seen: set | None = ...) -> list[str]: ... + def _generate_m2o_order_by( + self, + alias: str, + order_field: str, + query: Query, + reverse_direction: bool, + seen: set | None, + ) -> list[str]: ... + def _generate_order_by_inner( + self, + alias: str, + order_spec: str, + query: Query, + reverse_direction: bool = ..., + seen: set | None = ..., + ) -> list[str]: ... def _generate_order_by(self, order_spec: str | None, query: Query) -> str: ... - def _flush_search(self, domain: _Domain, fields: Sequence[str] | None = ..., order: str | None = ..., seen: set | None = ...) -> None: ... - def _search(self: _ModelT, domain: _Domain, offset: int = ..., limit: int | None = ..., order: str | None = ..., count: bool = ..., access_rights_uid: int | None = ...) -> Query | int: ... - def copy_data(self, default: dict[str, Any] | None = ...) -> list[dict[str, Any]]: ... - def copy_translations(self: _ModelT, new: _ModelT, excluded: Container[str] = ...) -> None: ... + def _flush_search( + self, + domain: _Domain, + fields: Sequence[str] | None = ..., + order: str | None = ..., + seen: set | None = ..., + ) -> None: ... + def _search( + self: _ModelT, + domain: _Domain, + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + count: bool = ..., + access_rights_uid: int | None = ..., + ) -> Query | int: ... + def copy_data( + self, default: dict[str, Any] | None = ... + ) -> list[dict[str, Any]]: ... + def copy_translations( + self: _ModelT, new: _ModelT, excluded: Container[str] = ... + ) -> None: ... def copy(self: _ModelT, default: dict[str, Any] | None = ...) -> _ModelT: ... def exists(self: _ModelT) -> _ModelT: ... def _check_recursion(self, parent: str | None = ...) -> bool: ... @@ -236,7 +410,15 @@ class BaseModel(metaclass=MetaModel): def get_xml_id(self) -> dict[int, str]: ... @classmethod def is_transient(cls) -> bool: ... - def search_read(self, domain: _Domain | None = ..., fields: list[str] | None = ..., offset: int = ..., limit: int | None = ..., order: str | None = ..., **read_kwargs: str) -> list[dict[str, Any]]: ... + def search_read( + self, + domain: _Domain | None = ..., + fields: list[str] | None = ..., + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + **read_kwargs: str + ) -> list[dict[str, Any]]: ... def toggle_active(self) -> None: ... def action_archive(self): ... def action_unarchive(self): ... @@ -246,8 +428,12 @@ class BaseModel(metaclass=MetaModel): def _patch_method(cls, name: str, method) -> None: ... @classmethod def _revert_method(cls, name: str) -> None: ... - def __init__(self, env: Environment, ids: tuple, prefetch_ids: Iterable[int]) -> None: ... - def browse(self: _ModelT, ids: int | NewId | Iterable[int | NewId] | None = ...) -> _ModelT: ... + def __init__( + self, env: Environment, ids: tuple, prefetch_ids: Iterable[int] + ) -> None: ... + def browse( + self: _ModelT, ids: int | NewId | Iterable[int | NewId] | None = ... + ) -> _ModelT: ... @property def ids(self) -> list[int]: ... _cr: Cursor @@ -256,10 +442,16 @@ class BaseModel(metaclass=MetaModel): def ensure_one(self: _ModelT) -> _ModelT: ... def with_env(self: _ModelT, env: Environment) -> _ModelT: ... def sudo(self: _ModelT, flag: bool = ...) -> _ModelT: ... - def with_user(self: _ModelT, user: Union['odoo.model.res_partner', int]) -> _ModelT: ... - def with_company(self: _ModelT, company: Union['odoo.model.res_company', int]) -> _ModelT: ... + def with_user( + self: _ModelT, user: Union["odoo.model.res_partner", int] + ) -> _ModelT: ... + def with_company( + self: _ModelT, company: Union["odoo.model.res_company", int] + ) -> _ModelT: ... def with_context(self: _ModelT, *args, **kwargs) -> _ModelT: ... - def with_prefetch(self: _ModelT, prefetch_ids: Iterable[int] | None = ...) -> _ModelT: ... + def with_prefetch( + self: _ModelT, prefetch_ids: Iterable[int] | None = ... + ) -> _ModelT: ... def _update_cache(self, values: dict[str, Any], validate: bool = ...): ... def _convert_to_record(self, values: dict[str, Any]): ... def _convert_to_write(self, values: dict[str, Any]) -> dict[str, Any]: ... @@ -267,13 +459,22 @@ class BaseModel(metaclass=MetaModel): def mapped(self, func: Callable | str): ... def filtered(self: _ModelT, func: Callable | str) -> _ModelT: ... def filtered_domain(self: _ModelT, domain: _Domain) -> _ModelT: ... - def sorted(self: _ModelT, key: Callable | str | None = ..., reverse: bool = ...) -> _ModelT: ... + def sorted( + self: _ModelT, key: Callable | str | None = ..., reverse: bool = ... + ) -> _ModelT: ... def update(self, values: dict[str, Any]) -> None: ... - def flush(self, fnames: Collection[str] | None = ..., records: BaseModel | None = ...) -> None: ... + def flush( + self, fnames: Collection[str] | None = ..., records: BaseModel | None = ... + ) -> None: ... def flush_model(self, fnames: Iterable[str] | None = ...) -> None: ... def flush_recordset(self, fnames: Iterable[str] | None = ...) -> None: ... def _flush(self, fnames: Iterable[str] | None = ...) -> None: ... - def new(self: _ModelT, values: dict[str, Any] | None = ..., origin: _ModelT | None = ..., ref: Any | None = ...) -> _ModelT: ... + def new( + self: _ModelT, + values: dict[str, Any] | None = ..., + origin: _ModelT | None = ..., + ref: Any | None = ..., + ) -> _ModelT: ... @property def _origin(self: _ModelT) -> _ModelT: ... def __bool__(self) -> bool: ... @@ -301,19 +502,42 @@ class BaseModel(metaclass=MetaModel): def _cache(self) -> RecordCache: ... def _in_cache_without(self: _ModelT, field: Field, limit: int = ...) -> _ModelT: ... def refresh(self) -> None: ... - def invalidate_cache(self, fnames: Collection[str] | None = ..., ids: Iterable[int] | None = ...) -> None: ... - def invalidate_model(self, fnames: Iterable[str] | None = ..., flush: bool = ...) -> None: ... - def invalidate_recordset(self, fnames: Iterable[str] | None = ..., flush: bool = ...) -> None: ... - def _invalidate_cache(self, fnames: Iterable[str] | None = ..., ids: Iterable[int] | None = ...) -> None: ... - def modified(self, fnames: Collection[str], create: bool = ..., before: bool = ...) -> None: ... - def _modified_triggers(self: _ModelT, tree: dict[Field | None, Any], create: bool = ...) -> Iterator[tuple[Field, _ModelT, bool]]: ... - def recompute(self, fnames: Collection[str] | None = ..., records: Union[BaseModel, None] = ...) -> None: ... + def invalidate_cache( + self, fnames: Collection[str] | None = ..., ids: Iterable[int] | None = ... + ) -> None: ... + def invalidate_model( + self, fnames: Iterable[str] | None = ..., flush: bool = ... + ) -> None: ... + def invalidate_recordset( + self, fnames: Iterable[str] | None = ..., flush: bool = ... + ) -> None: ... + def _invalidate_cache( + self, fnames: Iterable[str] | None = ..., ids: Iterable[int] | None = ... + ) -> None: ... + def modified( + self, fnames: Collection[str], create: bool = ..., before: bool = ... + ) -> None: ... + def _modified_triggers( + self: _ModelT, tree: dict[Field | None, Any], create: bool = ... + ) -> Iterator[tuple[Field, _ModelT, bool]]: ... + def recompute( + self, + fnames: Collection[str] | None = ..., + records: Union[BaseModel, None] = ..., + ) -> None: ... def _recompute_model(self, fnames: Iterable[str] | None = ...) -> None: ... def _recompute_recordset(self, fnames: Iterable[str] | None = ...) -> None: ... - def _recompute_field(self, field: Field, ids: Iterable[int] | None = ...) -> None: ... + def _recompute_field( + self, field: Field, ids: Iterable[int] | None = ... + ) -> None: ... def _has_onchange(self, field: Field, other_fields: Container[Field]) -> bool: ... def _onchange_eval(self, field_name: str, onchange: str, result: dict) -> None: ... - def onchange(self, values: dict[str, Any], field_name: str | list[str] | bool, field_onchange: dict[str, str]) -> dict: ... + def onchange( + self, + values: dict[str, Any], + field_name: str | list[str] | bool, + field_onchange: dict[str, str], + ) -> dict: ... def _get_placeholder_filename(self, field: str) -> str | bool: ... def _populate_factories(self) -> list[tuple[str, Callable[..., Iterator]]]: ... @property @@ -350,9 +574,15 @@ class TransientModel(Model): def _transient_clean_rows_older_than(self, seconds) -> None: ... def itemgetter_tuple(items) -> Callable[..., tuple]: ... -def convert_pgerror_not_null(model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error) -> dict[str, str]: ... -def convert_pgerror_unique(model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error) -> dict[str, str]: ... -def convert_pgerror_constraint(model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error) -> dict[str, str]: ... +def convert_pgerror_not_null( + model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error +) -> dict[str, str]: ... +def convert_pgerror_unique( + model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error +) -> dict[str, str]: ... +def convert_pgerror_constraint( + model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error +) -> dict[str, str]: ... PGERROR_TO_OE: dict[str, Callable] diff --git a/odoo-stubs/modules/__init__.pyi b/odoo-stubs/modules/__init__.pyi index 5508b25..d9ff7d6 100644 --- a/odoo-stubs/modules/__init__.pyi +++ b/odoo-stubs/modules/__init__.pyi @@ -1,26 +1,20 @@ -from . import ( - db as db, - graph as graph, - loading as loading, - migration as migration, - module as module, - neutralize as neutralize, - 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, - check_resource_path as check_resource_path, - get_manifest as get_manifest, - 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_openerp_module as load_openerp_module -) +from . import db as db +from . import graph as graph +from . import loading as loading +from . import migration as migration +from . import module as module +from . import neutralize as neutralize +from . import registry as registry +from .loading import load_modules as load_modules +from .loading import reset_modules_state as reset_modules_state +from .module import adapt_version as adapt_version +from .module import check_resource_path as check_resource_path +from .module import get_manifest as get_manifest +from .module import get_module_path as get_module_path +from .module import get_module_resource as get_module_resource +from .module import get_modules as get_modules +from .module import get_modules_with_version as get_modules_with_version +from .module import get_resource_from_path as get_resource_from_path +from .module import get_resource_path as get_resource_path +from .module import initialize_sys_path as initialize_sys_path +from .module import load_openerp_module as load_openerp_module diff --git a/odoo-stubs/modules/graph.pyi b/odoo-stubs/modules/graph.pyi index fdc1933..429cfdc 100644 --- a/odoo-stubs/modules/graph.pyi +++ b/odoo-stubs/modules/graph.pyi @@ -6,7 +6,9 @@ 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 add_modules( + self, cr: Cursor, module_list: list[str], force: list | None = ... + ): ... def __iter__(self) -> Iterator[Node]: ... def __str__(self) -> str: ... @@ -21,7 +23,9 @@ class Node: dbdemo: bool state: str installed_version: str - def __init__(self, name: str, graph: Graph, info: dict[str, Any] | None) -> None: ... + def __init__( + self, name: str, graph: Graph, info: dict[str, Any] | None + ) -> None: ... @property def data(self) -> dict[str, Any]: ... def add_child(self, name: str, info: dict[str, Any]): ... diff --git a/odoo-stubs/modules/loading.pyi b/odoo-stubs/modules/loading.pyi index e545cae..70a003f 100644 --- a/odoo-stubs/modules/loading.pyi +++ b/odoo-stubs/modules/loading.pyi @@ -1,17 +1,38 @@ from typing import Any, Iterable -from .graph import Graph, Node -from .registry import Registry from ..sql_db import Cursor from ..tests.result import OdooTestResult +from .graph import Graph, Node +from .registry import Registry 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 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(registry: Registry, force_demo: bool = ..., status: Any | None = ..., update_module: Any = ...) -> Registry | 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( + registry: 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 22b1740..9eb5a72 100644 --- a/odoo-stubs/modules/migration.pyi +++ b/odoo-stubs/modules/migration.pyi @@ -1,7 +1,7 @@ from types import ModuleType -from .graph import Graph, Node from ..sql_db import Cursor +from .graph import Graph, Node def load_script(path: str, module_name: str) -> ModuleType: ... diff --git a/odoo-stubs/modules/module.pyi b/odoo-stubs/modules/module.pyi index 3854e74..89277b4 100644 --- a/odoo-stubs/modules/module.pyi +++ b/odoo-stubs/modules/module.pyi @@ -24,10 +24,13 @@ class UpgradeHook: def load_module(self, name: str) -> ModuleType | None: ... def initialize_sys_path() -> None: ... -def get_module_path(module: str, downloaded: bool = ..., display_warning: bool = ...) -> str | Literal[False]: ... +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]: ... def check_resource_path(mod_path: str, *args) -> str | Literal[False]: ... + get_module_resource = get_resource_path def get_resource_from_path(path: str) -> tuple[str, str, str] | None: ... @@ -36,7 +39,9 @@ def module_manifest(path: str) -> str | None: ... def get_module_root(path: str) -> str | None: ... def load_manifest(module: str, mod_path: str | None = ...) -> dict[str, Any]: ... def get_manifest(module: str, mod_path: str | None = ...) -> dict[str, Any]: ... -def load_information_from_description_file(module: str, mod_path: str | None = ...) -> dict: ... +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]: ... diff --git a/odoo-stubs/modules/registry.pyi b/odoo-stubs/modules/registry.pyi index 0024b5c..b280848 100644 --- a/odoo-stubs/modules/registry.pyi +++ b/odoo-stubs/modules/registry.pyi @@ -4,13 +4,13 @@ from collections.abc import Mapping from threading import RLock from typing import Any, Callable, ClassVar, Collection, Iterable, Iterator -from .graph import Node -from ..models import BaseModel from ..fields import Field +from ..models import BaseModel from ..sql_db import Connection, Cursor from ..tests.result import OdooTestResult from ..tools import Collector from ..tools.lru import LRU +from .graph import Node class Registry(Mapping[str, type[BaseModel]]): _lock: RLock @@ -18,7 +18,13 @@ class Registry(Mapping[str, type[BaseModel]]): registries: ClassVar[LRU] def __new__(cls, db_name: str) -> Registry: ... @classmethod - def new(cls, db_name: str, force_demo: bool = ..., status: Any | None = ..., update_module: bool = ...) -> Registry: ... + 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 @@ -78,9 +84,21 @@ class Registry(Mapping[str, type[BaseModel]]): _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 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 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: ... @@ -111,7 +129,7 @@ class DummyRLock: def __exit__(self, type, value, traceback) -> None: ... class TriggerTree(dict): - __slots__ = ['root'] + __slots__ = ["root"] root: Any def __init__(self, root: Any = ..., *args, **kwargs) -> None: ... def __bool__(self) -> bool: ... diff --git a/odoo-stubs/netsvc.pyi b/odoo-stubs/netsvc.pyi index 452e196..20abd41 100644 --- a/odoo-stubs/netsvc.pyi +++ b/odoo-stubs/netsvc.pyi @@ -3,7 +3,9 @@ import warnings from logging import Logger, LogRecord from typing import IO, TextIO -def log(logger: Logger, level: int, prefix: str, msg, depth: int | None = ...) -> None: ... +def log( + logger: Logger, level: int, prefix: str, msg, depth: int | None = ... +) -> None: ... class WatchedFileHandler(logging.handlers.WatchedFileHandler): errors: None @@ -31,11 +33,15 @@ COLOR_PATTERN: str LEVEL_COLOR_MAPPING: dict[int, tuple[int, int]] class PerfFilter(logging.Filter): - def format_perf(self, query_count: int, query_time: float, remaining_time: float): ... + def format_perf( + self, query_count: int, query_time: float, remaining_time: float + ): ... def filter(self, record: LogRecord): ... class ColoredPerfFilter(PerfFilter): - def format_perf(self, query_count: int, query_time: float, remaining_time: float): ... + def format_perf( + self, query_count: int, query_time: float, remaining_time: float + ): ... class DBFormatter(logging.Formatter): def format(self, record: LogRecord): ... @@ -52,5 +58,12 @@ PSEUDOCONFIG_MAPPER: dict[str, list[str]] showwarning = warnings.showwarning IGNORE: set[str] -def showwarning_with_traceback(message: Warning | str, category: type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ...): ... +def showwarning_with_traceback( + message: Warning | str, + category: type[Warning], + filename: str, + lineno: int, + file: TextIO | None = ..., + line: str | None = ..., +): ... def runbot(self, message, *args, **kws) -> None: ... diff --git a/odoo-stubs/osv/expression.pyi b/odoo-stubs/osv/expression.pyi index 2d822df..b347c2a 100644 --- a/odoo-stubs/osv/expression.pyi +++ b/odoo-stubs/osv/expression.pyi @@ -1,7 +1,8 @@ from typing import Any, Callable from ..fields import Field -from ..models import BaseModel, MAGIC_COLUMNS as MAGIC_COLUMNS +from ..models import MAGIC_COLUMNS as MAGIC_COLUMNS +from ..models import BaseModel from ..sql_db import Cursor from ..tools.query import Query @@ -43,7 +44,13 @@ class expression: expression: _Domain query: Query | None result: tuple[str, list] - def __init__(self, domain: _Domain, model: BaseModel, alias: str | None = ..., query: Query | None = ...) -> None: ... + def __init__( + self, + domain: _Domain, + model: BaseModel, + alias: str | None = ..., + query: Query | None = ..., + ) -> None: ... def _unaccent(self, field: Field) -> Callable[[Any], str]: ... def get_tables(self) -> tuple[str, ...]: ... def parse(self): ... diff --git a/odoo-stubs/service/__init__.pyi b/odoo-stubs/service/__init__.pyi index c72c784..2d4b73d 100644 --- a/odoo-stubs/service/__init__.pyi +++ b/odoo-stubs/service/__init__.pyi @@ -1,7 +1,5 @@ -from . import ( - common as common, - db as db, - model as model, - server as server, - wsgi_server as wsgi_server -) +from . import common as common +from . import db as db +from . import model as model +from . import server as server +from . import wsgi_server as wsgi_server diff --git a/odoo-stubs/service/common.pyi b/odoo-stubs/service/common.pyi index a8c347a..13d77d7 100644 --- a/odoo-stubs/service/common.pyi +++ b/odoo-stubs/service/common.pyi @@ -4,7 +4,9 @@ from typing import Any, Literal RPC_VERSION_1: dict[str, Any] def exp_login(db: str, login: str, password: str) -> int: ... -def exp_authenticate(db: str, login: str, password: str, user_agent_env: dict | None) -> int: ... +def exp_authenticate( + db: str, login: str, password: str, user_agent_env: dict | None +) -> int: ... def exp_version() -> dict[str, Any]: ... def exp_about(extended: bool = ...) -> str | tuple[str, str]: ... def exp_set_loglevel(loglevel, logger: Logger | None = ...) -> Literal[True]: ... diff --git a/odoo-stubs/service/db.pyi b/odoo-stubs/service/db.pyi index 5e64ad9..30c239d 100644 --- a/odoo-stubs/service/db.pyi +++ b/odoo-stubs/service/db.pyi @@ -1,19 +1,34 @@ from functools import wraps as wraps -from typing import Any, Callable, IO, Iterable, Literal, TypeVar +from typing import IO, Any, Callable, Iterable, Literal, TypeVar from ..sql_db import Cursor -_CallableT = TypeVar('_CallableT', bound=Callable) +_CallableT = TypeVar("_CallableT", bound=Callable) class DatabaseExists(Warning): ... def check_db_management_enabled(method: _CallableT) -> _CallableT: ... def check_super(passwd: str) -> Literal[True]: ... -def _initialize_db(id, db_name: str, demo: bool, lang: str, user_password: str, login: str = ..., - country_code: str | None = ..., phone: str | None = ...) -> None: ... +def _initialize_db( + id, + db_name: str, + demo: bool, + lang: str, + user_password: str, + login: str = ..., + country_code: str | None = ..., + phone: str | None = ..., +) -> None: ... def _create_empty_database(name: str) -> None: ... -def exp_create_database(db_name: str, demo: bool, lang: str, user_password: str = ..., login: str = ..., - country_code: str | None = ..., phone: str | None = ...) -> Literal[True]: ... +def exp_create_database( + db_name: str, + demo: bool, + lang: str, + user_password: str = ..., + login: str = ..., + country_code: str | None = ..., + phone: str | None = ..., +) -> Literal[True]: ... def exp_duplicate_database(db_original_name: str, db_name: str) -> Literal[True]: ... def _drop_conn(cr: Cursor, db_name: str) -> None: ... def exp_drop(db_name: str) -> bool: ... diff --git a/odoo-stubs/service/model.pyi b/odoo-stubs/service/model.pyi index 6895e1b..ba0384f 100644 --- a/odoo-stubs/service/model.pyi +++ b/odoo-stubs/service/model.pyi @@ -9,11 +9,13 @@ from ..sql_db import Cursor PG_CONCURRENCY_ERRORS_TO_RETRY: tuple[str, str, str] MAX_TRIES_ON_CONCURRENCY_FAILURE: int -_CallableT = TypeVar('_CallableT', bound=Callable) +_CallableT = TypeVar("_CallableT", bound=Callable) def dispatch(method: str, params): ... def execute_cr(cr: Cursor, uid: int, obj: str, method: str, *args, **kw): ... -def execute_kw(db: str, uid: int, obj: str, method: str, args, kw: dict | None = ...): ... +def execute_kw( + db: str, uid: int, obj: str, method: str, args, kw: dict | None = ... +): ... def execute(db: str, uid: int, obj: str, method: str, *args, **kw): ... def _as_validation_error(env: Environment, exc: IntegrityError) -> ValidationError: ... def retrying(func: Callable[[], Any], env: Environment): ... diff --git a/odoo-stubs/service/security.pyi b/odoo-stubs/service/security.pyi index 95b514a..9d6c837 100644 --- a/odoo-stubs/service/security.pyi +++ b/odoo-stubs/service/security.pyi @@ -4,5 +4,7 @@ from ..api import Environment from ..http import Session def check(db: str, uid: int, passwd: str) -> None: ... -def compute_session_token(session: Session, env: Environment) -> str | Literal[False]: ... +def compute_session_token( + session: Session, env: Environment +) -> str | Literal[False]: ... def check_session(session: Session, env: Environment) -> bool: ... diff --git a/odoo-stubs/service/server.pyi b/odoo-stubs/service/server.pyi index ffab18c..c4d5683 100644 --- a/odoo-stubs/service/server.pyi +++ b/odoo-stubs/service/server.pyi @@ -1,11 +1,10 @@ +from itertools import chain as chain from socket import socket as socket_ from threading import Semaphore, Thread - -from gevent.pywsgi import WSGIServer -from itertools import chain as chain from typing import Any, Callable, Iterable, Literal, TypeVar import werkzeug.serving +from gevent.pywsgi import WSGIServer from inotify.adapters import InotifyTrees from psutil import Process from watchdog.observers import Observer @@ -13,7 +12,7 @@ from watchdog.observers import Observer from ..modules.registry import Registry from ..sql_db import Cursor -_WorkerT = TypeVar('_WorkerT', bound=Worker) +_WorkerT = TypeVar("_WorkerT", bound=Worker) INOTIFY_LISTEN_EVENTS: Any SLEEP_INTERVAL: int @@ -36,7 +35,9 @@ class RequestHandler(werkzeug.serving.WSGIRequestHandler): close_connection: bool def send_header(self, keyword, value) -> None: ... -class ThreadedWSGIServerReloadable(LoggingBaseWSGIServerMixIn, werkzeug.serving.ThreadedWSGIServer): +class ThreadedWSGIServerReloadable( + LoggingBaseWSGIServerMixIn, werkzeug.serving.ThreadedWSGIServer +): max_http_threads: Any http_threads_sem: Semaphore daemon_threads: bool @@ -128,7 +129,9 @@ class PreforkServer(CommonServer): def pipe_new(self) -> tuple[int, int]: ... def pipe_ping(self, pipe: tuple[int, int]) -> None: ... def signal_handler(self, sig: int, frame) -> None: ... - def worker_spawn(self, klass: Callable[..., _WorkerT], workers_registry: dict[int, _WorkerT]) -> _WorkerT | None: ... + def worker_spawn( + self, klass: Callable[..., _WorkerT], workers_registry: dict[int, _WorkerT] + ) -> _WorkerT | None: ... def long_polling_spawn(self) -> None: ... def worker_pop(self, pid: int) -> None: ... def worker_kill(self, pid: int, sig: int) -> None: ... diff --git a/odoo-stubs/sql_db.pyi b/odoo-stubs/sql_db.pyi index b178cd6..83b7a9b 100644 --- a/odoo-stubs/sql_db.pyi +++ b/odoo-stubs/sql_db.pyi @@ -1,7 +1,17 @@ from datetime import datetime from re import Pattern from threading import Lock, RLock -from typing import Any, Callable, Generator, Iterable, Iterator, Literal, NoReturn, Sequence, TypeVar +from typing import ( + Any, + Callable, + Generator, + Iterable, + Iterator, + Literal, + NoReturn, + Sequence, + TypeVar, +) import psycopg2.extensions from psycopg2.sql import Identifier @@ -9,9 +19,9 @@ from psycopg2.sql import Identifier from .api import Transaction from .tools import Callbacks -_T = TypeVar('_T') -_CursorT = TypeVar('_CursorT', bound=Cursor) -_SavepointT = TypeVar('_SavepointT', bound=Savepoint) +_T = TypeVar("_T") +_CursorT = TypeVar("_CursorT", bound=Cursor) +_SavepointT = TypeVar("_SavepointT", bound=Savepoint) def undecimalize(symb, cr: Cursor) -> float | None: ... @@ -68,7 +78,9 @@ class Cursor(BaseCursor): __caller: tuple[str, int | str] | Literal[False] cache: dict _now: datetime | None - def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict, **kwargs) -> None: ... + def __init__( + self, pool: ConnectionPool, dbname: str, dsn: dict, **kwargs + ) -> None: ... def __build_dict(self, row: Sequence) -> dict[str, Any]: ... def dictfetchone(self) -> dict[str, Any] | None: ... def dictfetchmany(self, size) -> list[dict[str, Any]]: ... @@ -76,7 +88,9 @@ class Cursor(BaseCursor): def __del__(self) -> None: ... def _format(self, query, params: Any | None = ...): ... def execute(self, query, params: Any | None = ..., log_exceptions: bool = ...): ... - def split_for_in_conditions(self, ids: Iterable, size: int | None = ...) -> Iterator[tuple]: ... + def split_for_in_conditions( + self, ids: Iterable, size: int | None = ... + ) -> Iterator[tuple]: ... def print_log(self): ... def _enable_logging(self) -> Generator[None, None, None]: ... def close(self): ... @@ -115,7 +129,9 @@ class ConnectionPool: def __repr__(self) -> str: ... def _debug(self, msg, *args) -> None: ... def borrow(self, connection_info: dict) -> PsycoConnection: ... - def give_back(self, connection: PsycoConnection, keep_in_pool: bool = ...) -> None: ... + def give_back( + self, connection: PsycoConnection, keep_in_pool: bool = ... + ) -> None: ... def close_all(self, dsn: dict | None = ...) -> None: ... def _dsn_equals(self, dsn1, dsn2) -> bool: ... def _dsn_to_dict(self, dsn) -> dict: ... diff --git a/odoo-stubs/tests/__init__.pyi b/odoo-stubs/tests/__init__.pyi index fabbb63..94007b2 100644 --- a/odoo-stubs/tests/__init__.pyi +++ b/odoo-stubs/tests/__init__.pyi @@ -1,2 +1,2 @@ -from .common import * from . import common as common +from .common import * diff --git a/odoo-stubs/tests/case.pyi b/odoo-stubs/tests/case.pyi index 663cb71..2acc875 100644 --- a/odoo-stubs/tests/case.pyi +++ b/odoo-stubs/tests/case.pyi @@ -10,9 +10,11 @@ class _Outcome: success: bool test: Any def __init__(self, test, result) -> None: ... - def testPartExecutor(self, test_case, isTest: bool = ...) -> Generator[None, None, None]: ... + def testPartExecutor( + self, test_case, isTest: bool = ... + ) -> Generator[None, None, None]: ... def _complete_traceback(self, initial_tb): ... - + class TestCase(_TestCase): _class_cleanups: list __unittest_skip__: bool diff --git a/odoo-stubs/tests/common.pyi b/odoo-stubs/tests/common.pyi index ff07092..8617969 100644 --- a/odoo-stubs/tests/common.pyi +++ b/odoo-stubs/tests/common.pyi @@ -11,8 +11,6 @@ import requests from lxml.etree import _Element from websocket import WebSocket -from . import case -from .result import OdooTestResult from ..api import Environment from ..http import Session from ..models import BaseModel @@ -21,11 +19,13 @@ from ..sql_db import BaseCursor, Cursor from ..tools import profiler from ..tools._vendor.sessions import Session from ..tools.profiler import Profiler +from . import case +from .result import OdooTestResult -_T = TypeVar('_T') -_CallableT = TypeVar('_CallableT', bound=Callable) -_ModelT = TypeVar('_ModelT', bound=BaseModel) -_FormT = TypeVar('_FormT', bound=Form) +_T = TypeVar("_T") +_CallableT = TypeVar("_CallableT", bound=Callable) +_ModelT = TypeVar("_ModelT", bound=BaseModel) +_FormT = TypeVar("_FormT", bound=Form) InvalidStateError = Any ADDONS_PATH: str @@ -43,7 +43,13 @@ def standalone(*tags: str) -> Callable[[_CallableT], _CallableT]: ... DB: str -def new_test_user(env: Environment, login: str = ..., groups: str = ..., context: dict | None = ..., **kwargs) -> 'odoo.model.res_users': ... +def new_test_user( + env: Environment, + login: str = ..., + groups: str = ..., + context: dict | None = ..., + **kwargs +) -> "odoo.model.res_users": ... class RecordCapturer: _model: BaseModel @@ -85,14 +91,26 @@ class BaseCase(case.TestCase, metaclass=MetaCase): def startClassPatcher(cls, patcher): ... def with_user(self, login: str) -> None: ... def debug_mode(self) -> Generator[None, None, None]: ... - def _assertRaises(self, exception, *, msg: Any | None = ...) -> Generator[Any, None, None]: ... - def assertRaises(self, exception, func: Any | None = ..., *args, **kwargs) -> Generator[Any, None, None] | None: ... - def assertQueries(self, expected, flush: bool = ...) -> Generator[list, None, None]: ... - def assertQueryCount(self, default: int = ..., flush: bool = ..., **counters) -> Generator[None, None, None]: ... - def assertRecordValues(self, records: BaseModel, expected_values: list[dict[str, Any]]) -> None: ... + def _assertRaises( + self, exception, *, msg: Any | None = ... + ) -> Generator[Any, None, None]: ... + def assertRaises( + self, exception, func: Any | None = ..., *args, **kwargs + ) -> Generator[Any, None, None] | None: ... + def assertQueries( + self, expected, flush: bool = ... + ) -> Generator[list, None, None]: ... + def assertQueryCount( + self, default: int = ..., flush: bool = ..., **counters + ) -> Generator[None, None, None]: ... + def assertRecordValues( + self, records: BaseModel, expected_values: list[dict[str, Any]] + ) -> None: ... def assertItemsEqual(self, a, b, msg: str | None = ...) -> None: ... def assertTreesEqual(self, n1, n2, msg: str | None = ...) -> None: ... - def _assertXMLEqual(self, original: str, expected: str, parser: str = ...) -> None: ... + def _assertXMLEqual( + self, original: str, expected: str, parser: str = ... + ) -> None: ... def assertXMLEqual(self, original: str, expected: str) -> None: ... def assertHTMLEqual(self, original: str, expected: str) -> None: ... profile_session: str @@ -161,23 +179,35 @@ class ChromeBrowser: def _chrome_start(self) -> None: ... dev_tools_frontend_url: str def _find_websocket(self) -> None: ... - def _json_command(self, command: str, timeout: int = ..., get_key: Any | None = ...): ... + def _json_command( + self, command: str, timeout: int = ..., get_key: Any | None = ... + ): ... def _open_websocket(self) -> None: ... def _receive(self, dbname: str) -> None: ... - def _websocket_request(self, method: str, *, params: Any | None = ..., timeout: float = ...): ... - def _websocket_send(self, method: str, *, params: Any | None = ..., with_future: bool = ...) -> Future | None: ... - def _handle_console(self, type, args: Any | None = ..., stackTrace: Any | None = ..., **kw) -> None: ... + def _websocket_request( + self, method: str, *, params: Any | None = ..., timeout: float = ... + ): ... + def _websocket_send( + self, method: str, *, params: Any | None = ..., with_future: bool = ... + ) -> Future | None: ... + def _handle_console( + self, type, args: Any | None = ..., stackTrace: Any | None = ..., **kw + ) -> None: ... def _handle_exception(self, exceptionDetails: dict, timestamp) -> None: ... def _handle_frame_stopped_loading(self, frameId) -> None: ... def _handle_screencast_frame(self, sessionId, data, metadata) -> None: ... _TO_LEVEL: dict[str, int] - def take_screenshot(self, prefix: str = ..., suffix: str | None = ...) -> Future: ... + def take_screenshot( + self, prefix: str = ..., suffix: str | None = ... + ) -> Future: ... def _save_screencast(self, prefix: str = ...) -> None: ... def start_screencast(self) -> None: ... def set_cookie(self, name: str, value, path, domain) -> None: ... def delete_cookie(self, name: str, **kwargs) -> None: ... def _wait_ready(self, ready_code, timeout: int = ...) -> bool: ... - def _wait_code_ok(self, code, timeout: float, error_checker: Any | None = ...) -> None: ... + def _wait_code_ok( + self, code, timeout: float, error_checker: Any | None = ... + ) -> None: ... def navigate_to(self, url: str, wait_stop: bool = ...) -> None: ... def clear(self) -> None: ... def _from_remoteobject(self, arg: Mapping): ... @@ -213,17 +243,37 @@ class HttpCase(TransactionCase): def start_browser(cls) -> None: ... @classmethod def terminate_browser(cls) -> None: ... - def url_open(self, url: str, data: Any | None = ..., files: Mapping | None = ..., timeout: int = ..., - headers: Mapping | None = ..., allow_redirects: bool = ..., head: bool = ...) -> requests.Response: ... + def url_open( + self, + url: str, + data: Any | None = ..., + files: Mapping | None = ..., + timeout: int = ..., + headers: Mapping | None = ..., + allow_redirects: bool = ..., + head: bool = ..., + ) -> requests.Response: ... def _wait_remaining_requests(self, timeout: int = ...) -> None: ... def logout(self, keep_db: bool = ...) -> None: ... session: Session def authenticate(self, user, password) -> Session: ... - def browser_js(self, url_path: str, code: str, ready: str = ..., login: str | None = ..., timeout: int = ..., - cookies: Any | None = ..., error_checker: Any | None = ..., watch: bool = ..., **kw) -> None: ... + def browser_js( + self, + url_path: str, + code: str, + ready: str = ..., + login: str | None = ..., + timeout: int = ..., + cookies: Any | None = ..., + error_checker: Any | None = ..., + watch: bool = ..., + **kw + ) -> None: ... @classmethod def base_url(cls) -> str: ... - def start_tour(self, url_path: str, tour_name: str, step_delay: float | None = ..., **kwargs) -> None: ... + def start_tour( + self, url_path: str, tour_name: str, step_delay: float | None = ..., **kwargs + ) -> None: ... def profile(self, **kwargs) -> profiler.Nested: ... class HttpSavepointCase(HttpCase): @@ -243,14 +293,24 @@ class Form(Generic[_ModelT]): _changed: set def __init__(self, recordp: _ModelT, view: _ModelT | str | None = ...) -> None: ... def _get_view_fields(self, node: _Element, model: BaseModel) -> dict: ... - def _o2m_set_edition_view(self, descr: dict, node: _Element, level: int) -> None: ... + def _o2m_set_edition_view( + self, descr: dict, node: _Element, level: int + ) -> None: ... def __str__(self) -> str: ... def _process_fvg(self, model: BaseModel, fvg: dict, level: int = ...) -> None: ... def _init_from_defaults(self, model: BaseModel) -> None: ... def _init_from_values(self, values: BaseModel) -> None: ... def __getattr__(self, field: str): ... - def _get_modifier(self, field: str, modifier: str, *, default: Any = ..., view: Any = ..., modmap: Any | None = ..., - vals: Any | None = ...): ... + def _get_modifier( + self, + field: str, + modifier: str, + *, + default: Any = ..., + view: Any = ..., + modmap: Any | None = ..., + vals: Any | None = ... + ): ... _OPS: dict[str, Callable[..., bool]] def _get_context(self, field: str): ... def __setattr__(self, field: str, value) -> None: ... @@ -258,9 +318,19 @@ class Form(Generic[_ModelT]): def __exit__(self, etype, _evalue, _etb) -> None: ... def save(self) -> _ModelT: ... def _values_to_save(self, all_fields: bool = ...) -> dict: ... - def _values_to_save_(self, record_values: dict, fields: dict, view: Any, changed: set, all_fields: bool = ..., - modifiers_values: dict | None = ..., parent_link: Any | None = ...) -> dict: ... - def _perform_onchange(self, fields: list[str], context: dict | None = ...) -> dict: ... + def _values_to_save_( + self, + record_values: dict, + fields: dict, + view: Any, + changed: set, + all_fields: bool = ..., + modifiers_values: dict | None = ..., + parent_link: Any | None = ..., + ) -> dict: ... + def _perform_onchange( + self, fields: list[str], context: dict | None = ... + ) -> dict: ... def _onchange_values(self) -> dict: ... def _onchange_values_(self, fields, record: dict) -> dict: ... def _cleanup_onchange(self, descr: dict, value, current): ... @@ -269,8 +339,16 @@ class O2MForm(Form): _proxy: O2MProxy _index: int | None def __init__(self, proxy: O2MProxy, index: int | None = ...) -> None: ... - def _get_modifier(self, field: str, modifier: str, *, default: Any = ..., view: Any = ..., modmap: Any | None = ..., - vals: Any | None = ...): ... + def _get_modifier( + self, + field: str, + modifier: str, + *, + default: Any = ..., + view: Any = ..., + modmap: Any | None = ..., + vals: Any | None = ... + ): ... def _onchange_values(self) -> dict: ... def save(self) -> None: ... def _values_to_save(self, all_fields: bool = ...) -> UpdateDict: ... diff --git a/odoo-stubs/tests/result.pyi b/odoo-stubs/tests/result.pyi index 4dfdb66..9e1bb8d 100644 --- a/odoo-stubs/tests/result.pyi +++ b/odoo-stubs/tests/result.pyi @@ -28,7 +28,12 @@ class OdooTestResult: _soft_fail: bool had_failure: bool stats: dict[str, Stat] - def __init__(self, stream: Any | None = ..., descriptions: Any | None = ..., verbosity: Any | None = ...) -> None: ... + def __init__( + self, + stream: Any | None = ..., + descriptions: Any | None = ..., + verbosity: Any | None = ..., + ) -> None: ... def printErrors(self) -> None: ... def startTest(self, test) -> None: ... def stopTest(self, test) -> None: ... @@ -45,7 +50,17 @@ class OdooTestResult: def __str__(self) -> str: ... def soft_fail(self) -> Generator[None, None, None]: ... def update(self, other) -> None: ... - def log(self, level, msg, *args, test: Any | None = ..., exc_info: Any | None = ..., extra: Any | None = ..., stack_info: bool = ..., caller_infos: Any | None = ...) -> None: ... + def log( + self, + level, + msg, + *args, + test: Any | None = ..., + exc_info: Any | None = ..., + extra: Any | None = ..., + stack_info: bool = ..., + caller_infos: Any | None = ... + ) -> None: ... def log_stats(self) -> None: ... def getDescription(self, test) -> str: ... def collectStats(self, test_id) -> Generator[None, None, None]: ... diff --git a/odoo-stubs/tests/suite.pyi b/odoo-stubs/tests/suite.pyi index 56010be..d131578 100644 --- a/odoo-stubs/tests/suite.pyi +++ b/odoo-stubs/tests/suite.pyi @@ -6,7 +6,9 @@ __unittest: bool class TestSuite(BaseTestSuite): def run(self, result, debug: bool = ...): ... def _handleClassSetUp(self, test, result) -> None: ... - def _createClassOrModuleLevelException(self, result, exception, method_name, parent, info: Any | None = ...) -> None: ... + def _createClassOrModuleLevelException( + self, result, exception, method_name, parent, info: Any | None = ... + ) -> None: ... def _tearDownPreviousClass(self, test, result) -> None: ... class _ErrorHolder: diff --git a/odoo-stubs/tools/__init__.pyi b/odoo-stubs/tools/__init__.pyi index a8e8350..babbe8c 100644 --- a/odoo-stubs/tools/__init__.pyi +++ b/odoo-stubs/tools/__init__.pyi @@ -1,30 +1,27 @@ +from . import appdirs as appdirs +from . import cloc as cloc +from . import osutil as osutil +from . import pdf as pdf +from . import pycompat as pycompat from .barcode import * +from .config import config as config +from .convert import * from .date_utils import * from .float_utils import * from .func import * from .image import * +from .js_transpiler import ODOO_MODULE_RE as ODOO_MODULE_RE +from .js_transpiler import URL_RE as URL_RE +from .js_transpiler import is_odoo_module as is_odoo_module +from .js_transpiler import transpile_javascript as transpile_javascript from .mail import * from .misc import * +from .query import Query as Query +from .query import _generate_table_alias as _generate_table_alias +from .sourcemap_generator import SourceMapGenerator as SourceMapGenerator from .sql import * from .template_inheritance import * from .translate import * from .xml_utils import * -from .convert import * -from . import ( - appdirs as appdirs, - cloc as cloc, - osutil as osutil, - pdf as pdf, - pycompat as pycompat -) -from .config import config as config -from .js_transpiler import ( - ODOO_MODULE_RE as ODOO_MODULE_RE, - URL_RE as URL_RE, - is_odoo_module as is_odoo_module, - transpile_javascript as transpile_javascript -) -from .query import Query as Query, _generate_table_alias as _generate_table_alias -from .sourcemap_generator import SourceMapGenerator as SourceMapGenerator SUPPORTED_DEBUGGER: set[str] diff --git a/odoo-stubs/tools/_vendor/send_file.pyi b/odoo-stubs/tools/_vendor/send_file.pyi index 1fc41b0..6df8ef9 100644 --- a/odoo-stubs/tools/_vendor/send_file.pyi +++ b/odoo-stubs/tools/_vendor/send_file.pyi @@ -1,20 +1,20 @@ from datetime import datetime from os import PathLike -from typing import Callable, IO +from typing import IO, Callable from werkzeug import Response def send_file( - path_or_file: PathLike | str | IO[bytes], - environ: dict, - mimetype: str | None = ..., - as_attachment: bool = ..., - download_name: str | None = ..., - conditional: bool = ..., - etag: bool | str = ..., - last_modified: datetime | int | float | None = ..., - max_age: int | Callable[[str | None], int | None] | None = ..., - use_x_sendfile: bool = ..., - response_class: type[Response] = ..., - _root_path: PathLike | str | None = ..., + path_or_file: PathLike | str | IO[bytes], + environ: dict, + mimetype: str | None = ..., + as_attachment: bool = ..., + download_name: str | None = ..., + conditional: bool = ..., + etag: bool | str = ..., + last_modified: datetime | int | float | None = ..., + max_age: int | Callable[[str | None], int | None] | None = ..., + use_x_sendfile: bool = ..., + response_class: type[Response] = ..., + _root_path: PathLike | str | None = ..., ) -> Response: ... diff --git a/odoo-stubs/tools/_vendor/sessions.pyi b/odoo-stubs/tools/_vendor/sessions.pyi index ada438c..b969c9a 100644 --- a/odoo-stubs/tools/_vendor/sessions.pyi +++ b/odoo-stubs/tools/_vendor/sessions.pyi @@ -3,22 +3,24 @@ from typing import Any, Generic, TypeVar from werkzeug.datastructures import CallbackDict -_ModificationTrackingDictT = TypeVar('_ModificationTrackingDictT', bound=ModificationTrackingDict) -_SessionT = TypeVar('_SessionT', bound=Session) +_ModificationTrackingDictT = TypeVar( + "_ModificationTrackingDictT", bound=ModificationTrackingDict +) +_SessionT = TypeVar("_SessionT", bound=Session) _sha1_re: Pattern def generate_key(salt: Any = ...) -> str: ... class ModificationTrackingDict(CallbackDict): - __slots__ = ('modified',) + __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') + __slots__ = ("modified", "sid", "new") sid: str new: bool def __init__(self, data, sid, new: bool = ...): ... @@ -44,8 +46,14 @@ class FilesystemSessionStore(SessionStore[_SessionT]): 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 __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: ... diff --git a/odoo-stubs/tools/_vendor/useragents.pyi b/odoo-stubs/tools/_vendor/useragents.pyi index 605c19b..95fab1f 100644 --- a/odoo-stubs/tools/_vendor/useragents.pyi +++ b/odoo-stubs/tools/_vendor/useragents.pyi @@ -6,7 +6,9 @@ class UserAgentParser(object): _browser_version_re: str _language_re: Pattern def __init__(self) -> None: ... - def __call__(self, user_agent: str) -> tuple[str | None, str | None, str | None, str | None]: ... + def __call__( + self, user_agent: str + ) -> tuple[str | None, str | None, str | None, str | None]: ... class UserAgent(object): _parser: UserAgentParser diff --git a/odoo-stubs/tools/appdirs.pyi b/odoo-stubs/tools/appdirs.pyi index 0b6cd4b..c06bd7b 100644 --- a/odoo-stubs/tools/appdirs.pyi +++ b/odoo-stubs/tools/appdirs.pyi @@ -3,12 +3,42 @@ from typing import Callable __version_info__: tuple __version__: str -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: ... +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: str @@ -16,7 +46,14 @@ class AppDirs: version: str | None roaming: bool multipath: bool - def __init__(self, appname: str, appauthor: str | None = ..., version: str | None = ..., roaming: bool = ..., multipath: bool = ...) -> None: ... + def __init__( + self, + appname: str, + appauthor: str | None = ..., + version: str | None = ..., + roaming: bool = ..., + multipath: bool = ..., + ) -> None: ... @property def user_data_dir(self) -> str: ... @property @@ -33,4 +70,5 @@ class AppDirs: 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 55b9495..c2ee8ce 100644 --- a/odoo-stubs/tools/cache.pyi +++ b/odoo-stubs/tools/cache.pyi @@ -1,11 +1,11 @@ from collections import defaultdict from typing import Any, Callable, TypeVar -from .lru import LRU from ..models import BaseModel +from .lru import LRU -_T = TypeVar('_T') -_CallableT = TypeVar('_CallableT') +_T = TypeVar("_T") +_CallableT = TypeVar("_CallableT") unsafe_eval = eval @@ -27,7 +27,9 @@ class ormcache: def __call__(self, method: _CallableT) -> _CallableT: ... key: Any def determine_key(self): ... - def lru(self, model: BaseModel) -> tuple[LRU, tuple[str, Callable], ormcache_counter]: ... + def lru( + self, model: BaseModel + ) -> tuple[LRU, tuple[str, Callable], ormcache_counter]: ... def lookup(self, method: Callable, *args, **kwargs): ... def clear(self, model: BaseModel, *args) -> None: ... @@ -52,4 +54,5 @@ class dummy_cache: 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 e9ce118..e7a8291 100644 --- a/odoo-stubs/tools/cloc.pyi +++ b/odoo-stubs/tools/cloc.pyi @@ -24,7 +24,13 @@ class Cloc: def parse_scss(self, s: str) -> tuple[int, int]: ... def parse_css(self, s: str) -> tuple[int, int]: ... def parse(self, s: str, ext: str) -> tuple[int, int]: ... - def book(self, module: str, item: str = ..., count: tuple[Any, Any] = ..., exclude: bool = ...) -> None: ... + 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: ... diff --git a/odoo-stubs/tools/config.pyi b/odoo-stubs/tools/config.pyi index 20bfb85..29e42ad 100644 --- a/odoo-stubs/tools/config.pyi +++ b/odoo-stubs/tools/config.pyi @@ -28,10 +28,16 @@ class configmanager: def _parse_config(self, args: list | None = ...): ... def _warn_deprecated_options(self) -> 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 _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 _test_enable_callback( + self, option: MyOption, opt, value, parser: OptionParser + ) -> None: ... def load(self) -> None: ... def save(self, keys: Any | None = ...) -> None: ... def get(self, key, default: Any | None = ...): ... diff --git a/odoo-stubs/tools/convert.pyi b/odoo-stubs/tools/convert.pyi index 1222285..aafe248 100644 --- a/odoo-stubs/tools/convert.pyi +++ b/odoo-stubs/tools/convert.pyi @@ -3,13 +3,15 @@ from typing import Any, Callable, TextIO from lxml.etree import _Element -from .misc import ustr as ustr from ..api import Environment from ..sql_db import Cursor +from .misc import ustr as ustr __all__ = [ - 'convert_file', 'convert_sql_import', - 'convert_csv_import', 'convert_xml_import' + "convert_file", + "convert_sql_import", + "convert_csv_import", + "convert_xml_import", ] safe_eval: Callable @@ -28,7 +30,9 @@ def str2bool(value) -> bool: ... def nodeattr2bool(node: _Element, attr, default: bool = ...) -> bool: ... class xml_import: - def get_env(self, node: _Element, eval_context: dict | None = ...) -> Environment: ... + 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: ... @@ -36,10 +40,14 @@ class xml_import: 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, extra_vals: dict | None = ...) -> tuple[str, int] | None: ... + def _tag_record( + self, rec: _Element, extra_vals: dict | None = ... + ) -> 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 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) -> Environment: ... @@ -52,11 +60,44 @@ class xml_import: _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 __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: Cursor, module: str, filename: str, idref: dict, mode: str = ..., noupdate: bool = ..., kind: str | None = ..., pathname: str | None = ...) -> 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: ... +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 bbf8cc2..d7bef90 100644 --- a/odoo-stubs/tools/date_utils.pyi +++ b/odoo-stubs/tools/date_utils.pyi @@ -1,18 +1,22 @@ import datetime -from typing import Tuple, Iterator, TypeVar +from typing import Iterator, Tuple, TypeVar from dateutil.relativedelta import relativedelta -_DateTimeT = TypeVar('_DateTimeT', datetime.date, datetime.datetime) +_DateTimeT = TypeVar("_DateTimeT", datetime.date, datetime.datetime) def get_month(date: _DateTimeT) -> Tuple[_DateTimeT, _DateTimeT]: ... def get_quarter_number(date: _DateTimeT) -> int: ... def get_quarter(date: _DateTimeT) -> Tuple[_DateTimeT, _DateTimeT]: ... -def get_fiscal_year(date: _DateTimeT, day: int = ..., month: int = ...) -> Tuple[_DateTimeT, _DateTimeT]: ... +def get_fiscal_year( + date: _DateTimeT, day: int = ..., month: int = ... +) -> Tuple[_DateTimeT, _DateTimeT]: ... def get_timedelta(qty: int, granularity: str) -> relativedelta: ... def start_of(value: _DateTimeT, granularity: str) -> _DateTimeT: ... def end_of(value: _DateTimeT, granularity: str) -> _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]: ... +def date_range( + start: datetime.datetime, end: datetime.datetime, step: relativedelta = ... +) -> Iterator[datetime.datetime]: ... diff --git a/odoo-stubs/tools/float_utils.pyi b/odoo-stubs/tools/float_utils.pyi index 38dbba7..fdec442 100644 --- a/odoo-stubs/tools/float_utils.pyi +++ b/odoo-stubs/tools/float_utils.pyi @@ -1,10 +1,30 @@ 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_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: float, precision_digits: int) -> tuple[str, str]: ... def float_split(value: float, precision_digits: int) -> tuple[int, int]: ... -def json_float_round(value: float, precision_digits: int, rounding_method: str = ...) -> float: ... +def json_float_round( + value: float, precision_digits: int, rounding_method: str = ... +) -> float: ... diff --git a/odoo-stubs/tools/func.pyi b/odoo-stubs/tools/func.pyi index 499501a..6a42a91 100644 --- a/odoo-stubs/tools/func.pyi +++ b/odoo-stubs/tools/func.pyi @@ -1,7 +1,7 @@ from json import JSONEncoder as JSONEncoder from typing import Callable, Generic, TypeVar -_T = TypeVar('_T') +_T = TypeVar("_T") class lazy_property(Generic[_T]): fget: Callable[..., _T] @@ -30,7 +30,7 @@ class _ClassProperty(property, Generic[_T]): def classproperty(func: Callable[..., _T]) -> _ClassProperty[_T]: ... class lazy: - __slots__ = ['_func', '_args', '_kwargs', '_cached_value'] + __slots__ = ["_func", "_args", "_kwargs", "_cached_value"] def __init__(self, func, *args, **kwargs) -> None: ... @property def _value(self): ... diff --git a/odoo-stubs/tools/image.pyi b/odoo-stubs/tools/image.pyi index 1aa0b35..d498aba 100644 --- a/odoo-stubs/tools/image.pyi +++ b/odoo-stubs/tools/image.pyi @@ -1,6 +1,7 @@ -from PIL import IcoImagePlugin as IcoImagePlugin, ImageOps as ImageOps from typing import Any, Iterable, Literal +from PIL import IcoImagePlugin as IcoImagePlugin +from PIL import ImageOps as ImageOps from PIL.Image import Image FILETYPE_BASE64_MAGICWORD: dict[bytes, str] @@ -14,13 +15,31 @@ class ImageProcess: image: Image | Literal[False] original_format: str def __init__(self, source: bytes, verify_resolution: bool = ...) -> None: ... - def image_quality(self, quality: int = ..., output_format: str = ...) -> bytes | Literal[False]: ... + def image_quality( + 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 crop_resize( + self, + max_width: int, + max_height: int, + center_x: float = ..., + center_y: float = ..., + ) -> ImageProcess: ... def colorize(self) -> ImageProcess: ... -def image_process(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_process( + 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 binary_to_image(source: bytes) -> Image: ... def base64_to_image(base64_source: bytes) -> Image: ... diff --git a/odoo-stubs/tools/js_transpiler.pyi b/odoo-stubs/tools/js_transpiler.pyi index 2584878..86fb182 100644 --- a/odoo-stubs/tools/js_transpiler.pyi +++ b/odoo-stubs/tools/js_transpiler.pyi @@ -17,7 +17,8 @@ def convert_export_class(content: str) -> str: ... EXPORT_FCT_DEFAULT_RE: Pattern -def convert_export_function_default(content: str): str: ... +def convert_export_function_default(content: str): + str: ... EXPORT_CLASS_DEFAULT_RE: Pattern diff --git a/odoo-stubs/tools/lru.pyi b/odoo-stubs/tools/lru.pyi index 66ba2ff..1d7e6e8 100644 --- a/odoo-stubs/tools/lru.pyi +++ b/odoo-stubs/tools/lru.pyi @@ -2,7 +2,7 @@ from collections import OrderedDict from threading import RLock from typing import Any -__all__ = ['LRU'] +__all__ = ["LRU"] class LRU: _lock: RLock diff --git a/odoo-stubs/tools/mail.pyi b/odoo-stubs/tools/mail.pyi index ef61040..ee6d695 100644 --- a/odoo-stubs/tools/mail.pyi +++ b/odoo-stubs/tools/mail.pyi @@ -19,9 +19,19 @@ class _Cleaner(clean.Cleaner): def parse_style(self, el: _Element) -> None: ... def tag_quote(el: _Element) -> None: ... -def html_normalize(src: str, filter_callback: Callable[[_Element], _Element] | None = ...) -> str: ... -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: ... +def html_normalize( + src: str, filter_callback: Callable[[_Element], _Element] | None = ... +) -> str: ... +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 @@ -33,9 +43,17 @@ def validate_url(url: str) -> str: ... def is_html_empty(html_content: str) -> bool: ... def html_keep_url(text: str) -> str: ... def html_to_inner_content(html: str) -> str: ... -def html2plaintext(html: str, body_id: str | None = ..., encoding: 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 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: Pattern @@ -52,6 +70,8 @@ def email_domain_extract(email: str) -> str | Literal[False]: ... def email_domain_normalize(domain: str) -> str | Literal[False]: ... def url_domain_extract(url: str) -> str | Literal[False]: ... def email_escape_char(email_address: str) -> str: ... -def decode_message_header(message: Message, header: str, separator: str = ...) -> str: ... +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 5609854..cf3a1ac 100644 --- a/odoo-stubs/tools/mimetypes.pyi +++ b/odoo-stubs/tools/mimetypes.pyi @@ -2,7 +2,7 @@ import collections from re import Pattern from typing import Any, Literal -__all__ = ['guess_mimetype'] +__all__ = ["guess_mimetype"] _ooxml_dirs: dict[str, str] def _check_ooxml(data: bytes) -> str | Literal[False]: ... @@ -17,7 +17,7 @@ _ppt_pattern: Pattern def _check_olecf(data: bytes) -> str | Literal[False]: ... def _check_svg(data: bytes) -> str | None: ... -_Entry = collections.namedtuple('_Entry', ['mimetype', 'signatures', 'discriminants']) +_Entry = collections.namedtuple("_Entry", ["mimetype", "signatures", "discriminants"]) _mime_mappings: tuple[_Entry, ...] def _odoo_guess_mimetype(bin_data: str, default: str = ...) -> str: ... @@ -26,7 +26,5 @@ _guesser: Any ms: Any def guess_mimetype(bin_data: str, default: str | None = ...) -> str: ... - -def neuter_mimetype(mimetype: str, user: 'odoo.model.res_users') -> str: ... - +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 fe01946..ec3cd91 100644 --- a/odoo-stubs/tools/misc.pyi +++ b/odoo-stubs/tools/misc.pyi @@ -6,7 +6,19 @@ from contextlib import ContextDecorator, suppress from logging import Handler, LogRecord from re import Pattern from types import ModuleType -from typing import Any, Collection, Generic, IO, AnyStr, ItemsView, Iterable, Iterator, NoReturn, TypeVar, Callable +from typing import ( + IO, + Any, + AnyStr, + Callable, + Collection, + Generic, + ItemsView, + Iterable, + Iterator, + NoReturn, + TypeVar, +) import markupsafe import xlsxwriter @@ -14,34 +26,45 @@ import xlwt from babel.core import Locale from xlwt import Worksheet +from ..api import Environment +from ..loglevels import exception_to_unicode as exception_to_unicode +from ..loglevels import get_encodings as get_encodings 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 -_T = TypeVar('_T') -_T1 = TypeVar('_T1') -_KT = TypeVar('_KT') -_VT = TypeVar('_VT') -_CallableT = TypeVar('_CallableT', bound=Callable) -_LowerLoggingT = TypeVar('_LowerLoggingT', bound=lower_logging) -_ReplaceExceptionsT = TypeVar('_ReplaceExceptionsT', bound=replace_exceptions) +_T = TypeVar("_T") +_T1 = TypeVar("_T1") +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") +_CallableT = TypeVar("_CallableT", bound=Callable) +_LowerLoggingT = TypeVar("_LowerLoggingT", bound=lower_logging) +_ReplaceExceptionsT = TypeVar("_ReplaceExceptionsT", bound=replace_exceptions) 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 _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 exec_pg_command_pipe( + name: str, *args +) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... def file_path(file_path: str, filter_ext: tuple[str, ...] = ...) -> str: ... -def file_open(name: str, mode: str = ..., filter_ext: tuple[str, ...] | None = ...) -> IO: ... +def file_open( + name: str, mode: str = ..., filter_ext: tuple[str, ...] | None = ... +) -> IO: ... def flatten(list) -> list: ... def reverse_enumerate(l): ... -def partition(pred: Callable[[_T], bool], elems: Iterable[_T]) -> tuple[list[_T], list[_T]]: ... +def partition( + pred: Callable[[_T], bool], elems: Iterable[_T] +) -> tuple[list[_T], list[_T]]: ... def topological_sort(elems: dict[_T, Any]) -> list[_T]: ... def merge_sequences(*iterables: Iterable[_T]) -> list[_T]: ... @@ -74,7 +97,9 @@ DATETIME_FORMATS_MAP: dict[str, str] POSIX_TO_LDML: dict[str, str] 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 split_every( + n: int, iterable: Iterable[_T], piece_maker: Callable[[Iterable[_T]], _T1] = ... +) -> Iterator[_T1]: ... raise_error: object @@ -91,7 +116,12 @@ class mute_logger(Handler): old_params: dict[str, tuple[list[Handler], bool]] def __init__(self, *loggers: str) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, exc_type: Any | None = ..., exc_val: Any | None = ..., exc_tb: Any | None = ...) -> None: ... + def __exit__( + self, + exc_type: Any | None = ..., + exc_val: Any | None = ..., + exc_tb: Any | None = ..., + ) -> None: ... def __call__(self, func: _CallableT) -> _CallableT: ... def emit(self, record: LogRecord) -> None: ... @@ -103,7 +133,12 @@ class lower_logging(Handler): to_level: int | None def __init__(self, max_level: int, to_level: int | None = ...) -> None: ... def __enter__(self: _LowerLoggingT) -> _LowerLoggingT: ... - def __exit__(self, exc_type: Any | None = ..., exc_val: Any | None = ..., exc_tb: Any | None = ...) -> None: ... + def __exit__( + self, + exc_type: Any | None = ..., + exc_val: Any | None = ..., + exc_tb: Any | None = ..., + ) -> None: ... def emit(self, record: LogRecord) -> None: ... _ph: Any @@ -120,14 +155,16 @@ class CountingStream(Generic[_T]): def stripped_sys_argv(*strip_args: str) -> list[str]: ... class ConstantMapping(Mapping[_KT, _VT]): - __slots__ = ['_value'] + __slots__ = ["_value"] _value: _VT def __init__(self, val: _VT) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator: ... def __getitem__(self, item) -> _VT: ... -def dumpstacks(sig: Any | None = ..., frame: Any | None = ..., thread_idents: Any | None = ...) -> None: ... +def 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]: ... @@ -150,7 +187,7 @@ class Collector(dict[_KT, tuple[_T]]): def discard_keys_and_values(self, excludes: Collection): ... class StackMap(MutableMapping): - __slots__ = ['_maps'] + __slots__ = ["_maps"] _maps: list[MutableMapping] def __init__(self, m: MutableMapping | None = ...) -> None: ... def __getitem__(self, key): ... @@ -163,7 +200,7 @@ class StackMap(MutableMapping): def popmap(self) -> MutableMapping: ... class OrderedSet(MutableSet): - __slots__ = ['_map'] + __slots__ = ["_map"] _map: dict def __init__(self, elems: Iterable = ...) -> None: ... def __contains__(self, elem) -> bool: ... @@ -179,7 +216,7 @@ class LastOrderedSet(OrderedSet): def add(self, elem) -> None: ... class Callbacks: - __slots__ = ['_funcs', 'data'] + __slots__ = ["_funcs", "data"] _funcs: deque data: dict def __init__(self) -> None: ... @@ -188,18 +225,20 @@ class Callbacks: def clear(self) -> None: ... class ReversedIterable(Generic[_T]): - __slots__ = ['iterable'] + __slots__ = ["iterable"] iterable: Iterable[_T] def __init__(self, iterable: Iterable[_T]) -> None: ... def __iter__(self) -> Iterator[_T]: ... def __reversed__(self) -> Iterator[_T]: ... -def groupby(iterable: Iterable[_T], key: Callable[..., _T1] | None = ...) -> ItemsView[_T1, _T]: ... +def groupby( + iterable: Iterable[_T], key: Callable[..., _T1] | None = ... +) -> ItemsView[_T1, _T]: ... def unique(it: Iterable[_T]) -> Iterator[_T]: ... def submap(mapping: Mapping[_KT, _VT], keys: Iterable[_KT]) -> dict[_KT, _VT]: ... class Reverse: - __slots__ = ['val'] + __slots__ = ["val"] val: Any def __init__(self, val) -> None: ... def __eq__(self, other) -> bool: ... @@ -220,21 +259,50 @@ class replace_exceptions(ContextDecorator): html_escape = markupsafe.escape -def get_lang(env: Environment, lang_code: str = ...) -> 'odoo.model.res_lang': ... +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 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_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_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: ... consteq: Callable[[str, str], bool] @@ -243,18 +311,24 @@ _PICKLE_SAFE_NAMES: dict class Unpickler(pickle_.Unpickler): def find_class(self, module_name: str, name: str): ... -def _pickle_load(stream: pickle_._ReadableFileobj, encoding: str = ..., errors: bool = ...): ... +def _pickle_load( + stream: pickle_._ReadableFileobj, encoding: str = ..., errors: bool = ... +): ... pickle: ModuleType class DotDict(dict): def __getattr__(self, attrib): ... -def get_diff(data_from: tuple[str, str], data_to: tuple[str, str], custom_style: bool = ...) -> str: ... -def hmac(env: Environment, scope, message, hash_function = ...) -> str: ... +def get_diff( + data_from: tuple[str, str], data_to: tuple[str, str], custom_style: bool = ... +) -> str: ... +def hmac(env: Environment, scope, message, hash_function=...) -> str: ... ADDRESS_REGEX: Pattern def street_split(street: str) -> dict[str, str]: ... def is_list_of(values: list | tuple, type_: type | tuple[type, ...]) -> bool: ... -def has_list_types(values: list | tuple, types: Collection[type | tuple[type, ...]]) -> bool: ... \ No newline at end of file +def has_list_types( + values: list | tuple, types: Collection[type | tuple[type, ...]] +) -> bool: ... diff --git a/odoo-stubs/tools/osutil.pyi b/odoo-stubs/tools/osutil.pyi index db61ab9..4a386cb 100644 --- a/odoo-stubs/tools/osutil.pyi +++ b/odoo-stubs/tools/osutil.pyi @@ -5,6 +5,11 @@ WINDOWS_RESERVED: Pattern def clean_filename(name: str, replacement: str = ...) -> str: ... def listdir(dir: str, recursive: bool = ...) -> Iterable[str]: ... -def zip_dir(path: str, stream: str | BinaryIO, include_dir: bool = ..., fnct_sort: Callable | None = ...) -> None: ... +def zip_dir( + path: str, + stream: str | BinaryIO, + include_dir: bool = ..., + fnct_sort: Callable | None = ..., +) -> None: ... is_running_as_nt_service: Callable[[], bool] diff --git a/odoo-stubs/tools/pdf.pyi b/odoo-stubs/tools/pdf.pyi index 40741dd..c79a725 100644 --- a/odoo-stubs/tools/pdf.pyi +++ b/odoo-stubs/tools/pdf.pyi @@ -3,7 +3,8 @@ from re import Pattern from typing import Any, BinaryIO, Iterable from PyPDF2 import PdfFileReader, PdfFileWriter -from PyPDF2.generic import ArrayObject as ArrayObject, IndirectObject +from PyPDF2.generic import ArrayObject as ArrayObject +from PyPDF2.generic import IndirectObject from PyPDF2.utils import b_ as b_ DEFAULT_PDF_DATETIME_FORMAT: str @@ -14,12 +15,18 @@ def _unwrapping_get(self, key, default: Any | None = ...): ... class BrandedFileWriter(PdfFileWriter): def __init__(self) -> None: ... + PdfFileWriter = BrandedFileWriter def merge_pdf(pdf_data: Iterable[bytes]) -> bytes: ... def rotate_pdf(pdf: bytes) -> bytes: ... -def to_pdf_stream(attachment: 'odoo.model.ir_attachment') -> BytesIO: ... -def add_banner(pdf_stream: str | BinaryIO, text: str | None = ..., logo: bool = ..., thickness: float = ...) -> BytesIO: ... +def to_pdf_stream(attachment: "odoo.model.ir_attachment") -> BytesIO: ... +def add_banner( + pdf_stream: str | BinaryIO, + text: str | None = ..., + logo: bool = ..., + thickness: float = ..., +) -> BytesIO: ... class OdooPdfFileReader(PdfFileReader): def getAttachments(self) -> Iterable[tuple[Any, Any]]: ... @@ -29,10 +36,15 @@ class OdooPdfFileWriter(PdfFileWriter): is_pdfa: bool _header: bytes _ID: Any - def __init__(self, *args, **kwargs): None + 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 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: ... + 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 8a8e6c7..2339a8d 100644 --- a/odoo-stubs/tools/populate.pyi +++ b/odoo-stubs/tools/populate.pyi @@ -6,21 +6,51 @@ from dateutil.relativedelta import relativedelta from ..tools import pycompat as pycompat -_T = TypeVar('_T') +_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 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]]: ... -def randfloat(a: float, b: float, seed: Any | None = ...) -> Callable[[Iterable, str, str], Iterator[dict]]: ... -def randdatetime(*, base_date: datetime.datetime | None = ..., relative_before: datetime.timedelta | relativedelta | None = ..., - relative_after: datetime.timedelta | relativedelta | None = ..., seed: Any | None = ...) -> Callable[[Iterable, str, str], 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]]: ... +def randfloat( + a: float, b: float, seed: Any | None = ... +) -> Callable[[Iterable, str, str], Iterator[dict]]: ... +def randdatetime( + *, + base_date: datetime.datetime | None = ..., + relative_before: datetime.timedelta | relativedelta | None = ..., + relative_after: datetime.timedelta | relativedelta | None = ..., + seed: Any | None = ... +) -> Callable[[Iterable, str, str], Iterator[dict]]: ... diff --git a/odoo-stubs/tools/profiler.pyi b/odoo-stubs/tools/profiler.pyi index 95b0894..9ca013e 100644 --- a/odoo-stubs/tools/profiler.pyi +++ b/odoo-stubs/tools/profiler.pyi @@ -5,7 +5,7 @@ from typing import Any, Callable, ContextManager, Generic, Iterable, TypeVar from ..sql_db import Cursor -_T = TypeVar('_T') +_T = TypeVar("_T") real_datetime_now: Callable[..., datetime] real_time: Callable[[], float] @@ -13,7 +13,9 @@ real_time: Callable[[], float] def _format_frame(frame: FrameType) -> tuple[str, int, str, str]: ... def _format_stack(stack: Iterable) -> list[list]: ... def get_current_frame(thread: Thread | None = ...) -> FrameType: ... -def _get_stack_trace(frame: FrameType, limit_frame: FrameType | None = ...) -> list[tuple[str, int, str, str]]: ... +def _get_stack_trace( + frame: FrameType, limit_frame: FrameType | None = ... +) -> list[tuple[str, int, str, str]]: ... def stack_size() -> int: ... def make_session(name: str = ...) -> str: ... def force_hook() -> None: ... @@ -32,7 +34,9 @@ class Collector: def start(self) -> None: ... def stop(self) -> None: ... def add(self, entry: dict | None = ..., frame: FrameType | None = ...) -> None: ... - def _get_stack_trace(self, frame: FrameType | None = ...) -> list[tuple[str, int, str, str]]: ... + def _get_stack_trace( + self, frame: FrameType | None = ... + ) -> list[tuple[str, int, str, str]]: ... def post_process(self) -> None: ... @property def entries(self) -> list[dict]: ... @@ -110,9 +114,15 @@ class Profiler: profile_id: Any db: str | None collectors: list[Collector] - def __init__(self, collectors: list[str | Collector] | None = ..., db: str | None = ..., - profile_session: Any | None = ..., description: str | None = ..., disable_gc: bool = ..., - params: Any | None = ...) -> None: ... + def __init__( + self, + collectors: list[str | Collector] | None = ..., + db: str | None = ..., + profile_session: Any | None = ..., + description: str | None = ..., + disable_gc: bool = ..., + params: Any | None = ..., + ) -> None: ... def __enter__(self: _T) -> _T: ... def __exit__(self, *args) -> None: ... def _add_file_lines(self, stack: list[tuple[str, int, str, str]]) -> None: ... @@ -123,6 +133,8 @@ class Profiler: class Nested(Generic[_T]): profiler: Profiler context_manager: ContextManager[_T] - def __init__(self, profiler: Profiler, context_manager: ContextManager[_T]) -> None: ... + def __init__( + self, profiler: Profiler, context_manager: ContextManager[_T] + ) -> None: ... def __enter__(self) -> _T: ... def __exit__(self, exc_type, exc_value, traceback): ... diff --git a/odoo-stubs/tools/query.pyi b/odoo-stubs/tools/query.pyi index a732945..fdb677b 100644 --- a/odoo-stubs/tools/query.pyi +++ b/odoo-stubs/tools/query.pyi @@ -20,9 +20,37 @@ class Query: def __init__(self, cr: Cursor, alias: str, table: str | None = ...) -> None: ... def add_table(self, alias: str, table: str | None = ...) -> None: ... def add_where(self, where_clause: str, where_params: Iterable = ...) -> None: ... - def join(self, lhs_alias: str, lhs_column: str, rhs_table: str, rhs_column: str, link: str, extra: str | None = ..., extra_params: tuple = ...) -> str: ... - def left_join(self, lhs_alias: str, lhs_column: str, rhs_table: str, rhs_column: str, link: str, extra: str | None = ..., extra_params: tuple = ...) -> str: ... - def _join(self, kind: str, lhs_alias: str, lhs_column: str, rhs_table: str, rhs_column: str, link: str, extra: str | None = ..., extra_params: tuple = ...) -> str: ... + def join( + self, + lhs_alias: str, + lhs_column: str, + rhs_table: str, + rhs_column: str, + link: str, + extra: str | None = ..., + extra_params: tuple = ..., + ) -> str: ... + def left_join( + self, + lhs_alias: str, + lhs_column: str, + rhs_table: str, + rhs_column: str, + link: str, + extra: str | None = ..., + extra_params: tuple = ..., + ) -> str: ... + def _join( + self, + kind: str, + lhs_alias: str, + lhs_column: str, + rhs_table: str, + rhs_column: str, + link: str, + extra: str | None = ..., + extra_params: tuple = ..., + ) -> str: ... def select(self, *args) -> tuple[str, list]: ... def subselect(self, *args) -> tuple[str, list]: ... def get_sql(self) -> tuple[str, str, list]: ... @@ -38,4 +66,11 @@ class Query: def where_clause(self) -> tuple[str, ...]: ... @property def where_clause_params(self) -> tuple: ... - def add_join(self, connection, implicit: bool = ..., outer: bool = ..., extra: str | None = ..., extra_params: tuple = ...) -> tuple[str, str]: ... + def add_join( + self, + connection, + implicit: bool = ..., + outer: bool = ..., + extra: str | None = ..., + extra_params: tuple = ..., + ) -> tuple[str, str]: ... diff --git a/odoo-stubs/tools/rendering_tools.pyi b/odoo-stubs/tools/rendering_tools.pyi index ccc52bd..84d5610 100644 --- a/odoo-stubs/tools/rendering_tools.pyi +++ b/odoo-stubs/tools/rendering_tools.pyi @@ -11,4 +11,6 @@ template_env_globals: dict[str, Any] def parse_inline_template(text: str) -> list[tuple[str, str]]: ... def convert_inline_template_to_qweb(template: str) -> Markup: ... -def render_inline_template(template_instructions: Iterable[tuple[str, str]], variables: dict) -> str: ... +def render_inline_template( + template_instructions: Iterable[tuple[str, str]], variables: dict +) -> str: ... diff --git a/odoo-stubs/tools/safe_eval.pyi b/odoo-stubs/tools/safe_eval.pyi index add5a96..1f662e2 100644 --- a/odoo-stubs/tools/safe_eval.pyi +++ b/odoo-stubs/tools/safe_eval.pyi @@ -1,12 +1,15 @@ -from opcode import HAVE_ARGUMENT as HAVE_ARGUMENT from types import CodeType from typing import Any, Iterable, Iterator, Literal +from opcode import HAVE_ARGUMENT as HAVE_ARGUMENT + unsafe_eval = eval _ALLOWED_MODULES: list[str] _UNSAFE_ATTRIBUTES: list[str] -def to_opcodes(opnames: Iterable[str], _opmap: dict[str, int] =...) -> Iterator[int]: ... +def to_opcodes( + opnames: Iterable[str], _opmap: dict[str, int] = ... +) -> Iterator[int]: ... _BLACKLIST: set[int] _CONST_OPCODES: set[int] @@ -15,16 +18,33 @@ _EXPR_OPCODES: set[int] _SAFE_OPCODES: set[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 = ..., filename: 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 = ..., filename: str | None = ... +): ... 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 = ...): ... +def _import( + name: str, + globals: dict | None = ..., + locals: dict | None = ..., + fromlist: list | None = ..., + level: int = ..., +): ... _BUILTINS: dict[str, Any] -def safe_eval(expr: str, globals_dict: dict | None = ..., locals_dict: dict | None = ..., mode: str = ..., - nocopy: bool = ..., locals_builtins: bool = ..., filename: str | None = ...): ... +def safe_eval( + expr: str, + globals_dict: dict | None = ..., + locals_dict: dict | None = ..., + mode: str = ..., + nocopy: bool = ..., + locals_builtins: bool = ..., + filename: str | None = ..., +): ... def test_python_expr(expr: str, mode: str = ...) -> str | Literal[False]: ... def check_values(d: dict): ... diff --git a/odoo-stubs/tools/sourcemap_generator.pyi b/odoo-stubs/tools/sourcemap_generator.pyi index f0ebcef..51f8d5a 100644 --- a/odoo-stubs/tools/sourcemap_generator.pyi +++ b/odoo-stubs/tools/sourcemap_generator.pyi @@ -12,7 +12,13 @@ class SourceMapGenerator: def _serialize_mappings(self) -> str: ... def to_json(self) -> dict: ... def get_content(self) -> bytes: ... - def add_source(self, source_name: str, source_content: str, last_index: int, start_offset: int = ...) -> None: ... + def add_source( + self, + source_name: str, + source_content: str, + last_index: int, + start_offset: int = ..., + ) -> None: ... B64CHARS: bytes SHIFTSIZE: int diff --git a/odoo-stubs/tools/speedscope.pyi b/odoo-stubs/tools/speedscope.pyi index 6194c47..3c286e9 100644 --- a/odoo-stubs/tools/speedscope.pyi +++ b/odoo-stubs/tools/speedscope.pyi @@ -1,7 +1,7 @@ from reprlib import Repr from typing import Any, Callable, Iterable, Sequence, TypeVar -_SpeedscopeT = TypeVar('_SpeedscopeT', bound=Speedscope) +_SpeedscopeT = TypeVar("_SpeedscopeT", bound=Speedscope) shortener: Repr shorten: Callable[[Any], str] @@ -16,14 +16,30 @@ class Speedscope: frames_indexes: dict[Any, int] frame_count: int profiles: list - def __init__(self, name: str = ..., init_stack_trace: list | None = ...) -> None: ... + def __init__( + self, name: str = ..., init_stack_trace: list | None = ... + ) -> None: ... def add(self, key, profile) -> None: ... def convert_stack(self, stack: list[Sequence]) -> None: ... - def add_output(self: _SpeedscopeT, names: Iterable[str], complete: bool = ..., display_name: str | None = ..., - use_context: bool = ..., **params) -> _SpeedscopeT: ... + def add_output( + self: _SpeedscopeT, + names: Iterable[str], + complete: bool = ..., + display_name: str | None = ..., + use_context: bool = ..., + **params + ) -> _SpeedscopeT: ... def add_default(self: _SpeedscopeT) -> _SpeedscopeT: ... def make(self) -> dict: ... def get_frame_id(self, frame) -> int: ... - def stack_to_ids(self, stack: list, context: Iterable[tuple[int, dict]], stack_offset: int = ...) -> list[int]: ... - def process(self, entries: list[dict], continuous: bool = ..., hide_gaps: bool = ..., use_context: bool = ..., - constant_time: bool = ...) -> list[dict]: ... + def stack_to_ids( + self, stack: list, context: Iterable[tuple[int, dict]], stack_offset: int = ... + ) -> list[int]: ... + def process( + self, + entries: list[dict], + continuous: bool = ..., + hide_gaps: bool = ..., + use_context: bool = ..., + constant_time: bool = ..., + ) -> list[dict]: ... diff --git a/odoo-stubs/tools/sql.pyi b/odoo-stubs/tools/sql.pyi index 71336de..cec8ee0 100644 --- a/odoo-stubs/tools/sql.pyi +++ b/odoo-stubs/tools/sql.pyi @@ -12,28 +12,78 @@ def table_kind(cr: Cursor, tablename: str) -> str | None: ... SQL_ORDER_BY_TYPE: defaultdict -def create_model_table(cr: Cursor, tablename: str, comment: str | None = ..., columns: Iterable = ...) -> 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 convert_column_translatable(cr: Cursor, tablename: str, columnname: str, columntype: str) -> None: ... -def _convert_column(cr: Cursor, tablename: str, columnname: str, columntype: str, using: str) -> None: ... +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 convert_column_translatable( + cr: Cursor, tablename: str, columnname: str, columntype: str +) -> None: ... +def _convert_column( + cr: Cursor, tablename: str, columnname: str, columntype: str, using: str +) -> None: ... def drop_depending_views(cr: Cursor, table: str, column: str) -> None: ... def get_depending_views(cr: Cursor, table: str, column: str): ... 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 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 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 check_index_exist(cr: Cursor, indexname: str) -> None: ... -def create_index(cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str], method: str = ..., where: str = ...) -> None: ... -def create_unique_index(cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str]) -> None: ... +def create_index( + cr: Cursor, + indexname: str, + tablename: str, + expressions: Iterable[str], + method: str = ..., + where: 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: ... diff --git a/odoo-stubs/tools/template_inheritance.pyi b/odoo-stubs/tools/template_inheritance.pyi index bfa8606..c793696 100644 --- a/odoo-stubs/tools/template_inheritance.pyi +++ b/odoo-stubs/tools/template_inheritance.pyi @@ -5,9 +5,15 @@ from lxml.etree import _Element RSTRIP_REGEXP: Pattern -def add_stripped_items_before(node: _Element, spec: _Element, extract: Callable[[_Element], _Element]) -> None: ... +def add_stripped_items_before( + node: _Element, spec: _Element, extract: Callable[[_Element], _Element] +) -> None: ... def add_text_before(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: ... +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 f0970f6..b3fcbf8 100644 --- a/odoo-stubs/tools/test_reports.pyi +++ b/odoo-stubs/tools/test_reports.pyi @@ -1,10 +1,26 @@ from typing import Any, Literal -from . import config as config from ..sql_db import Cursor +from . import config as config -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]: ... +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 0e8899f..5fa6034 100644 --- a/odoo-stubs/tools/translate.pyi +++ b/odoo-stubs/tools/translate.pyi @@ -3,16 +3,16 @@ from collections import defaultdict, namedtuple from re import Match, Pattern from tarfile import TarFile from types import FrameType -from typing import Any, BinaryIO, Callable, IO, Iterable, Iterator, NoReturn +from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, NoReturn from lxml.etree import HTMLParser, _Element from polib import POFile -from .pycompat import _CsvWriter from ..api import Environment from ..fields import Field from ..models import BaseModel from ..sql_db import Connection, Cursor +from .pycompat import _CsvWriter PYTHON_TRANSLATION_COMMENT: str JAVASCRIPT_TRANSLATION_COMMENT: str @@ -32,8 +32,12 @@ def translate_attrib_value(node: _Element) -> bool: ... avoid_pattern: Pattern -def translate_xml_node(node: _Element, callback: Callable[[str], str | None], parse: Callable[[str], _Element], - serialize: Callable[[_Element], str]) -> _Element: ... +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: ... @@ -50,14 +54,16 @@ def translate_sql_constraint(cr: Cursor, key: str, lang: str) -> str: ... class GettextAlias: def _get_db(self) -> Connection | None: ... - def _get_cr(self, frame: FrameType, allow_create: bool = ...) -> tuple[Cursor, bool]: ... + 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, module: str | None = ...) -> str: ... class _lt: - __slots__ = ['_source', '_args', '_module'] + __slots__ = ["_source", "_args", "_module"] _source: str _args: tuple _module: str @@ -77,7 +83,9 @@ re_escaped_replacements: dict[str, str] def _sub_replacement(match_obj: Match) -> str: ... def unquote(str: str) -> str: ... -def TranslationFileReader(source: IO, fileformat: str = ...) -> CSVFileReader | PoFileReader: ... +def TranslationFileReader( + source: IO, fileformat: str = ... +) -> CSVFileReader | PoFileReader: ... class CSVFileReader: source: csv.DictReader @@ -90,7 +98,9 @@ class PoFileReader: def __init__(self, source: str | IO): ... def __iter__(self) -> Iterator[dict[str, Any]]: ... -def TranslationFileWriter(target, fileformat: str = ..., lang: str | None = ...) -> CSVFileWriter | PoFileWriter | TarFileWriter: ... +def TranslationFileWriter( + target, fileformat: str = ..., lang: str | None = ... +) -> CSVFileWriter | PoFileWriter | TarFileWriter: ... class CSVFileWriter: writer: _CsvWriter @@ -103,7 +113,9 @@ class PoFileWriter: 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: ... + def add_entry( + self, modules, tnrs, source, trad, comments: Iterable[str] | None = ... + ) -> None: ... class TarFileWriter: tar: TarFile @@ -111,14 +123,20 @@ class TarFileWriter: def __init__(self, target: IO, lang: str) -> None: ... def write_rows(self, rows: Iterable) -> None: ... -def trans_export(lang: str, modules: list[str], buffer, format: str, cr: Cursor) -> None: ... +def trans_export( + lang: str, modules: list[str], buffer, format: str, cr: Cursor +) -> None: ... def _push(callback: Callable[[str, int], Any], term: str, source_line: int) -> None: ... -def _extract_translatable_qweb_terms(element: _Element, callback: Callable[[str, int], Any]) -> None: ... +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]: ... def extract_formula_terms(formula: str) -> Iterator[str]: ... -def extract_spreadsheet_terms(fileobj, keywords, comment_tags, options) -> Iterator[tuple[int, str, str, list]]: ... +def extract_spreadsheet_terms( + fileobj, keywords, comment_tags, options +) -> Iterator[tuple[int, str, str, list]]: ... -ImdInfo = namedtuple('ExternalId', ['name', 'model', 'res_id', 'module']) +ImdInfo = namedtuple("ExternalId", ["name", "model", "res_id", "module"]) class TranslationModuleReader: _cr: Cursor @@ -128,16 +146,39 @@ class TranslationModuleReader: _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 __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 = ..., value: Any | None = ...) -> None: ... - def _get_translatable_records(self, imd_records: Iterable[ImdInfo]) -> BaseModel: ... + def _push_translation( + self, + module: str, + ttype: str, + name: str, + res_id: str, + source: str, + comments: Iterable[str] | None = ..., + record_id: int | None = ..., + value: Any | 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: 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 _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 DeepDefaultDict() -> defaultdict: ... @@ -146,16 +187,37 @@ class TranslationImporter: cr: Cursor verbose: bool env: Environment - model_translations: defaultdict[str, defaultdict[str, defaultdict[str, defaultdict]]] - model_terms_translations: defaultdict[str, defaultdict[str, defaultdict[str, defaultdict]]] + model_translations: defaultdict[ + str, defaultdict[str, defaultdict[str, defaultdict]] + ] + model_terms_translations: defaultdict[ + str, defaultdict[str, defaultdict[str, defaultdict]] + ] def __init__(self, cr: Cursor, verbose: bool = ...) -> None: ... - def load_file(self, filepath: str, lang: str, xmlids: Iterable[str] | None = ...) -> None: ... - def load(self, fileobj: IO, fileformat: str, lang: str, xmlids: Iterable[str] | None = ...) -> None: ... + def load_file( + self, filepath: str, lang: str, xmlids: Iterable[str] | None = ... + ) -> None: ... + def load( + self, + fileobj: IO, + fileformat: str, + lang: str, + xmlids: Iterable[str] | None = ..., + ) -> None: ... def _load(self, reader, lang: str, xmlids: Iterable[str] | None = ...) -> None: ... def save(self, overwrite: bool = ..., force_overwrite: bool = ...) -> None: ... -def trans_load(cr: Cursor, filepath: str, lang: str, verbose: bool = ..., overwrite: bool = ...) -> None: ... -def trans_load_data(cr: Cursor, fileobj: IO, fileformat: str, lang: str, verbose: bool = ..., overwrite: bool = ...) -> None: ... +def trans_load( + cr: Cursor, filepath: str, lang: str, verbose: bool = ..., overwrite: bool = ... +) -> None: ... +def trans_load_data( + cr: Cursor, + fileobj: IO, + fileformat: str, + lang: str, + verbose: bool = ..., + overwrite: bool = ..., +) -> None: ... def get_locales(lang: str | None = ...) -> None: ... def resetlocale() -> str: ... def load_language(cr: Cursor, lang: str) -> None: ... @@ -169,7 +231,9 @@ class CodeTranslations: @staticmethod def _read_code_translations_file(fileobj: IO, filter_func: Callable) -> dict: ... @staticmethod - def _get_code_translations(module_name: str, lang: str, filter_func: Callable) -> dict: ... + def _get_code_translations( + module_name: str, lang: str, filter_func: Callable + ) -> dict: ... def _load_python_translations(self, module_name: str, lang: str): ... def _load_web_translations(self, module_name: str, lang: str): ... def get_python_translations(self, module_name: str, lang: str) -> dict: ... diff --git a/odoo-stubs/tools/view_validation.pyi b/odoo-stubs/tools/view_validation.pyi index f248c7f..aac7a19 100644 --- a/odoo-stubs/tools/view_validation.pyi +++ b/odoo-stubs/tools/view_validation.pyi @@ -5,7 +5,7 @@ from typing import Callable, TypeVar from lxml.etree import RelaxNG, _Element -_CallableT = TypeVar('_CallableT', bound=Callable) +_CallableT = TypeVar("_CallableT", bound=Callable) _validators: defaultdict[str, list[Callable]] _relaxng_cache: dict[str, RelaxNG | None] diff --git a/odoo-stubs/tools/which.pyi b/odoo-stubs/tools/which.pyi index a873fe2..fbc0905 100644 --- a/odoo-stubs/tools/which.pyi +++ b/odoo-stubs/tools/which.pyi @@ -1,4 +1,5 @@ -from os import R_OK as R_OK, W_OK as W_OK +from os import R_OK as R_OK +from os import W_OK as W_OK from os.path import dirname as dirname from typing import Iterator @@ -8,5 +9,9 @@ windows: bool seen: set defpathext: list[str] -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: ... +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/xml_utils.pyi b/odoo-stubs/tools/xml_utils.pyi index c5ee92b..f6ab2ea 100644 --- a/odoo-stubs/tools/xml_utils.pyi +++ b/odoo-stubs/tools/xml_utils.pyi @@ -1,6 +1,7 @@ +from typing import IO, Callable, Iterable, Literal + from lxml import etree from lxml.etree import _Element -from typing import Callable, IO, Iterable, Literal from ..api import Environment @@ -10,13 +11,41 @@ class odoo_resolver(etree.Resolver): def __init__(self, env: Environment, prefix: str | None) -> None: ... def resolve(self, url: str, id: str, context) -> str: ... -def _check_with_xsd(tree_or_str: str | _Element, stream: str | IO, env: Environment | None = ..., prefix: str | 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: ... -def load_xsd_files_from_url(env: Environment, url: str, file_name: str | None = ..., force_reload: bool = ..., request_max_timeout: int = ..., - xsd_name_prefix: str = ..., xsd_names_filter: str | list[str] | None = ..., - modify_xsd_content: Callable[[bytes], bytes] | None = ...) -> 'odoo.model.ir_attachment | Literal[False]': ... -def validate_xml_from_attachment(env: Environment, xml_content, xsd_name: str, reload_files_function: Callable | None = ..., - prefix: str | None = ...) -> None: ... +def _check_with_xsd( + tree_or_str: str | _Element, + stream: str | IO, + env: Environment | None = ..., + prefix: str | 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: ... +def load_xsd_files_from_url( + env: Environment, + url: str, + file_name: str | None = ..., + force_reload: bool = ..., + request_max_timeout: int = ..., + xsd_name_prefix: str = ..., + xsd_names_filter: str | list[str] | None = ..., + modify_xsd_content: Callable[[bytes], bytes] | None = ..., +) -> "odoo.model.ir_attachment | Literal[False]": ... +def validate_xml_from_attachment( + env: Environment, + xml_content, + xsd_name: str, + reload_files_function: Callable | None = ..., + prefix: str | None = ..., +) -> None: ...