From 4b27980d525d409c1477182aba7d900238e8c701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Trellu?= Date: Mon, 12 Oct 2026 20:42:20 -0400 Subject: [PATCH] refactor: initialise the vocabulary memo in __init__, no getattr SkillResources._vocabularies_memo was only created by the first _locale_vocabularies() call, so the read guarded it with getattr. It is now set to None in __init__ and read directly. Co-Authored-By: Claude Opus 5.5 --- ovos_workshop/resource_files.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ovos_workshop/resource_files.py b/ovos_workshop/resource_files.py index eb752d9f..18a6164b 100644 --- a/ovos_workshop/resource_files.py +++ b/ovos_workshop/resource_files.py @@ -800,6 +800,9 @@ def __init__(self, skill_directory: str, self.types = self._define_resource_types() self._dialog_renderer = dialog_renderer self.static = dict() + # (directories, file signature, vocabularies, last check) of the last + # _locale_vocabularies() call, see there + self._vocabularies_memo: Optional[tuple] = None @property def dialog_renderer(self) -> MustacheDialogRenderer: @@ -939,7 +942,7 @@ def _locale_vocabularies(self) -> Dict[str, List[str]]: vocab_type = self.types.vocabulary cacheable = not vocab_type.user_directory if cacheable: - memo = getattr(self, "_vocabularies_memo", None) + memo = self._vocabularies_memo if memo is not None and memo[0] == (vocab_type.base_directory, vocab_type.workshop_directory) \ and _still_fresh(memo[1], memo[3]):