33
44from datetime import datetime
55from importlib .util import find_spec
6- from typing import Any , Optional , Union , cast
6+ from typing import Any , Literal , Optional , TypeAlias , Union , cast
77
88import attrs
99from gooddata_api_client .model .inline_filter_definition_inline import InlineFilterDefinitionInline
6464 "NOT_EQUAL_TO" : "!=" ,
6565}
6666
67+ ComparisonOperator : TypeAlias = Literal [
68+ "GREATER_THAN" ,
69+ "GREATER_THAN_OR_EQUAL_TO" ,
70+ "LESS_THAN" ,
71+ "LESS_THAN_OR_EQUAL_TO" ,
72+ "EQUAL_TO" ,
73+ "NOT_EQUAL_TO" ,
74+ ]
75+
76+ RangeOperator : TypeAlias = Literal ["BETWEEN" , "NOT_BETWEEN" ]
77+
6778
6879def _extract_id_or_local_id (val : Union [ObjId , Attribute , Metric , str ]) -> Union [ObjId , str ]:
6980 if isinstance (val , (str , ObjId )):
@@ -488,7 +499,7 @@ def description(self, labels: dict[str, str], format_locale: Optional[str] = Non
488499
489500@attrs .define (frozen = True , slots = True )
490501class MetricValueComparisonCondition :
491- operator : str
502+ operator : ComparisonOperator
492503 value : Union [int , float ]
493504
494505 def as_api_model (self ) -> afm_models .MeasureValueCondition :
@@ -505,7 +516,7 @@ def description(self) -> str:
505516
506517@attrs .define (frozen = True , slots = True )
507518class MetricValueRangeCondition :
508- operator : str
519+ operator : RangeOperator
509520 from_value : Union [int , float ]
510521 to_value : Union [int , float ]
511522
@@ -519,7 +530,7 @@ def as_api_model(self) -> afm_models.MeasureValueCondition:
519530 return afm_models .MeasureValueCondition (range = range_body , _check_type = False )
520531
521532 def description (self ) -> str :
522- not_between = "not" if self .operator == "NOT_BETWEEN" else ""
533+ not_between = "not " if self .operator == "NOT_BETWEEN" else ""
523534 return f"{ not_between } between { float (self .from_value )} - { float (self .to_value )} "
524535
525536
0 commit comments