Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set strict-typing in Habitica quality scale record #135899

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .strict-typing
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/habitica/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
6 changes: 5 additions & 1 deletion homeassistant/components/habitica/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ def get_recurrence_dates(
) -> 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
)
if TYPE_CHECKING:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is typing breaking here? should we just cast(recurrence_dates , list[date | datetime]?

assert isinstance(recurrence_dates, list)
assert all(isinstance(date, datetime) for date in recurrence_dates)
return recurrence_dates
# if no end_date is given, return only the next recurrence
return [recurrences.after(start_date, inc=True)]

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/habitica/quality_scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ rules:
# Platinum
async-dependency: todo
inject-websession: done
strict-typing: todo
strict-typing: done
10 changes: 10 additions & 0 deletions mypy.ini

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading