mirror of
https://github.com/home-assistant/core
synced 2024-07-08 20:17:01 +00:00
Add strict typing to islamic prayer times (#99585)
* Add strict typing to islamic prayer times * fix mypy errors
This commit is contained in:
parent
e5210c5823
commit
0cc2c27115
|
@ -188,6 +188,7 @@ homeassistant.components.input_select.*
|
||||||
homeassistant.components.integration.*
|
homeassistant.components.integration.*
|
||||||
homeassistant.components.ipp.*
|
homeassistant.components.ipp.*
|
||||||
homeassistant.components.iqvia.*
|
homeassistant.components.iqvia.*
|
||||||
|
homeassistant.components.islamic_prayer_times.*
|
||||||
homeassistant.components.isy994.*
|
homeassistant.components.isy994.*
|
||||||
homeassistant.components.jellyfin.*
|
homeassistant.components.jellyfin.*
|
||||||
homeassistant.components.jewish_calendar.*
|
homeassistant.components.jewish_calendar.*
|
||||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any, cast
|
||||||
|
|
||||||
from prayer_times_calculator import PrayerTimesCalculator, exceptions
|
from prayer_times_calculator import PrayerTimesCalculator, exceptions
|
||||||
from requests.exceptions import ConnectionError as ConnError
|
from requests.exceptions import ConnectionError as ConnError
|
||||||
|
@ -37,7 +38,7 @@ class IslamicPrayerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, datetim
|
||||||
"""Return the calculation method."""
|
"""Return the calculation method."""
|
||||||
return self.config_entry.options.get(CONF_CALC_METHOD, DEFAULT_CALC_METHOD)
|
return self.config_entry.options.get(CONF_CALC_METHOD, DEFAULT_CALC_METHOD)
|
||||||
|
|
||||||
def get_new_prayer_times(self) -> dict[str, str]:
|
def get_new_prayer_times(self) -> dict[str, Any]:
|
||||||
"""Fetch prayer times for today."""
|
"""Fetch prayer times for today."""
|
||||||
calc = PrayerTimesCalculator(
|
calc = PrayerTimesCalculator(
|
||||||
latitude=self.hass.config.latitude,
|
latitude=self.hass.config.latitude,
|
||||||
|
@ -45,7 +46,7 @@ class IslamicPrayerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, datetim
|
||||||
calculation_method=self.calc_method,
|
calculation_method=self.calc_method,
|
||||||
date=str(dt_util.now().date()),
|
date=str(dt_util.now().date()),
|
||||||
)
|
)
|
||||||
return calc.fetch_prayer_times()
|
return cast(dict[str, Any], calc.fetch_prayer_times())
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_schedule_future_update(self, midnight_dt: datetime) -> None:
|
def async_schedule_future_update(self, midnight_dt: datetime) -> None:
|
||||||
|
@ -98,7 +99,7 @@ class IslamicPrayerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, datetim
|
||||||
self.hass, self.async_request_update, next_update_at
|
self.hass, self.async_request_update, next_update_at
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_request_update(self, *_) -> None:
|
async def async_request_update(self, _: datetime) -> None:
|
||||||
"""Request update from coordinator."""
|
"""Request update from coordinator."""
|
||||||
await self.async_request_refresh()
|
await self.async_request_refresh()
|
||||||
|
|
||||||
|
|
10
mypy.ini
10
mypy.ini
|
@ -1642,6 +1642,16 @@ disallow_untyped_defs = true
|
||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.islamic_prayer_times.*]
|
||||||
|
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.isy994.*]
|
[mypy-homeassistant.components.isy994.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user