From fa2bcf4d75bc34f684df5d264470a6a6f1f18fb4 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Sun, 10 Mar 2024 18:12:28 +0000 Subject: [PATCH] Fixes for new errors from mypy 1.9.0 --- lib/galaxy/job_metrics/instrumenters/cgroup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/job_metrics/instrumenters/cgroup.py b/lib/galaxy/job_metrics/instrumenters/cgroup.py index 66da4f9389f9..406dcf0da0b9 100644 --- a/lib/galaxy/job_metrics/instrumenters/cgroup.py +++ b/lib/galaxy/job_metrics/instrumenters/cgroup.py @@ -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 @@ 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))