From 41df79837551ff35441ecb605f6920338ae64f72 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 12 Mar 2022 00:57:38 +0100 Subject: [PATCH] Bump mypy to 0.940 (#68007) --- homeassistant/components/co2signal/sensor.py | 2 +- homeassistant/components/energy/data.py | 2 +- homeassistant/components/flux_led/discovery.py | 4 ++-- homeassistant/components/unifiprotect/entity.py | 1 - homeassistant/components/unifiprotect/models.py | 3 +-- homeassistant/helpers/entity_platform.py | 2 +- mypy.ini | 1 + requirements_test.txt | 2 +- script/hassfest/mypy_config.py | 1 + 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/co2signal/sensor.py b/homeassistant/components/co2signal/sensor.py index b10cd054ff9..0c637506447 100644 --- a/homeassistant/components/co2signal/sensor.py +++ b/homeassistant/components/co2signal/sensor.py @@ -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) diff --git a/homeassistant/components/energy/data.py b/homeassistant/components/energy/data.py index d07d3406073..d33f915628d 100644 --- a/homeassistant/components/energy/data.py +++ b/homeassistant/components/energy/data.py @@ -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) diff --git a/homeassistant/components/flux_led/discovery.py b/homeassistant/components/flux_led/discovery.py index 62b80243c8b..a522d133827 100644 --- a/homeassistant/components/flux_led/discovery.py +++ b/homeassistant/components/flux_led/discovery.py @@ -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 diff --git a/homeassistant/components/unifiprotect/entity.py b/homeassistant/components/unifiprotect/entity.py index 27b74d2b303..045a9c4fd6d 100644 --- a/homeassistant/components/unifiprotect/entity.py +++ b/homeassistant/components/unifiprotect/entity.py @@ -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: diff --git a/homeassistant/components/unifiprotect/models.py b/homeassistant/components/unifiprotect/models.py index df11c46a5d9..ecc3e4210ff 100644 --- a/homeassistant/components/unifiprotect/models.py +++ b/homeassistant/components/unifiprotect/models.py @@ -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) diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index cc252f82782..eaf0ae6d6bb 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -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: diff --git a/mypy.ini b/mypy.ini index 6316ce32abf..8beb6183d01 100644 --- a/mypy.ini +++ b/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 diff --git a/requirements_test.txt b/requirements_test.txt index 3896de74630..0e78d456e95 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -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 diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 5df83f1e527..9882c016597 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -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".