From 30ec25fa0a1879c23bbc375a9fd5bb8cc15eef90 Mon Sep 17 00:00:00 2001 From: Bharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com> Date: Sat, 18 May 2024 04:55:05 +0530 Subject: [PATCH] fix: plugin(sensors) - serialization bug with raw stats --- glances/plugins/sensors/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/glances/plugins/sensors/__init__.py b/glances/plugins/sensors/__init__.py index 8634d579..9f1c8e6f 100644 --- a/glances/plugins/sensors/__init__.py +++ b/glances/plugins/sensors/__init__.py @@ -25,6 +25,7 @@ from glances.plugins.plugin.model import GlancesPluginModel class SensorType(str, Enum): + # Switch to `enum.StrEnum` when we only support py311+ CPU_TEMP = 'temperature_core' FAN_SPEED = 'fan_speed' HDD_TEMP = 'temperature_hdd' @@ -195,7 +196,7 @@ class PluginModel(GlancesPluginModel): else: return stats["label"] - def __set_type(self, stats, sensor_type): + def __set_type(self, stats: List[Dict[str, Any]], sensor_type: SensorType) -> List[Dict[str, Any]]: """Set the plugin type. 4 types of stats is possible in the sensors plugin: @@ -206,7 +207,7 @@ class PluginModel(GlancesPluginModel): """ for i in stats: # Set the sensors type - i.update({'type': str(sensor_type)}) + i.update({'type': sensor_type}) # also add the key name i.update({'key': self.get_key()})