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