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:
parent
188c2c97ba
commit
0ee6a64e3b
1 changed files with 5 additions and 2 deletions
|
|
@ -35,6 +35,9 @@ else:
|
||||||
logged_user = getuser()
|
logged_user = getuser()
|
||||||
|
|
||||||
|
|
||||||
|
bool_type = bool
|
||||||
|
|
||||||
|
|
||||||
class Const(object):
|
class Const(object):
|
||||||
|
|
||||||
## Application ##
|
## Application ##
|
||||||
|
|
@ -455,13 +458,13 @@ class Const(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def bool(cls, value: str) -> bool:
|
def bool(cls, value: str) -> bool_type:
|
||||||
"""@return (bool): bool value for associated constant"""
|
"""@return (bool): bool value for associated constant"""
|
||||||
assert isinstance(value, str)
|
assert isinstance(value, str)
|
||||||
return value.lower() in (cls.BOOL_TRUE, "1", "yes", "on", "y", "t")
|
return value.lower() in (cls.BOOL_TRUE, "1", "yes", "on", "y", "t")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def bool_const(cls, value: bool) -> str:
|
def bool_const(cls, value: bool_type) -> str:
|
||||||
"""@return (str): constant associated to bool value"""
|
"""@return (str): constant associated to bool value"""
|
||||||
assert isinstance(value, bool)
|
assert isinstance(value, bool)
|
||||||
return cls.BOOL_TRUE if value else cls.BOOL_FALSE
|
return cls.BOOL_TRUE if value else cls.BOOL_FALSE
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue