From 26b47a5dd3aebef29ca0ed7524bc116fb0abe33a Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 15 May 2023 15:31:32 +0000 Subject: [PATCH] Type hints and docstrings. --- matcher/model.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/matcher/model.py b/matcher/model.py index eddb447..aac4527 100644 --- a/matcher/model.py +++ b/matcher/model.py @@ -413,12 +413,15 @@ class ItemLocation(Base): return loc -def location_objects(coords): - locations = [] - for pid, coord_list in coords.items(): +def location_objects( + coords_dict: dict[str, list[wikidata.Coords]] +) -> list[ItemLocation]: + """Create location objects with the given coordinates.""" + locations: list[ItemLocation] = [] + for pid, coord_list in coords_dict.items(): for num, coords in enumerate(coord_list): point = f"POINT({coords['longitude']} {coords['latitude']})" - loc = ItemLocation( + loc: ItemLocation = ItemLocation( property_id=int(pid[1:]), statement_order=num, location=point ) locations.append(loc)