Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/game_resources.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import enum
import requests
import logging
from typing import Callable, Dict, List, Tuple

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use import typing as t and t.Callable, t.Dict...


logger = logging.getLogger(__name__)

def fetch_dynamic_enum(enum_name, url, process_items):
def fetch_dynamic_enum(enum_name: str, url: str, process_items: Callable[[List[Dict]], List[Tuple[str, str]]]) -> enum.Enum:
"""Fetch data from API and create an Enum dynamically with deduplication"""
try:
logger.info(f"Fetching {enum_name} data from {url}")
Expand All @@ -19,7 +20,7 @@ def fetch_dynamic_enum(enum_name, url, process_items):
if name not in unique_items:
unique_items[name] = value
else:
print(f"Warning: Duplicate map name detected and skipped - {name}")
logger.warning(f"Duplicate map name detected and skipped: {name}")

logger.info("Processed %s items: %s", enum_name, ', '.join(f"{k}: {v}" for k, v in unique_items.items()))

Expand All @@ -28,7 +29,7 @@ def fetch_dynamic_enum(enum_name, url, process_items):
logger.error(f"Failed to fetch {enum_name}: {e}")
raise RuntimeError(f"Failed to fetch {enum_name}: {e}")

def process_agents(agents_data):
def process_agents(agents_data: List[Dict]) -> List[Tuple[str, str]]:
logger.info("Processing agents data")
agents = [
a for a in agents_data
Expand All @@ -41,7 +42,7 @@ def process_agents(agents_data):
for a in sorted_agents
]

def process_maps(maps_data):
def process_maps(maps_data: List[Dict]) :

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you accidentally deleted the return type hint

logger.info("Processing maps data")
map_items = []
for m in maps_data:
Expand Down