From 0ee6a64e3bbd9416970b421d3cb587f7d89dbaf1 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sat, 6 Apr 2024 12:14:10 +0200 Subject: [PATCH] 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`. --- libervia/backend/core/constants.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libervia/backend/core/constants.py b/libervia/backend/core/constants.py index e75d476c..0e6ebfcd 100644 --- a/libervia/backend/core/constants.py +++ b/libervia/backend/core/constants.py @@ -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