Partial fix for mypy issues

This commit is contained in:
Ian Renton
2026-09-20 20:42:16 +01:00
parent 93ea27510f
commit 203758fa2d
25 changed files with 244 additions and 147 deletions
+4 -3
View File
@@ -37,12 +37,12 @@ class SpotProvider:
# off to SSE listeners.
spots = sorted(spots, key=lambda s: s.time if s and s.time else 0)
for spot in spots:
if datetime.fromtimestamp(spot.time, pytz.UTC) > self.last_spot_time:
if datetime.fromtimestamp(spot.time or 0, pytz.UTC) > self.last_spot_time:
# Fill in any blanks and add to the list
spot.infer_missing()
self._add_spot(spot)
if spots:
self.last_spot_time = datetime.fromtimestamp(max(s.time for s in spots), pytz.UTC)
self.last_spot_time = datetime.fromtimestamp(max(s.time or 0 for s in spots), pytz.UTC)
def _submit(self, spot: Spot) -> None:
"""Submit a single spot retrieved from the provider. This will be added to the list regardless of its age. Spots
@@ -52,9 +52,10 @@ class SpotProvider:
# Fill in any blanks and add to the list
spot.infer_missing()
self._add_spot(spot)
self.last_spot_time = datetime.fromtimestamp(spot.time, pytz.UTC)
self.last_spot_time = datetime.fromtimestamp(spot.time or 0, pytz.UTC)
def _add_spot(self, spot: Spot) -> None:
assert spot.id is not None, "infer_missing() always assigns an id"
if not spot.expired():
self._spots.set(spot.id, spot)