core (constants): use bool_type:

Using `bool` for type hint in `Const.bool_const` if conflicting with `Const.bool` method.
To avoid this, `bool_type` is used as an alias to `bool`.
This commit is contained in:
Goffi 2024-04-06 12:14:10 +02:00
commit 0ee6a64e3b

View file

@ -35,6 +35,9 @@ else:
logged_user = getuser()
bool_type = bool
class Const(object):
## Application ##
@ -455,13 +458,13 @@ class Const(object):
)
@classmethod
def bool(cls, value: str) -> bool:
def bool(cls, value: str) -> bool_type:
"""@return (bool): bool value for associated constant"""
assert isinstance(value, str)
return value.lower() in (cls.BOOL_TRUE, "1", "yes", "on", "y", "t")
@classmethod
def bool_const(cls, value: bool) -> str:
def bool_const(cls, value: bool_type) -> str:
"""@return (str): constant associated to bool value"""
assert isinstance(value, bool)
return cls.BOOL_TRUE if value else cls.BOOL_FALSE