fix: resolve ruff lint and format errors across codebase

Fix E402 import ordering, F841 unused variable, F541 unnecessary
f-strings, F401 unused import, and auto-format 6 files.
This commit is contained in:
bensig
2026-04-04 18:37:17 -07:00
parent 0f8fa8c7d5
commit 6d8c462219
7 changed files with 333 additions and 200 deletions
+42 -31
View File
@@ -71,15 +71,17 @@ def build_graph(col=None, config=None):
wings = sorted(data["wings"])
if len(wings) >= 2:
for i, wa in enumerate(wings):
for wb in wings[i + 1:]:
for wb in wings[i + 1 :]:
for hall in data["halls"]:
edges.append({
"room": room,
"wing_a": wa,
"wing_b": wb,
"hall": hall,
"count": data["count"],
})
edges.append(
{
"room": room,
"wing_a": wa,
"wing_b": wb,
"hall": hall,
"count": data["count"],
}
)
# Convert sets to lists for JSON serialization
nodes = {}
@@ -104,17 +106,22 @@ def traverse(start_room: str, col=None, config=None, max_hops: int = 2):
nodes, edges = build_graph(col, config)
if start_room not in nodes:
return {"error": f"Room '{start_room}' not found", "suggestions": _fuzzy_match(start_room, nodes)}
return {
"error": f"Room '{start_room}' not found",
"suggestions": _fuzzy_match(start_room, nodes),
}
start = nodes[start_room]
visited = {start_room}
results = [{
"room": start_room,
"wings": start["wings"],
"halls": start["halls"],
"count": start["count"],
"hop": 0,
}]
results = [
{
"room": start_room,
"wings": start["wings"],
"halls": start["halls"],
"count": start["count"],
"hop": 0,
}
]
# BFS traversal
frontier = [(start_room, 0)]
@@ -133,14 +140,16 @@ def traverse(start_room: str, col=None, config=None, max_hops: int = 2):
shared_wings = current_wings & set(data["wings"])
if shared_wings:
visited.add(room)
results.append({
"room": room,
"wings": data["wings"],
"halls": data["halls"],
"count": data["count"],
"hop": depth + 1,
"connected_via": sorted(shared_wings),
})
results.append(
{
"room": room,
"wings": data["wings"],
"halls": data["halls"],
"count": data["count"],
"hop": depth + 1,
"connected_via": sorted(shared_wings),
}
)
if depth + 1 < max_hops:
frontier.append((room, depth + 1))
@@ -167,13 +176,15 @@ def find_tunnels(wing_a: str = None, wing_b: str = None, col=None, config=None):
if wing_b and wing_b not in wings:
continue
tunnels.append({
"room": room,
"wings": wings,
"halls": data["halls"],
"count": data["count"],
"recent": data["dates"][-1] if data["dates"] else "",
})
tunnels.append(
{
"room": room,
"wings": wings,
"halls": data["halls"],
"count": data["count"],
"recent": data["dates"][-1] if data["dates"] else "",
}
)
tunnels.sort(key=lambda x: -x["count"])
return tunnels[:50]