From 58890eba188faea01643a156246379efadb27344 Mon Sep 17 00:00:00 2001 From: AlexNg Date: Sat, 25 May 2024 18:46:21 +0800 Subject: [PATCH] fix: Cast verbosity comparison to Literal type --- src/thread/utils/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/thread/utils/config.py b/src/thread/utils/config.py index 081410e..11a6ac5 100644 --- a/src/thread/utils/config.py +++ b/src/thread/utils/config.py @@ -1,4 +1,4 @@ -from typing import Any, Callable, Literal, Union +from typing import Any, Callable, Literal, Union, cast _Verbosity_Num = Literal[0, 1, 2] _Verbosity_Enum = Literal['quiet', 'normal', 'verbose'] @@ -79,6 +79,7 @@ def _compare( return operator(self.level_number, other) if isinstance(other, str): if Verbosity.is_valid_level(other): + other = cast(_Verbosity_Enum, other) return operator(self.level_number, VerbosityMapping[other]) return operator(self.level_string, other) raise ValueError('Cannot compare Verbosity with other types')