Skip to content

Commit

Permalink
Merge pull request #161 from dknowles2/mypy
Browse files Browse the repository at this point in the history
Fix typing errors and deserialization errors
  • Loading branch information
dknowles2 authored Jun 2, 2024
2 parents 7e50ac0 + 5e9b6df commit 9cf0303
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 77 deletions.
11 changes: 6 additions & 5 deletions pydrawise/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from datetime import datetime, timedelta
import time
from typing import Any

import aiohttp
import requests
Expand Down Expand Up @@ -237,7 +238,7 @@ def _zone_from_json(zone_json: dict) -> Zone:
remaining_time=timedelta(seconds=zone_json["run"]),
)
elif zone_json["time"] == 1576800000:
suspended_until = ZoneSuspension(end_time=datetime.max)
suspended_until = datetime.max
else:
now = datetime.now().replace(microsecond=0)
start_time = now + timedelta(seconds=zone_json["time"])
Expand Down Expand Up @@ -270,8 +271,8 @@ class LegacyHydrawise:

def __init__(self, user_token: str, load_on_init: bool = True) -> None:
self._api_key = user_token
self.controller_info = {}
self.controller_status = {}
self.controller_info: dict[str, Any] = {}
self.controller_status: dict[str, Any] = {}
if load_on_init:
self.update_controller_info()

Expand Down Expand Up @@ -350,7 +351,7 @@ def _get_controller_status(self) -> dict:
return self._get("statusschedule.php")

def suspend_zone(self, days: int, zone: int | None = None) -> dict:
params = {}
params: dict[str, Any] = {}

if days > 0:
params["custom"] = int(time.time() + (days * 24 * 60 * 60))
Expand All @@ -370,7 +371,7 @@ def suspend_zone(self, days: int, zone: int | None = None) -> dict:
return self._get("setzone.php", **params)

def run_zone(self, minutes: int, zone: int | None = None) -> dict:
params = {}
params: dict[str, Any] = {}

if zone is not None:
if not self.relays:
Expand Down
Loading

0 comments on commit 9cf0303

Please sign in to comment.