Skip to content

Commit 141bcae

Browse files
authored
Add Home Connect to .strict-typing (#138799)
* Add Home Connect to .strict-typing * Fix mypy errors
1 parent 8ae52cd commit 141bcae

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

.strict-typing

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ homeassistant.components.here_travel_time.*
234234
homeassistant.components.history.*
235235
homeassistant.components.history_stats.*
236236
homeassistant.components.holiday.*
237+
homeassistant.components.home_connect.*
237238
homeassistant.components.homeassistant.*
238239
homeassistant.components.homeassistant_alerts.*
239240
homeassistant.components.homeassistant_green.*

homeassistant/components/home_connect/__init__.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async def _get_client_and_ha_id(
237237
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: C901
238238
"""Set up Home Connect component."""
239239

240-
async def _async_service_program(call: ServiceCall, start: bool):
240+
async def _async_service_program(call: ServiceCall, start: bool) -> None:
241241
"""Execute calls to services taking a program."""
242242
program = call.data[ATTR_PROGRAM]
243243
client, ha_id = await _get_client_and_ha_id(hass, call.data[ATTR_DEVICE_ID])
@@ -323,7 +323,9 @@ async def _async_service_program(call: ServiceCall, start: bool):
323323
},
324324
) from err
325325

326-
async def _async_service_set_program_options(call: ServiceCall, active: bool):
326+
async def _async_service_set_program_options(
327+
call: ServiceCall, active: bool
328+
) -> None:
327329
"""Execute calls to services taking a program."""
328330
option_key = call.data[ATTR_KEY]
329331
value = call.data[ATTR_VALUE]
@@ -396,7 +398,9 @@ async def _async_service_set_program_options(call: ServiceCall, active: bool):
396398
},
397399
) from err
398400

399-
async def _async_service_command(call: ServiceCall, command_key: CommandKey):
401+
async def _async_service_command(
402+
call: ServiceCall, command_key: CommandKey
403+
) -> None:
400404
"""Execute calls to services executing a command."""
401405
client, ha_id = await _get_client_and_ha_id(hass, call.data[ATTR_DEVICE_ID])
402406

@@ -412,15 +416,15 @@ async def _async_service_command(call: ServiceCall, command_key: CommandKey):
412416
},
413417
) from err
414418

415-
async def async_service_option_active(call: ServiceCall):
419+
async def async_service_option_active(call: ServiceCall) -> None:
416420
"""Service for setting an option for an active program."""
417421
await _async_service_set_program_options(call, True)
418422

419-
async def async_service_option_selected(call: ServiceCall):
423+
async def async_service_option_selected(call: ServiceCall) -> None:
420424
"""Service for setting an option for a selected program."""
421425
await _async_service_set_program_options(call, False)
422426

423-
async def async_service_setting(call: ServiceCall):
427+
async def async_service_setting(call: ServiceCall) -> None:
424428
"""Service for changing a setting."""
425429
key = call.data[ATTR_KEY]
426430
value = call.data[ATTR_VALUE]
@@ -439,19 +443,19 @@ async def async_service_setting(call: ServiceCall):
439443
},
440444
) from err
441445

442-
async def async_service_pause_program(call: ServiceCall):
446+
async def async_service_pause_program(call: ServiceCall) -> None:
443447
"""Service for pausing a program."""
444448
await _async_service_command(call, CommandKey.BSH_COMMON_PAUSE_PROGRAM)
445449

446-
async def async_service_resume_program(call: ServiceCall):
450+
async def async_service_resume_program(call: ServiceCall) -> None:
447451
"""Service for resuming a paused program."""
448452
await _async_service_command(call, CommandKey.BSH_COMMON_RESUME_PROGRAM)
449453

450-
async def async_service_select_program(call: ServiceCall):
454+
async def async_service_select_program(call: ServiceCall) -> None:
451455
"""Service for selecting a program."""
452456
await _async_service_program(call, False)
453457

454-
async def async_service_set_program_and_options(call: ServiceCall):
458+
async def async_service_set_program_and_options(call: ServiceCall) -> None:
455459
"""Service for setting a program and options."""
456460
data = dict(call.data)
457461
program = data.pop(ATTR_PROGRAM, None)
@@ -521,7 +525,7 @@ async def async_service_set_program_and_options(call: ServiceCall):
521525
},
522526
) from err
523527

524-
async def async_service_start_program(call: ServiceCall):
528+
async def async_service_start_program(call: ServiceCall) -> None:
525529
"""Service for starting a program."""
526530
await _async_service_program(call, True)
527531

homeassistant/components/home_connect/api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""API for Home Connect bound to HASS OAuth."""
22

3+
from typing import cast
4+
35
from aiohomeconnect.client import AbstractAuth
46
from aiohomeconnect.const import API_ENDPOINT
57

@@ -25,4 +27,4 @@ async def async_get_access_token(self) -> str:
2527
"""Return a valid access token."""
2628
await self.session.async_ensure_token_valid()
2729

28-
return self.session.token["access_token"]
30+
return cast(str, self.session.token["access_token"])

homeassistant/components/home_connect/coordinator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ async def _event_listener(self) -> None:
254254
await self.async_refresh()
255255

256256
@callback
257-
def _call_event_listener(self, event_message: EventMessage):
257+
def _call_event_listener(self, event_message: EventMessage) -> None:
258258
"""Call listener for event."""
259259
for event in event_message.data.items:
260260
for listener in self.context_listeners.get(
@@ -263,7 +263,7 @@ def _call_event_listener(self, event_message: EventMessage):
263263
listener()
264264

265265
@callback
266-
def _call_all_event_listeners_for_appliance(self, ha_id: str):
266+
def _call_all_event_listeners_for_appliance(self, ha_id: str) -> None:
267267
for listener, context in self._listeners.values():
268268
if isinstance(context, tuple) and context[0] == ha_id:
269269
listener()

mypy.ini

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)