Add type ignore error codes [util] (#66777)
This commit is contained in:
parent
0ac9376ee4
commit
0188e8b319
6 changed files with 12 additions and 12 deletions
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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()."""
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue