Set strict-typing in Habitica quality scale record (#135899)

* Set strict-typing in Habitica quality scale record

* cast
pull/127851/merge
Manu 2025-01-18 16:35:35 +01:00 committed by GitHub
parent 5a7b6cd7a0
commit 595f49ee9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 5 deletions

View File

@ -224,6 +224,7 @@ homeassistant.components.gpsd.*
homeassistant.components.greeneye_monitor.*
homeassistant.components.group.*
homeassistant.components.guardian.*
homeassistant.components.habitica.*
homeassistant.components.hardkernel.*
homeassistant.components.hardware.*
homeassistant.components.here_travel_time.*

View File

@ -2,7 +2,6 @@
from habiticalib import Habitica
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
@ -61,6 +60,6 @@ async def async_setup_entry(
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: HabiticaConfigEntry) -> bool:
"""Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -6,7 +6,7 @@ from abc import abstractmethod
from dataclasses import asdict
from datetime import date, datetime, timedelta
from enum import StrEnum
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, cast
from uuid import UUID
from dateutil.rrule import rrule
@ -95,9 +95,11 @@ class HabiticaCalendarEntity(HabiticaBase, CalendarEntity):
) -> list[datetime]:
"""Calculate recurrence dates based on start_date and end_date."""
if end_date:
return recurrences.between(
recurrence_dates = recurrences.between(
start_date, end_date - timedelta(days=1), inc=True
)
return cast(list[datetime], recurrence_dates)
# if no end_date is given, return only the next recurrence
return [recurrences.after(start_date, inc=True)]

View File

@ -79,4 +79,4 @@ rules:
# Platinum
async-dependency: todo
inject-websession: done
strict-typing: todo
strict-typing: done

10
mypy.ini generated
View File

@ -1996,6 +1996,16 @@ disallow_untyped_defs = true
warn_return_any = true
warn_unreachable = true
[mypy-homeassistant.components.habitica.*]
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.hardkernel.*]
check_untyped_defs = true
disallow_incomplete_defs = true