Enable strict typing for apcupsd (#84861)

This commit is contained in:
Yuxin Wang 2022-12-30 15:48:29 -05:00 committed by GitHub
parent 7abff358a5
commit 06095b1fec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View File

@ -58,6 +58,7 @@ homeassistant.components.amcrest.*
homeassistant.components.ampio.* homeassistant.components.ampio.*
homeassistant.components.analytics.* homeassistant.components.analytics.*
homeassistant.components.anthemav.* homeassistant.components.anthemav.*
homeassistant.components.apcupsd.*
homeassistant.components.aqualogic.* homeassistant.components.aqualogic.*
homeassistant.components.aseko_pool_live.* homeassistant.components.aseko_pool_live.*
homeassistant.components.asuswrt.* homeassistant.components.asuswrt.*

View File

@ -62,7 +62,7 @@ class APCUPSdData:
"""Initialize the data object.""" """Initialize the data object."""
self._host = host self._host = host
self._port = port self._port = port
self.status: dict[str, Any] = {} self.status: dict[str, str] = {}
@property @property
def name(self) -> str | None: def name(self) -> str | None:
@ -100,7 +100,7 @@ class APCUPSdData:
return self.status.get("STATFLAG") return self.status.get("STATFLAG")
@Throttle(MIN_TIME_BETWEEN_UPDATES) @Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self, **kwargs): def update(self, **kwargs: Any) -> None:
"""Fetch the latest status from APCUPSd. """Fetch the latest status from APCUPSd.
Note that the result dict uses upper case for each resource, where our Note that the result dict uses upper case for each resource, where our

View File

@ -465,7 +465,7 @@ async def async_setup_entry(
async_add_entities(entities, update_before_add=True) async_add_entities(entities, update_before_add=True)
def infer_unit(value): def infer_unit(value: str) -> tuple[str, str | None]:
"""If the value ends with any of the units from ALL_UNITS. """If the value ends with any of the units from ALL_UNITS.
Split the unit off the end of the value and return the value, unit tuple Split the unit off the end of the value and return the value, unit tuple

View File

@ -333,6 +333,16 @@ disallow_untyped_defs = true
warn_return_any = true warn_return_any = true
warn_unreachable = true warn_unreachable = true
[mypy-homeassistant.components.apcupsd.*]
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.aqualogic.*] [mypy-homeassistant.components.aqualogic.*]
check_untyped_defs = true check_untyped_defs = true
disallow_incomplete_defs = true disallow_incomplete_defs = true