From e2e73d0fdb96479a9094da2ab4cb64be9f491b1f Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 1 Apr 2023 23:23:51 +0200 Subject: [PATCH] Fix another Python < 3.10 subscripted generic issue. --- platypush/plugins/sensor/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platypush/plugins/sensor/__init__.py b/platypush/plugins/sensor/__init__.py index f50302041e..f1926d8d3b 100644 --- a/platypush/plugins/sensor/__init__.py +++ b/platypush/plugins/sensor/__init__.py @@ -211,8 +211,8 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC): if low_t is None or high_t is None: return [] - assert isinstance(low_t, Numeric) and isinstance( - high_t, Numeric + assert isinstance(low_t, (int, float)) and isinstance( + high_t, (int, float) ), f'Non-numeric thresholds detected: "{low_t}" and "{high_t}"' # Above threshold case @@ -246,7 +246,9 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC): return events # Scalar case - if isinstance(old_data, (Numeric, NoneType)) and isinstance(new_data, Numeric): + if isinstance(old_data, (Numeric, NoneType)) and isinstance( + new_data, (int, float) + ): return self._process_scalar_threshold_events( old_data, new_data, attr # type: ignore )