mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-21 06:47:42 +00:00
Autogenerated type safety parameterisation of all methods
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user