Fix another Python < 3.10 subscripted generic issue.

This commit is contained in:
Fabio Manganiello 2023-04-01 23:23:51 +02:00
parent c1d0f21ead
commit e2e73d0fdb
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -211,8 +211,8 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC):
if low_t is None or high_t is None: if low_t is None or high_t is None:
return [] return []
assert isinstance(low_t, Numeric) and isinstance( assert isinstance(low_t, (int, float)) and isinstance(
high_t, Numeric high_t, (int, float)
), f'Non-numeric thresholds detected: "{low_t}" and "{high_t}"' ), f'Non-numeric thresholds detected: "{low_t}" and "{high_t}"'
# Above threshold case # Above threshold case
@ -246,7 +246,9 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC):
return events return events
# Scalar case # 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( return self._process_scalar_threshold_events(
old_data, new_data, attr # type: ignore old_data, new_data, attr # type: ignore
) )