From 4e9a1cab166ea768a4d7bcbbfb508277e4b1f581 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Tue, 27 May 2025 10:17:05 +0200
Subject: [PATCH] lint & typing

---
 mapping_provider/api/map.py            |  4 ++--
 mapping_provider/backends/inventory.py |  2 +-
 mapping_provider/backends/services.py  | 13 +++++++------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/mapping_provider/api/map.py b/mapping_provider/api/map.py
index b42956b..5e2ee9b 100644
--- a/mapping_provider/api/map.py
+++ b/mapping_provider/api/map.py
@@ -139,7 +139,7 @@ def get_pops() -> PopList:
             city=pop_dict['city'],
             country=pop_dict['country'],
         )
-    return PopList(pops=map(_make_pop, pop_list_obj))
+    return PopList(pops=list(map(_make_pop, pop_list_obj)))
 
 
 @router.get("/equipment")
@@ -163,7 +163,7 @@ def get_equipment() -> EquipmentList:
             pop=equipment_dict['pop'],
             status=equipment_dict['status'],
         )
-    return EquipmentList(equipment=map(_make_equipment, equipment_list_obj))
+    return EquipmentList(equipment=list(map(_make_equipment, equipment_list_obj)))
 
 
 @router.get("/trunks")
diff --git a/mapping_provider/backends/inventory.py b/mapping_provider/backends/inventory.py
index 6409cfa..459af84 100644
--- a/mapping_provider/backends/inventory.py
+++ b/mapping_provider/backends/inventory.py
@@ -1,10 +1,10 @@
 import concurrent.futures
-import jsonschema
 import logging
 import time
 from threading import Event
 from typing import Any
 
+import jsonschema
 import requests
 
 from . import cache
diff --git a/mapping_provider/backends/services.py b/mapping_provider/backends/services.py
index 124d967..b8f2cef 100644
--- a/mapping_provider/backends/services.py
+++ b/mapping_provider/backends/services.py
@@ -1,7 +1,7 @@
 import functools
 import logging
-from collections.abc import Generator
 import re
+from collections.abc import Generator
 from typing import Any
 
 from pydantic import BaseModel
@@ -36,9 +36,10 @@ class Service(BaseModel):
 class ServiceList(BaseModel):
     services: list[Service]
 
-def endpoint_to_pop(endpoint: dict[str, Any], inprov_equipment_dict: list[dict[str, str]]) -> str:
+
+def endpoint_to_pop(endpoint: dict[str, Any], inprov_equipment_dict: dict[str, dict[str, Any]]) -> str:
     
-    def _hostname_to_equipment(_hn):
+    def _hostname_to_equipment(_hn: str) -> str:
         m = re.match(r'^(.+)\.geant\.net$', _hn)
         if not m:
             logger.error(f'unexpected hostname pattern: {_hn}')
@@ -58,9 +59,9 @@ def endpoint_to_pop(endpoint: dict[str, Any], inprov_equipment_dict: list[dict[s
         logger.error(f'unknown endpoint equipment: {eq_name}')
         return '?'
 
-    return inprov_equipment_dict[eq_name]['pop']
-
-
+    pop_name = inprov_equipment_dict[eq_name]['pop']
+    assert isinstance(pop_name, str)  # mypy noise
+    return pop_name
 
 
 def _services(service_type: str | None = None) -> Generator[Service]:
-- 
GitLab