Make mypy work again #8

Merged
alexander merged 16 commits from fix-mypy into develop 2026-11-30 14:13:44 +01:00
2 changed files with 10 additions and 0 deletions
Showing only changes of commit 607055d55a - Show all commits

Raise an error if Path._directions is not set ...

... instead of failing inside `json.loads()` on `None`
Alexander Hess 2026-11-30 12:48:23 +01:00
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -270,6 +270,9 @@ class Path(meta.Base):
Implementation detail: This property is cached as none of the
underlying attributes (i.e., `._directions`) are to be changed.
"""
if not self._directions:
raise RuntimeError("_directions is not set")
points = [utils.Location(*point) for point in json.loads(self._directions)]
for point in points:
point.relate_to(self.first_address.city.southwest)

View file

@ -670,6 +670,13 @@ class TestSyncWithGoogleMaps:
class TestProperties:
"""Test properties in `Path`."""
def test_waypoints_no_directions(self, path):
"""Test `Path.waypoints` property."""
path._directions = None
with pytest.raises(RuntimeError, match="not set"):
int(path.waypoints)
def test_waypoints_structure(self, path):
"""Test `Path.waypoints` property."""
result = path.waypoints