From b1ab21fb8d1ee809533bc71fc00f2a11cab49b8e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sat, 4 Oct 2025 18:25:47 +0200 Subject: mparser: use a literal for arithmetic operators Signed-off-by: Paolo Bonzini --- mesonbuild/mparser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index f80706a90..030905285 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -459,10 +459,9 @@ class ComparisonNode(BinaryOperatorNode): @dataclass(unsafe_hash=True) class ArithmeticNode(BinaryOperatorNode): - # TODO: use a Literal for operation - operation: str + operation: ARITH_OPERATORS - def __init__(self, operation: str, left: BaseNode, operator: SymbolNode, right: BaseNode): + def __init__(self, operation: ARITH_OPERATORS, left: BaseNode, operator: SymbolNode, right: BaseNode): super().__init__(left, operator, right) self.operation = operation @@ -675,6 +674,7 @@ class ParenthesizedNode(BaseNode): if T.TYPE_CHECKING: COMPARISONS = Literal['==', '!=', '<', '<=', '>=', '>', 'in', 'not in'] + ARITH_OPERATORS = Literal['add', 'sub', 'mul', 'div', 'mod'] comparison_map: T.Mapping[str, COMPARISONS] = { 'equal': '==', -- cgit v1.2.3