From b570cdd5996aad21e40068e64a54289dc9770d90 Mon Sep 17 00:00:00 2001 From: Damian Birchler Date: Fri, 3 Nov 2023 12:56:42 +0100 Subject: [PATCH] Check if unit /and/ output number are non-negative. --- src/trnsys_dck_parser/parse/expression/parse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/trnsys_dck_parser/parse/expression/parse.py b/src/trnsys_dck_parser/parse/expression/parse.py index f6cd35f..8124819 100644 --- a/src/trnsys_dck_parser/parse/expression/parse.py +++ b/src/trnsys_dck_parser/parse/expression/parse.py @@ -101,18 +101,18 @@ def _argument_list(self) -> _tp.Sequence[_exp.ExpressionOrNumber]: def _unit_and_output_number(self) -> _tp.Tuple[int, int]: self._expect(_tok.Tokens.INTEGER) unit_number = int(self._current_token.value) - self._check_non_negative(unit_number) + self._check_non_negative(unit_number, "Unit number") self._expect(_tok.Tokens.COMMA) self._expect(_tok.Tokens.INTEGER) output_number = int(self._current_token.value) - self._check_non_negative(unit_number) + self._check_non_negative(output_number, "Output number") return unit_number, output_number - def _check_non_negative(self, integer): + def _check_non_negative(self, integer: int, what: str) -> None: if integer >= 0: return - self._raise_parsing_error("Unit numbers must be non-negative.") + self._raise_parsing_error(f"{what} numbers must be non-negative.")