Activate mypy for todoist (#55096)
This commit is contained in:
parent
0ab99fc8bf
commit
336aa74317
3 changed files with 10 additions and 7 deletions
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Todoist task management (https://todoist.com)."""
|
"""Support for Todoist task management (https://todoist.com)."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -226,14 +228,17 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _parse_due_date(data: dict, gmt_string) -> datetime:
|
def _parse_due_date(data: dict, gmt_string) -> datetime | None:
|
||||||
"""Parse the due date dict into a datetime object."""
|
"""Parse the due date dict into a datetime object."""
|
||||||
# Add time information to date only strings.
|
# Add time information to date only strings.
|
||||||
if len(data["date"]) == 10:
|
if len(data["date"]) == 10:
|
||||||
return datetime.fromisoformat(data["date"]).replace(tzinfo=dt.UTC)
|
return datetime.fromisoformat(data["date"]).replace(tzinfo=dt.UTC)
|
||||||
if dt.parse_datetime(data["date"]).tzinfo is None:
|
nowtime = dt.parse_datetime(data["date"])
|
||||||
|
if not nowtime:
|
||||||
|
return None
|
||||||
|
if nowtime.tzinfo is None:
|
||||||
data["date"] += gmt_string
|
data["date"] += gmt_string
|
||||||
return dt.as_utc(dt.parse_datetime(data["date"]))
|
return dt.as_utc(nowtime)
|
||||||
|
|
||||||
|
|
||||||
class TodoistProjectDevice(CalendarEventDevice):
|
class TodoistProjectDevice(CalendarEventDevice):
|
||||||
|
@ -533,6 +538,8 @@ class TodoistProjectData:
|
||||||
due_date = _parse_due_date(
|
due_date = _parse_due_date(
|
||||||
task["due"], self._api.state["user"]["tz_info"]["gmt_string"]
|
task["due"], self._api.state["user"]["tz_info"]["gmt_string"]
|
||||||
)
|
)
|
||||||
|
if not due_date:
|
||||||
|
continue
|
||||||
midnight = dt.as_utc(
|
midnight = dt.as_utc(
|
||||||
dt.parse_datetime(
|
dt.parse_datetime(
|
||||||
due_date.strftime("%Y-%m-%d")
|
due_date.strftime("%Y-%m-%d")
|
||||||
|
|
3
mypy.ini
3
mypy.ini
|
@ -1622,9 +1622,6 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.tesla.*]
|
[mypy-homeassistant.components.tesla.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.todoist.*]
|
|
||||||
ignore_errors = true
|
|
||||||
|
|
||||||
[mypy-homeassistant.components.toon.*]
|
[mypy-homeassistant.components.toon.*]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||||
"homeassistant.components.telegram_bot.*",
|
"homeassistant.components.telegram_bot.*",
|
||||||
"homeassistant.components.template.*",
|
"homeassistant.components.template.*",
|
||||||
"homeassistant.components.tesla.*",
|
"homeassistant.components.tesla.*",
|
||||||
"homeassistant.components.todoist.*",
|
|
||||||
"homeassistant.components.toon.*",
|
"homeassistant.components.toon.*",
|
||||||
"homeassistant.components.tplink.*",
|
"homeassistant.components.tplink.*",
|
||||||
"homeassistant.components.unifi.*",
|
"homeassistant.components.unifi.*",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue