mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Bump mypy to 0.940 (#68007)
This commit is contained in:
parent
380f04277e
commit
41df798375
@ -98,7 +98,7 @@ class CO2Sensor(update_coordinator.CoordinatorEntity[CO2SignalResponse], SensorE
|
||||
@property
|
||||
def native_value(self) -> StateType:
|
||||
"""Return sensor state."""
|
||||
if (value := self.coordinator.data["data"][self._description.key]) is None: # type: ignore[misc]
|
||||
if (value := self.coordinator.data["data"][self._description.key]) is None: # type: ignore[literal-required]
|
||||
return None
|
||||
return round(value, 2)
|
||||
|
||||
|
@ -291,7 +291,7 @@ class EnergyManager:
|
||||
"device_consumption",
|
||||
):
|
||||
if key in update:
|
||||
data[key] = update[key] # type: ignore[misc]
|
||||
data[key] = update[key] # type: ignore[literal-required]
|
||||
|
||||
self.data = data
|
||||
self._store.async_delay_save(lambda: cast(dict, self.data), 60)
|
||||
|
@ -102,9 +102,9 @@ def async_populate_data_from_discovery(
|
||||
device.get(discovery_key) is not None
|
||||
and conf_key
|
||||
not in data_updates # Prefer the model num from TCP instead of UDP
|
||||
and current_data.get(conf_key) != device[discovery_key] # type: ignore[misc]
|
||||
and current_data.get(conf_key) != device[discovery_key] # type: ignore[literal-required]
|
||||
):
|
||||
data_updates[conf_key] = device[discovery_key] # type: ignore[misc]
|
||||
data_updates[conf_key] = device[discovery_key] # type: ignore[literal-required]
|
||||
|
||||
|
||||
@callback
|
||||
|
@ -44,7 +44,6 @@ def _async_device_entities(
|
||||
for device in data.get_by_types({model_type}):
|
||||
assert isinstance(device, (Camera, Light, Sensor, Viewer, Doorlock))
|
||||
for description in descs:
|
||||
assert isinstance(description, EntityDescription)
|
||||
if description.ufp_required_field:
|
||||
required_field = get_nested_attr(device, description.ufp_required_field)
|
||||
if not required_field:
|
||||
|
@ -18,7 +18,7 @@ T = TypeVar("T", bound=ProtectDeviceModel)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ProtectRequiredKeysMixin(Generic[T]):
|
||||
class ProtectRequiredKeysMixin(EntityDescription, Generic[T]):
|
||||
"""Mixin for required keys."""
|
||||
|
||||
ufp_required_field: str | None = None
|
||||
@ -54,7 +54,6 @@ class ProtectSetableKeysMixin(ProtectRequiredKeysMixin, Generic[T]):
|
||||
|
||||
async def ufp_set(self, obj: T, value: Any) -> None:
|
||||
"""Set value for UniFi Protect device."""
|
||||
assert isinstance(self, EntityDescription)
|
||||
_LOGGER.debug("Setting %s to %s for %s", self.name, value, obj.name)
|
||||
if self.ufp_set_method is not None:
|
||||
await getattr(obj, self.ufp_set_method)(value)
|
||||
|
@ -478,7 +478,7 @@ class EntityPlatform:
|
||||
"via_device",
|
||||
):
|
||||
if key in device_info:
|
||||
processed_dev_info[key] = device_info[key] # type: ignore[misc]
|
||||
processed_dev_info[key] = device_info[key] # type: ignore[literal-required]
|
||||
|
||||
if "configuration_url" in device_info:
|
||||
if device_info["configuration_url"] is None:
|
||||
|
1
mypy.ini
1
mypy.ini
@ -12,6 +12,7 @@ warn_incomplete_stub = true
|
||||
warn_redundant_casts = true
|
||||
warn_unused_configs = true
|
||||
warn_unused_ignores = true
|
||||
enable_error_code = ignore-without-code
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
|
@ -11,7 +11,7 @@ codecov==2.1.12
|
||||
coverage==6.3.2
|
||||
freezegun==1.1.0
|
||||
mock-open==1.4.0
|
||||
mypy==0.931
|
||||
mypy==0.940
|
||||
pre-commit==2.17.0
|
||||
pylint==2.12.2
|
||||
pipdeptree==2.2.1
|
||||
|
@ -247,6 +247,7 @@ GENERAL_SETTINGS: Final[dict[str, str]] = {
|
||||
"warn_redundant_casts": "true",
|
||||
"warn_unused_configs": "true",
|
||||
"warn_unused_ignores": "true",
|
||||
"enable_error_code": "ignore-without-code",
|
||||
}
|
||||
|
||||
# This is basically the list of checks which is enabled for "strict=true".
|
||||
|
Loading…
x
Reference in New Issue
Block a user