Fix ty diagnostics from newer homeassistant/cryptography type stubs
requirements-dev.txt intentionally leaves homeassistant/cryptography unpinned (always test against latest), so ty's view of their stubs can drift between runs. SensorEntity._attr_state_class now requires SensorStateClass rather than a bare str (same fix already applied to _attr_device_class); NameAttribute.value is generic over str | bytes, so narrow it before handing it to re.search.
This commit is contained in:
2 files changed
+3
-3
No files matched your search
@@ -91,7 +91,7 @@ def _fetch_samsung_uuid() -> str:
|
|||||||
raise RuntimeError(f"No certificate received from {_SAMSUNG_CLOUD_HOST}")
|
raise RuntimeError(f"No certificate received from {_SAMSUNG_CLOUD_HOST}")
|
||||||
cert = _x509.load_der_x509_certificate(der)
|
cert = _x509.load_der_x509_certificate(der)
|
||||||
for attr in cert.subject:
|
for attr in cert.subject:
|
||||||
if attr.oid == _x509.oid.NameOID.ORGANIZATIONAL_UNIT_NAME:
|
if attr.oid == _x509.oid.NameOID.ORGANIZATIONAL_UNIT_NAME and isinstance(attr.value, str):
|
||||||
m = re.search(r"uuid:([0-9a-f-]+)", attr.value, re.IGNORECASE)
|
m = re.search(r"uuid:([0-9a-f-]+)", attr.value, re.IGNORECASE)
|
||||||
if m:
|
if m:
|
||||||
return m.group(1)
|
return m.group(1)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity, SensorStateClass
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@@ -47,7 +47,7 @@ class LocalThingsSensor(LocalThingsEntity, SensorEntity):
|
|||||||
self._attr_device_class = (
|
self._attr_device_class = (
|
||||||
SensorDeviceClass(desc.device_class) if desc.device_class else None
|
SensorDeviceClass(desc.device_class) if desc.device_class else None
|
||||||
)
|
)
|
||||||
self._attr_state_class = desc.state_class
|
self._attr_state_class = SensorStateClass(desc.state_class) if desc.state_class else None
|
||||||
if desc.options:
|
if desc.options:
|
||||||
self._attr_options = list(desc.options)
|
self._attr_options = list(desc.options)
|
||||||
self._hysteresis_value = None
|
self._hysteresis_value = None
|
||||||
|
|||||||
Reference in new issue
Block a user