summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2024-03-12 09:31:15 +0100
committerBirte Kristina Friesel <birte.friesel@uos.de>2024-03-12 09:31:15 +0100
commit8e59d0d8fc75b68774f3553a22e992a062e54fa7 (patch)
treef33b7983567d9d0d13906e40e3b92a788d37c387
parent304caa47e46028d679a8e8136b99706da9cd197c (diff)
soft_cast_int_or_float: handle values that already are int/float
-rw-r--r--lib/utils.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/utils.py b/lib/utils.py
index 879a53d..3778fc0 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -124,9 +124,11 @@ def soft_cast_int_or_float(n):
If `n` is empty, returns None.
If `n` is not numeric, it is left unchanged.
"""
+ if type(n) in (float, int):
+ return n
if n is None or n == "":
return None
- if "." in n:
+ if type(n) is str and "." in n:
return soft_cast_float(n)
return soft_cast_int(n)