fix(salary): reject non-finite workbook numbers (#572)

* fix(salary): reject non-finite workbook numbers

* docs(changelog): record fix for #572
This commit is contained in:
Rudy Mizrahi Celekli authored and GitHub committed 2026-10-18 07:19:24 +02:00
1 parent ef4d12711c
commit 991bda5dd2
3 files changed
+65 -2

No files matched your search

+10 -2
View File
@@ -26,6 +26,7 @@ with paired count/index columns per category, it groups them automatically.
"""
import json
import math
import sys
import argparse
import re
@@ -58,10 +59,17 @@ ID_PATTERNS = {"id", "personnummer"}
DEFAULT_CATEGORY = "all_employees"
def _finite_float(value):
number = float(value)
if not math.isfinite(number):
raise ValueError("salary values must be finite")
return number
def parse_numeric_cell(value):
"""Parse numeric Excel values, including localized string cells."""
if isinstance(value, (int, float)):
return float(value)
return _finite_float(value)
if not isinstance(value, str):
raise ValueError("not numeric")
@@ -84,7 +92,7 @@ def parse_numeric_cell(value):
elif "." in text:
if re.fullmatch(r"[+-]?\d+\.\d{3}", text):
raise ValueError("ambiguous dot separator")
return float(text)
return _finite_float(text)
def header_matches(header, patterns):