Skip to content

Commit

Permalink
Fixes for new errors from mypy 1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Mar 10, 2024
1 parent a75ad67 commit fa2bcf4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/galaxy/job_metrics/instrumenters/cgroup.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -123,8 +121,13 @@ def format(self, key: str, value: Any) -> formatting.FormattedMetric:
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))


Expand Down

0 comments on commit fa2bcf4

Please sign in to comment.