Fixes for new errors from mypy 1.9.0

This commit is contained in:
Nicola Soranzo
2024-03-12 11:06:58 +00:00
parent 330599c70f
commit 437b39ce36
@@ -1,8 +1,6 @@
"""The module describes the ``cgroup`` job metrics plugin."""
import decimal
import logging
import numbers
from collections import namedtuple
from typing import (
Any,
@@ -123,8 +121,13 @@ class CgroupPluginFormatter(formatting.JobMetricFormatter):
return formatting.FormattedMetric(title, nice_size(value))
except ValueError:
pass
elif isinstance(value, (decimal.Decimal, numbers.Integral, numbers.Real)) and value == int(value):
value = int(value)
else:
try:
int_value = int(value)
if value == int_value:
value = int_value
except TypeError:
pass
return formatting.FormattedMetric(title, str(value))