Autogenerated type safety parameterisation of all methods

This commit is contained in:
Ian Renton
2026-09-20 20:02:19 +01:00
parent 6037e742cc
commit 324dd1414b
132 changed files with 1228 additions and 706 deletions
+8 -4
View File
@@ -1,7 +1,11 @@
from __future__ import annotations
from core.enums import ActivityName
from data.activities import ACTIVITIES
from data.activity import Activity
def get_activity_by_name(name):
def get_activity_by_name(name: str) -> Activity | None:
"""Utility function to resolve an arbitrary, case-insensitive activity name string (e.g. from a spot comment, a
provider, or an API request) to the matching known Activity. Returns None if no match is found."""
@@ -13,7 +17,7 @@ def get_activity_by_name(name):
return None
def get_ref_regex_for_activity(activity):
def get_ref_regex_for_activity(activity: str) -> str | None:
"""Utility function to get the regex string for an activity reference for a named activity. If no match is
found, None will be returned."""
@@ -21,14 +25,14 @@ def get_ref_regex_for_activity(activity):
return found.ref_regex if found else None
def get_icon_for_activity(activity):
def get_icon_for_activity(activity: str) -> str | None:
"""Utility function to get the icon for a named activity. If no match is found, None will be returned."""
found = get_activity_by_name(activity)
return found.icon if found else None
def get_activity_name_from_comment_name(activity):
def get_activity_name_from_comment_name(activity: str) -> ActivityName | None:
"""Utility function to get the name of an activity from its "comment name". Generally these will be the same
but there are some cases (e.g. is "TOTA" Towers, Tiles or Toilets?) where we need to transform one to the
other."""