diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index 5c2882ec2e212f9ed18c979182a0288337020493..15e9254e9d8757526ceff48366f98a1877f326a7 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -137,7 +137,7 @@ class Throttle: else: - def throttled_value() -> None: # type: ignore + def throttled_value() -> None: # type: ignore[misc] """Stand-in function for when real func is being throttled.""" return None @@ -191,7 +191,7 @@ class Throttle: if force or utcnow() - throttle[1] > self.min_time: result = method(*args, **kwargs) throttle[1] = utcnow() - return result # type: ignore + return result # type: ignore[no-any-return] return throttled_value() finally: diff --git a/homeassistant/util/json.py b/homeassistant/util/json.py index 9c98691c605edd906101b673731e334e533514a9..fdee7a7a90f29697c50c70c9242f8fd9692fa46d 100644 --- a/homeassistant/util/json.py +++ b/homeassistant/util/json.py @@ -30,7 +30,7 @@ def load_json(filename: str, default: list | dict | None = None) -> list | dict: """ try: with open(filename, encoding="utf-8") as fdesc: - return json.loads(fdesc.read()) # type: ignore + return json.loads(fdesc.read()) # type: ignore[no-any-return] except FileNotFoundError: # This is not a fatal error _LOGGER.debug("JSON file not found: %s", filename) diff --git a/homeassistant/util/package.py b/homeassistant/util/package.py index a1ee2b9f5845347e78849483c0cb7802580c6a80..aad93e375424fdd64468337372b10248c04a4b6d 100644 --- a/homeassistant/util/package.py +++ b/homeassistant/util/package.py @@ -50,7 +50,7 @@ def is_installed(package: str) -> bool: # was aborted while in progress see # https://github.com/home-assistant/core/issues/47699 if installed_version is None: - _LOGGER.error("Installed version for %s resolved to None", req.project_name) # type: ignore + _LOGGER.error("Installed version for %s resolved to None", req.project_name) # type: ignore[unreachable] return False return installed_version in req except PackageNotFoundError: diff --git a/homeassistant/util/unit_system.py b/homeassistant/util/unit_system.py index dfe73b0e937ae9e410014331ad19bb668715a62c..e964fee798c892a2a9acdd8e95e30773017c15a3 100644 --- a/homeassistant/util/unit_system.py +++ b/homeassistant/util/unit_system.py @@ -134,7 +134,7 @@ class UnitSystem: raise TypeError(f"{length!s} is not a numeric value.") # type ignore: https://github.com/python/mypy/issues/7207 - return distance_util.convert( # type: ignore + return distance_util.convert( # type: ignore[unreachable] length, from_unit, self.length_unit ) @@ -144,7 +144,7 @@ class UnitSystem: raise TypeError(f"{precip!s} is not a numeric value.") # type ignore: https://github.com/python/mypy/issues/7207 - return distance_util.convert( # type: ignore + return distance_util.convert( # type: ignore[unreachable] precip, from_unit, self.accumulated_precipitation_unit ) @@ -154,7 +154,7 @@ class UnitSystem: raise TypeError(f"{pressure!s} is not a numeric value.") # type ignore: https://github.com/python/mypy/issues/7207 - return pressure_util.convert( # type: ignore + return pressure_util.convert( # type: ignore[unreachable] pressure, from_unit, self.pressure_unit ) @@ -164,7 +164,7 @@ class UnitSystem: raise TypeError(f"{wind_speed!s} is not a numeric value.") # type ignore: https://github.com/python/mypy/issues/7207 - return speed_util.convert(wind_speed, from_unit, self.wind_speed_unit) # type: ignore + return speed_util.convert(wind_speed, from_unit, self.wind_speed_unit) # type: ignore[unreachable] def volume(self, volume: float | None, from_unit: str) -> float: """Convert the given volume to this unit system.""" @@ -172,7 +172,7 @@ class UnitSystem: raise TypeError(f"{volume!s} is not a numeric value.") # type ignore: https://github.com/python/mypy/issues/7207 - return volume_util.convert(volume, from_unit, self.volume_unit) # type: ignore + return volume_util.convert(volume, from_unit, self.volume_unit) # type: ignore[unreachable] def as_dict(self) -> dict[str, str]: """Convert the unit system to a dictionary.""" diff --git a/homeassistant/util/yaml/dumper.py b/homeassistant/util/yaml/dumper.py index 8e9cb382b6c369a352912b759efde861a08f93f4..3eafc8abdd7cb3a1b2e23e5b3950dce78f6500b1 100644 --- a/homeassistant/util/yaml/dumper.py +++ b/homeassistant/util/yaml/dumper.py @@ -24,7 +24,7 @@ def save_yaml(path: str, data: dict) -> None: # From: https://gist.github.com/miracle2k/3184458 -def represent_odict( # type: ignore +def represent_odict( # type: ignore[no-untyped-def] dumper, tag, mapping, flow_style=None ) -> yaml.MappingNode: """Like BaseRepresenter.represent_mapping but does not issue the sort().""" diff --git a/homeassistant/util/yaml/loader.py b/homeassistant/util/yaml/loader.py index e6ac5fd364a8e20bc378b2159728e7277a39ffd8..84349ef91a93dfa821c00e2a3eb9f65f903150b1 100644 --- a/homeassistant/util/yaml/loader.py +++ b/homeassistant/util/yaml/loader.py @@ -100,7 +100,7 @@ class SafeLineLoader(yaml.SafeLoader): """Annotate a node with the first line it was seen.""" last_line: int = self.line node: yaml.nodes.Node = super().compose_node(parent, index) # type: ignore[assignment] - node.__line__ = last_line + 1 # type: ignore + node.__line__ = last_line + 1 # type: ignore[attr-defined] return node @@ -149,7 +149,7 @@ def _add_reference( ... -def _add_reference(obj, loader: SafeLineLoader, node: yaml.nodes.Node): # type: ignore +def _add_reference(obj, loader: SafeLineLoader, node: yaml.nodes.Node): # type: ignore[no-untyped-def] """Add file reference information to an object.""" if isinstance(obj, list): obj = NodeListClass(obj)