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
1 changed files with 5 additions and 3 deletions

View File

@ -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
)