Explorar o código

Config parser: Check for strings using instanceof rather than type

In HA 2023.12 beta, the yaml parser has been modified to return objects that
are a subclass of str, rather than str objects themselves.  This breaks the
check for multiple conditions, which needs to differentiate strings from
other sequences.
Jason Rumney %!s(int64=2) %!d(string=hai) anos
pai
achega
f777b547ce
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      custom_components/tuya_local/helpers/device_config.py

+ 1 - 1
custom_components/tuya_local/helpers/device_config.py

@@ -74,7 +74,7 @@ def _bytes_to_fmt(bytes, signed=False):
 
 def _equal_or_in(value1, values2):
     """Return true if value1 is the same as values2, or appears in values2."""
-    if type(values2) is not str and isinstance(values2, Sequence):
+    if not isinstance(values2, str) and isinstance(values2, Sequence):
         return value1 in values2
     else:
         return value1 == values2