Mercurial > libervia-backend
changeset 4229:dd9bc7d791d7
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`.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 06 Apr 2024 12:14:10 +0200 |
parents | 79a4870cfbdf |
children | 314d3c02bb67 |
files | libervia/backend/core/constants.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/backend/core/constants.py Sat Mar 09 15:13:14 2024 +0100 +++ b/libervia/backend/core/constants.py Sat Apr 06 12:14:10 2024 +0200 @@ -35,6 +35,9 @@ logged_user = getuser() +bool_type = bool + + class Const(object): ## Application ## @@ -455,13 +458,13 @@ ) @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