fix: black

This commit is contained in:
egarette@silique.fr 2025-10-15 09:43:56 +02:00
parent 60e259fef2
commit 0513d6677e
5 changed files with 102 additions and 22 deletions

View file

@ -162,7 +162,9 @@ def option_type(typ):
kwargs["is_group"] = True
return func(self, options_bag, *args[1:], **kwargs)
self._set_subconfig()
if (not isinstance(typ, list) or "allow_dynoption" not in typ) and self._subconfig.is_dynamic_without_identifiers:
if (
not isinstance(typ, list) or "allow_dynoption" not in typ
) and self._subconfig.is_dynamic_without_identifiers:
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
option = self._subconfig.option
@ -321,7 +323,15 @@ class _TiramisuOptionOptionDescription:
"""Test if option is a leader or a follower"""
return self._subconfig.option.impl_is_leadership()
@option_type(["optiondescription", "option", "with_or_without_index", "symlink", "allow_dynoption"])
@option_type(
[
"optiondescription",
"option",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
def description(
self,
with_quote: bool = False,
@ -338,7 +348,15 @@ class _TiramisuOptionOptionDescription:
None,
)
@option_type(["optiondescription", "option", "symlink", "with_or_without_index", "allow_dynoption"])
@option_type(
[
"optiondescription",
"option",
"symlink",
"with_or_without_index",
"allow_dynoption",
]
)
def name(
self,
*,
@ -351,7 +369,15 @@ class _TiramisuOptionOptionDescription:
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
return self._subconfig.true_path.rsplit(".", 1)[-1]
@option_type(["optiondescription", "option", "with_or_without_index", "symlink", "allow_dynoption"])
@option_type(
[
"optiondescription",
"option",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
def path(
self,
*,
@ -443,7 +469,15 @@ class _TiramisuOptionOptionDescription:
)
return options
@option_type(["option", "optiondescription", "symlink", "with_or_without_index", "allow_dynoption"])
@option_type(
[
"option",
"optiondescription",
"symlink",
"with_or_without_index",
"allow_dynoption",
]
)
def type(self, only_self=False, translation=False):
"""Get de option type"""
option = self._subconfig.option
@ -466,7 +500,15 @@ class _TiramisuOptionOptionDescription:
"""Get de option extra"""
return self._subconfig.option.impl_get_extra(extra)
@option_type(["option", "optiondescription", "symlink", "with_or_without_index", "allow_dynoption"])
@option_type(
[
"option",
"optiondescription",
"symlink",
"with_or_without_index",
"allow_dynoption",
]
)
def isdynamic(self, *, only_self: bool = False):
"""Test if option is a dynamic optiondescription"""
if not only_self:
@ -675,7 +717,9 @@ class TiramisuOptionProperty(CommonTiramisuOption):
_validate_properties = False
@option_type(["option", "optiondescription", "with_index", "symlink", "allow_dynoption"])
@option_type(
["option", "optiondescription", "with_index", "symlink", "allow_dynoption"]
)
def get(
self,
*,
@ -807,7 +851,15 @@ class TiramisuOptionInformation(CommonTiramisuOption):
_validate_properties = False
@option_type(["option", "optiondescription", "with_or_without_index", "symlink", "allow_dynoption"])
@option_type(
[
"option",
"optiondescription",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
def get(
self,
name: str,
@ -840,7 +892,15 @@ class TiramisuOptionInformation(CommonTiramisuOption):
path=self._path,
)
@option_type(["option", "optiondescription", "with_or_without_index", "symlink", "allow_dynoption"])
@option_type(
[
"option",
"optiondescription",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
def list(self) -> list:
"""List information's keys"""
lst1 = set(self._subconfig.option._list_information())

View file

@ -25,7 +25,13 @@ from copy import copy, deepcopy
from typing import Optional, List, Any, Union
from os.path import commonprefix
from .error import PropertiesOptionError, ConfigError, ConflictError, LeadershipError, AttributeOptionError
from .error import (
PropertiesOptionError,
ConfigError,
ConflictError,
LeadershipError,
AttributeOptionError,
)
from .option import DynOptionDescription, Leadership, Option
from .setting import ConfigBag, Settings, undefined, groups
from .value import Values, owners
@ -273,8 +279,16 @@ class SubConfig:
self.true_path = true_path
if self.option.impl_is_dynoptiondescription():
self.is_dynamic = True
self.is_dynamic_without_identifiers = identifiers is None or (parent and identifiers == parent.identifiers)
if check_dynamic_without_identifiers and parent and parent.is_dynamic and self.is_dynamic_without_identifiers != parent.is_dynamic_without_identifiers:
self.is_dynamic_without_identifiers = identifiers is None or (
parent and identifiers == parent.identifiers
)
if (
check_dynamic_without_identifiers
and parent
and parent.is_dynamic
and self.is_dynamic_without_identifiers
!= parent.is_dynamic_without_identifiers
):
raise AttributeOptionError(true_path, "option-dynamic")
elif parent:
self.is_dynamic = parent.is_dynamic
@ -398,7 +412,7 @@ class SubConfig:
name = dyn_child.path
if name in children_name:
raise ConflictError(
_("option name \"{0}\" is not unique in {1}").format(
_('option name "{0}" is not unique in {1}').format(
name,
self.option.impl_get_display_name(
self, with_quote=True
@ -420,7 +434,7 @@ class SubConfig:
name = child.impl_getpath()
if name in children_name:
raise ConflictError(
_("option name \"{0}\" is not unique in {1}").format(
_('option name "{0}" is not unique in {1}').format(
name,
self.option.impl_get_display_name(
self, with_quote=True
@ -756,7 +770,7 @@ class _Config(CCache):
):
if path == dyn_child.path:
raise ConflictError(
_("option name \"{0}\" is not unique in {1}").format(
_('option name "{0}" is not unique in {1}').format(
name,
option.impl_get_display_name(
subconfig, with_quote=True
@ -765,7 +779,7 @@ class _Config(CCache):
)
elif child.impl_getname() == name:
raise ConflictError(
_("option name \"{0}\" is not unique in {1}").format(
_('option name "{0}" is not unique in {1}').format(
name,
self.option.impl_get_display_name(
self, with_quote=True

View file

@ -364,10 +364,10 @@ class ValueOptionError(_CommonError, ValueError):
def __init__(self, **kwargs):
if ValueOptionError.tmpl is None:
opt = kwargs.get('opt')
opt = kwargs.get("opt")
if opt and opt._do_not_display_value_in_error:
if kwargs.get("index") is None:
self.tmpl = _('{2} has an invalid {1}')
self.tmpl = _("{2} has an invalid {1}")
else:
self.tmpl = _('{2} at index "{3}" has an invalid {1}')
else:

View file

@ -138,9 +138,7 @@ class DynOptionDescription(OptionDescription):
raise ValueError(
_(
"DynOptionDescription identifiers for option {0}, is not a list ({1})"
).format(
name, values
)
).format(name, values)
)
values_ = []
for val in values:

View file

@ -31,7 +31,15 @@ class IntOption(Option):
_type = "integer"
_t_type = _("integer")
def __init__(self, *args, min_number=None, max_number=None, min_integer=None, max_integer=None, **kwargs):
def __init__(
self,
*args,
min_number=None,
max_number=None,
min_integer=None,
max_integer=None,
**kwargs,
):
extra = {}
if min_number is not None:
extra["min_integer"] = min_number